Commit f861e9a68f0b15de823d791ec49d22c159a28c38

Authored by Imanol-Mikel Barba Sabariego
1 parent 33630ee2

Begin migration to clion and code update

.gitignore 0 → 100644
  1 +.idea
... ...
CMakeLists.txt 0 → 100755
  1 +cmake_minimum_required(VERSION 3.3)
  2 +project(nagios_plugins)
  3 +
  4 +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  5 +
  6 +set(SOURCE_FILES check_memfree/check_memfree.cpp check_memfree/range.cpp check_memfree/aux.cpp)
  7 +add_executable(nagios_plugins ${SOURCE_FILES})
0 8 \ No newline at end of file
... ...
aux.cpp renamed to check_memfree/aux.cpp 100644 → 100755
aux.h renamed to check_memfree/aux.h 100644 → 100755
check_memfree_freebsd/aux.cpp 0 → 100755
  1 +#include "aux.h"
  2 +
  3 +void timer_handler (int signum)
  4 +{
  5 + if(signum == SIGVTALRM)
  6 + {
  7 + cout << servicename << " CRITICAL - timeout occurred" << endl;
  8 + exit(2);
  9 + }
  10 +}
  11 +
  12 +int str2int(string str)
  13 +{
  14 + int num;
  15 + stringstream sstream;
  16 + sstream << str;
  17 + if(!(sstream >> num))
  18 + {
  19 + throw integerConversionException("Integer conversion error");
  20 + }
  21 + return num;
  22 +}
  23 +
  24 +string int2str(int x)
  25 +{
  26 + string str;
  27 + stringstream sstream;
  28 + sstream << x;
  29 + sstream >> str;
  30 + return str;
  31 +}
  32 +
  33 +int exec(string cmd, string *output)
  34 +{
  35 + *output = "";
  36 + FILE* pipe = popen(cmd.c_str(), "r");
  37 + if (!pipe)
  38 + {
  39 + cout << "Error opening child process" << endl;
  40 + exit(3);
  41 + }
  42 + char buffer[128];
  43 + while(!feof(pipe))
  44 + {
  45 + if(fgets(buffer, 128, pipe) != NULL)
  46 + {
  47 + *output += buffer;
  48 + }
  49 + }
  50 + return pclose(pipe)/256;
  51 +}
... ...
check_memfree_freebsd/aux.h 0 → 100755
  1 +#ifndef AUX_H
  2 +#define AUX_H
  3 +
  4 +#include <sstream>
  5 +#include <iostream>
  6 +#include <exception>
  7 +
  8 +#include <stdlib.h>
  9 +#include <stdio.h>
  10 +#include <signal.h>
  11 +
  12 +using namespace std;
  13 +
  14 +extern char *servicename;
  15 +
  16 +int str2int(string str);
  17 +string int2str(int x);
  18 +int exec(string cmd, string *output);
  19 +void timer_handler (int signum);
  20 +
  21 +class integerConversionException : public exception
  22 +{
  23 + private:
  24 + string s;
  25 + public:
  26 + integerConversionException(std::string ss) : s(ss) {}
  27 + ~integerConversionException() throw () {}
  28 + const char* what() const throw() { return s.c_str(); }
  29 +};
  30 +
  31 +#endif
... ...
check_smart/aux.cpp 0 → 100755
  1 +#include "aux.h"
  2 +
  3 +void timer_handler (int signum)
  4 +{
  5 + if(signum == SIGVTALRM)
  6 + {
  7 + cout << servicename << " CRITICAL - timeout occurred" << endl;
  8 + exit(2);
  9 + }
  10 +}
  11 +
  12 +int str2int(string str)
  13 +{
  14 + int num;
  15 + stringstream sstream;
  16 + sstream << str;
  17 + if(!(sstream >> num))
  18 + {
  19 + throw integerConversionException("Integer conversion error");
  20 + }
  21 + return num;
  22 +}
  23 +
  24 +string int2str(int x)
  25 +{
  26 + string str;
  27 + stringstream sstream;
  28 + sstream << x;
  29 + sstream >> str;
  30 + return str;
  31 +}
  32 +
  33 +int exec(string cmd, string *output)
  34 +{
  35 + *output = "";
  36 + FILE* pipe = popen(cmd.c_str(), "r");
  37 + if (!pipe)
  38 + {
  39 + cout << "Error opening child process" << endl;
  40 + exit(3);
  41 + }
  42 + char buffer[128];
  43 + while(!feof(pipe))
  44 + {
  45 + if(fgets(buffer, 128, pipe) != NULL)
  46 + {
  47 + *output += buffer;
  48 + }
  49 + }
  50 + return pclose(pipe)/256;
  51 +}
