auxiliar.h 959 Bytes
//
// Created by Imanol on 28-may-16.
//

#ifndef NAGIOS_PLUGINS_AUXILIAR_H
#define NAGIOS_PLUGINS_AUXILIAR_H

#include <sstream>
#include <iostream>
#include <exception>

#include <stdlib.h>
#include <stdio.h>
#include <signal.h>

extern const char *servicename;

int str2int(const std::string& str);
std::string int2str(const int x);
double str2double(const std::string& str);
std::string double2str(const double x);
bool starts_with(const std::string& value, const std::string& begin);
bool ends_with(const std::string& value, const std::string& ending);
int exec(const std::string& cmd, std::string& output);
void timer_handler(int signum);

class ConversionException : public std::exception
{
private:
    std::string s;
public:
    ConversionException(std::string ss) : s(ss) {}
    ~ConversionException() throw () {}
    const char* what() const throw() { return s.c_str(); }
};

#endif //NAGIOS_PLUGINS_AUXILIAR_H