diff --git a/check_nfs4/README.md b/check_nfs4/README.md deleted file mode 100755 index 281556b..0000000 --- a/check_nfs4/README.md +++ /dev/null @@ -1,23 +0,0 @@ -``` -check_memfree v1.0 - -Check free memory space on local machine. - -Usage: -check_memfree [-hV] -w % -c % -check_memfree [-hV] -w -c - -Options: - -h - Print detailed help screen - -V - Print version information - -w INTEGER - Exit with WARNING status if less than INTEGER bytes of memory space are free - -w PERCENT% - Exit with WARNING status if less than PERCENT of memory space is free - -c INTEGER - Exit with CRITICAL status if less than INTEGER bytes of memory space are free - -c PERCENT% - Exit with CRITCAL status if less than PERCENT of memory space is free -``` diff --git a/check_nfs4/auxiliar.cpp b/check_nfs4/auxiliar.cpp deleted file mode 100755 index 53aca90..0000000 --- a/check_nfs4/auxiliar.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// -// Created by Imanol on 28-may-16. -// - -#include "auxiliar.h" - -void timer_handler (int signum) -{ - if(signum == SIGVTALRM) - { - cout << servicename << " CRITICAL - timeout occurred" << endl; - exit(2); - } -} - -int str2int(string str) -{ - int num; - stringstream sstream; - sstream << str; - if(!(sstream >> num)) - { - throw integerConversionException("Integer conversion error"); - } - return num; -} - -string int2str(int x) -{ - string str; - stringstream sstream; - sstream << x; - sstream >> str; - return str; -} - -int exec(string cmd, string *output) -{ - *output = ""; - FILE* pipe = popen(cmd.c_str(), "r"); - if (!pipe) - { - cout << "Error opening child process" << endl; - exit(3); - } - char buffer[128]; - while(!feof(pipe)) - { - if(fgets(buffer, 128, pipe) != NULL) - { - *output += buffer; - } - } - return pclose(pipe)/256; -} \ No newline at end of file diff --git a/check_nfs4/auxiliar.h b/check_nfs4/auxiliar.h deleted file mode 100755 index 6cc6e6a..0000000 --- a/check_nfs4/auxiliar.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// Created by Imanol on 28-may-16. -// - -#ifndef NAGIOS_PLUGINS_AUXILIAR_H -#define NAGIOS_PLUGINS_AUXILIAR_H - -#include -#include -#include - -#include -#include -#include - -using namespace std; - -extern char *servicename; - -int str2int(string str); -string int2str(int x); -int exec(string cmd, string *output); -void timer_handler (int signum); - -class integerConversionException : public exception -{ -private: - string s; -public: - integerConversionException(std::string ss) : s(ss) {} - ~integerConversionException() throw () {} - const char* what() const throw() { return s.c_str(); } -}; - -#endif //NAGIOS_PLUGINS_AUXILIAR_H diff --git a/check_nfs4/check_nfs4.cpp b/check_nfs4/check_nfs4.cpp deleted file mode 100755 index 8e73f42..0000000 --- a/check_nfs4/check_nfs4.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "check_nfs4.h" - -using namespace std; - -char *servicename = (char*)"NFSv4"; - -void printVersion() -{ - cout << "check_csgo v" << VERSION << endl << endl; -} - -void printHelp(bool longVersion) -{ - if(longVersion) - { - printVersion(); - cout << "Check CS:GO DS instance." << endl << endl; - printHelp(false); - cout << "Options:" << endl; - cout << " -h" << endl; - cout << " Print detailed help screen" << endl; - cout << " -V" << endl; - cout << " Print version information" << endl; - cout << " -H HOSTADDRESS" << endl; - cout << " Host where the Source DS is running" << endl; - cout << " -p" << endl; - cout << " Port where the Source DS is listening. Default is 27015." << endl << endl; - return; - } - cout << "Usage: " << endl << "check_csgo [-hV] -H HOSTADDRESS [-p PORT]" << endl << endl; -} - -int check_nfs4(char *hostname, char *mountpoint, string *detail) -{ - return 0; -} - -int main(int argc, char **argv) -{ - struct itimerval timer; - timer.it_value.tv_sec = 10; - timer.it_value.tv_usec = 0; - timer.it_interval.tv_sec = 0; - timer.it_interval.tv_usec = 0; - setitimer (ITIMER_VIRTUAL, &timer, 0); - - struct sigaction sa; - memset (&sa, 0, sizeof (sa)); - sa.sa_handler = &timer_handler; - sigaction (SIGVTALRM, &sa, 0); - - char *hostname = NULL; - char *mountpoint = NULL; - int c; - - while ((c = getopt (argc, argv, "H:m:Vh")) != -1) - { - switch(c) - { - case 'H': - hostname = optarg; - break; - case 'm': - mountpoint = optarg; - break; - case 'V': - printVersion(); - return 0; - case 'h': - printHelp(true); - return 0; - case '?': - printHelp(false); - return 3; - } - } - - if(hostname == NULL) - { - cout << "No HOSTADDRESS specified. Exiting." << endl; - return 3; - } - if(mountpoint == NULL) - { - cout << "No mountpoint specified. Exiting." << endl; - return 3; - } - - string details = ""; - int returnCode = check_nfs4(hostname,mountpoint,&details); - - cout << servicename; - switch(returnCode) - { - case 0: - cout << " OK"; - cout << " - " << mountpoint << " " << details << endl; - break; - - case 2: - cout << " CRITICAL - " << details << endl; - break; - } - - return returnCode; -} diff --git a/check_nfs4/check_nfs4.h b/check_nfs4/check_nfs4.h deleted file mode 100755 index 6cf9480..0000000 --- a/check_nfs4/check_nfs4.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CHECK_CSGO_H -#define CHECK_CSGO_H - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "auxiliar.h" -#include "udp.h" - -#define VERSION "1.0" - -int check_nfs4(char *hostname, char *mountpoint, string *detail); -void printVersion(); -void printHelp(bool longVersion); - -#endif diff --git a/check_nfs4/udp.cpp b/check_nfs4/udp.cpp deleted file mode 100644 index 534d5ba..0000000 --- a/check_nfs4/udp.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "udp.h" - -void setupSocket(uint16_t port, char *hostname, struct hostent *host, int timeout, struct sockaddr_in *si, int *s) -{ - if((*s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) - { - cout << "Couldn't create socket" << endl; - exit(3); - } - struct timeval tv; - tv.tv_sec = timeout; - tv.tv_usec = 0; - if(setsockopt(*s, SOL_SOCKET, SO_RCVTIMEO,&tv,sizeof(tv)) < 0) - { - cout << "Error setting socket timeout" << endl; - exit(3); - } - if(!(host = gethostbyname(hostname))) - { - cout << "Client could not get host address information" << endl; - exit(3); - } - - memset((char *) si, 0, sizeof(*si)); - si->sin_family = AF_INET; - memcpy (&(si->sin_addr), host->h_addr, host->h_length); - si->sin_port = htons(port); -} - -int sendMsg(int s, char *msg, size_t msgLength, struct sockaddr_in *si) -{ - return sendto(s, msg, msgLength, 0,(struct sockaddr*) si, sizeof(*si)); -} - -int recvMsg(int s, char *msg, size_t msgLength, struct sockaddr_in *si) -{ - size_t slen = sizeof(*si); - return recvfrom(s, msg, msgLength, 0, (struct sockaddr *) si, (socklen_t*)&slen); -} diff --git a/check_nfs4/udp.h b/check_nfs4/udp.h deleted file mode 100644 index 01a02c2..0000000 --- a/check_nfs4/udp.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef UDP_H -#define UDP_H - -#include - -#include -#include - -#include -#include -#include -#include - -using namespace std; - -void setupSocket(uint16_t port, char *hostname, struct hostent *host, int timeout, struct sockaddr_in *si, int *s); -int sendMsg(int s, char *msg, size_t msgLength, struct sockaddr_in *si); -int recvMsg(int s, char *msg, size_t msgLength, struct sockaddr_in *si); - -#endif