... ...
check_smart/aux.h 0 → 100755
  1 +#ifndef AUX_H
  2 +#define AUX_H
  3 +
  4 +#include <sstream>
  5 +#include <iostream>
  6 +#include <exception>
  7 +
  8 +#include <stdlib.h>
  9 +#include <stdio.h>
  10 +#include <signal.h>
  11 +
  12 +using namespace std;
  13 +
  14 +extern char *servicename;
  15 +
  16 +int str2int(string str);
  17 +string int2str(int x);
  18 +int exec(string cmd, string *output);
  19 +void timer_handler (int signum);
  20 +
  21 +class integerConversionException : public exception
  22 +{
  23 + private:
  24 + string s;
  25 + public:
  26 + integerConversionException(std::string ss) : s(ss) {}
  27 + ~integerConversionException() throw () {}
  28 + const char* what() const throw() { return s.c_str(); }
  29 +};
  30 +
  31 +#endif
... ...
check_tftp/aux.cpp 0 → 100755
  1 +#include "aux.h"
  2 +
  3 +void timer_handler (int signum)
  4 +{
  5 + if(signum == SIGVTALRM)
  6 + {
  7 + cout << servicename << " CRITICAL - timeout occurred" << endl;
  8 + exit(2);
  9 + }
  10 +}
  11 +
  12 +int str2int(string str)
  13 +{
  14 + int num;
  15 + stringstream sstream;
  16 + sstream << str;
  17 + if(!(sstream >> num))
  18 + {
  19 + throw integerConversionException("Integer conversion error");
  20 + }
  21 + return num;
  22 +}
  23 +
  24 +string int2str(int x)
  25 +{
  26 + string str;
  27 + stringstream sstream;
  28 + sstream << x;
  29 + sstream >> str;
  30 + return str;
  31 +}
  32 +
  33 +int exec(string cmd, string *output)
  34 +{
  35 + *output = "";
  36 + FILE* pipe = popen(cmd.c_str(), "r");
  37 + if (!pipe)
  38 + {
  39 + cout << "Error opening child process" << endl;
  40 + exit(3);
  41 + }
  42 + char buffer[128];
  43 + while(!feof(pipe))
  44 + {
  45 + if(fgets(buffer, 128, pipe) != NULL)
  46 + {
  47 + *output += buffer;
  48 + }
  49 + }
  50 + return pclose(pipe)/256;
  51 +}
... ...
check_tftp/aux.h 0 → 100755
  1 +#ifndef AUX_H
  2 +#define AUX_H
  3 +
  4 +#include <sstream>
  5 +#include <iostream>
  6 +#include <exception>
  7 +
  8 +#include <stdlib.h>
  9 +#include <stdio.h>
  10 +#include <signal.h>
  11 +
  12 +using namespace std;
  13 +
  14 +extern char *servicename;
  15 +
  16 +int str2int(string str);
  17 +string int2str(int x);
  18 +int exec(string cmd, string *output);
  19 +void timer_handler (int signum);
  20 +
  21 +class integerConversionException : public exception
  22 +{
  23 + private:
  24 + string s;
  25 + public:
  26 + integerConversionException(std::string ss) : s(ss) {}
  27 + ~integerConversionException() throw () {}
  28 + const char* what() const throw() { return s.c_str(); }
  29 +};
  30 +
  31 +#endif
... ...