Commit 75bf9b0fde890cf94149a124b2adf95c629eace2

Authored by Imanol-Mikel Barba Sabariego
1 parent f861e9a6

cleaning

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