From 63734f52ab1b4b2c17545b26fc41016d6bbd80bd Mon Sep 17 00:00:00 2001 From: Monitoring Plugins Development Team Date: Sat, 18 Jan 2014 03:40:24 -0500 Subject: Project rename initial commit. This is an initial take at renaming the project to Monitoring Plugins. It's not expected to be fully complete, and it is expected to break things (The perl module for instance). More testing will be required before this goes mainline. --- lib/Makefile.am | 6 +-- lib/extra_opts.c | 4 +- lib/extra_opts.h | 2 +- lib/parse_ini.c | 4 +- lib/parse_ini.h | 2 +- lib/tests/Makefile.am | 2 +- lib/tests/test_utils.c | 48 ++++++++++++------------ lib/utils_base.c | 100 ++++++++++++++++++++++++------------------------- lib/utils_base.h | 4 +- lib/utils_cmd.c | 4 +- lib/utils_cmd.h | 2 +- lib/utils_disk.c | 2 +- lib/utils_tcp.c | 2 +- 13 files changed, 91 insertions(+), 91 deletions(-) (limited to 'lib') diff --git a/lib/Makefile.am b/lib/Makefile.am index 99fa591a..1515312c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,15 +2,15 @@ SUBDIRS = . tests -noinst_LIBRARIES = libnagiosplug.a +noinst_LIBRARIES = libmonitoringplug.a AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\" -libnagiosplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c +libmonitoringplug_a_SOURCES = utils_base.c utils_disk.c utils_tcp.c utils_cmd.c EXTRA_DIST = utils_base.h utils_disk.h utils_tcp.h utils_cmd.h parse_ini.h extra_opts.h if USE_PARSE_INI -libnagiosplug_a_SOURCES += parse_ini.c extra_opts.c +libmonitoringplug_a_SOURCES += parse_ini.c extra_opts.c endif USE_PARSE_INI INCLUDES = -I$(srcdir) -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins diff --git a/lib/extra_opts.c b/lib/extra_opts.c index 2939c7a1..70e7dd27 100644 --- a/lib/extra_opts.c +++ b/lib/extra_opts.c @@ -1,9 +1,9 @@ /***************************************************************************** * -* Nagios-plugins extra_opts library +* Monitoring-plugins extra_opts library * * License: GPL -* Copyright (c) 2007 Nagios Plugins Development Team +* Copyright (c) 2007 Monitoring Plugins Development Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/extra_opts.h b/lib/extra_opts.h index 4bb7b73b..8ff14a16 100644 --- a/lib/extra_opts.h +++ b/lib/extra_opts.h @@ -2,7 +2,7 @@ #define _EXTRA_OPTS_H_ /* - * extra_opts.h: routines for loading nagios-plugin defaults from ini + * extra_opts.h: routines for loading monitoring-plugin defaults from ini * configuration files. */ diff --git a/lib/parse_ini.c b/lib/parse_ini.c index 004396fe..dfa72d9c 100644 --- a/lib/parse_ini.c +++ b/lib/parse_ini.c @@ -1,9 +1,9 @@ /***************************************************************************** * -* Nagios-plugins parse_ini library +* Monitoring-plugins parse_ini library * * License: GPL -* Copyright (c) 2007 Nagios Plugins Development Team +* Copyright (c) 2007 Monitoring Plugins Development Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lib/parse_ini.h b/lib/parse_ini.h index e0ba8164..a3a494ef 100644 --- a/lib/parse_ini.h +++ b/lib/parse_ini.h @@ -2,7 +2,7 @@ #define _PARSE_INI_H_ /* - * parse_ini.h: routines for loading nagios-plugin defaults from ini + * parse_ini.h: routines for loading monitoring-plugin defaults from ini * configuration files. */ diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am index 1af5891a..c0411ac5 100644 --- a/lib/tests/Makefile.am +++ b/lib/tests/Makefile.am @@ -28,7 +28,7 @@ endif AM_CFLAGS = -g -I$(top_srcdir)/lib -I$(top_srcdir)/gl $(tap_cflags) AM_LDFLAGS = $(tap_ldflags) -ltap -LDADD = $(top_srcdir)/lib/libnagiosplug.a $(top_srcdir)/gl/libgnu.a +LDADD = $(top_srcdir)/lib/libmonitoringplug.a $(top_srcdir)/gl/libgnu.a SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini1.c test_ini3.c test_opts1.c test_opts2.c test_opts3.c diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c index 79e1110a..7a1a1fa1 100644 --- a/lib/tests/test_utils.c +++ b/lib/tests/test_utils.c @@ -40,20 +40,20 @@ main (int argc, char **argv) plan_tests(150); - ok( this_nagios_plugin==NULL, "nagios_plugin not initialised"); + ok( this_monitoring_plugin==NULL, "monitoring_plugin not initialised"); np_init( "check_test", argc, argv ); - ok( this_nagios_plugin!=NULL, "nagios_plugin now initialised"); - ok( !strcmp(this_nagios_plugin->plugin_name, "check_test"), "plugin name initialised" ); + ok( this_monitoring_plugin!=NULL, "monitoring_plugin now initialised"); + ok( !strcmp(this_monitoring_plugin->plugin_name, "check_test"), "plugin name initialised" ); - ok( this_nagios_plugin->argc==argc, "Argc set" ); - ok( this_nagios_plugin->argv==argv, "Argv set" ); + ok( this_monitoring_plugin->argc==argc, "Argc set" ); + ok( this_monitoring_plugin->argv==argv, "Argv set" ); np_set_args(0,0); - ok( this_nagios_plugin->argc==0, "argc changed" ); - ok( this_nagios_plugin->argv==0, "argv changed" ); + ok( this_monitoring_plugin->argc==0, "argc changed" ); + ok( this_monitoring_plugin->argv==0, "argv changed" ); np_set_args(argc, argv); @@ -296,11 +296,11 @@ main (int argc, char **argv) diag( "You are probably running in wrong directory. Must run as ./test_utils" ); - this_nagios_plugin->argc=4; - this_nagios_plugin->argv[0] = "./test_utils"; - this_nagios_plugin->argv[1] = "here"; - this_nagios_plugin->argv[2] = "--and"; - this_nagios_plugin->argv[3] = "now"; + this_monitoring_plugin->argc=4; + this_monitoring_plugin->argv[0] = "./test_utils"; + this_monitoring_plugin->argv[1] = "here"; + this_monitoring_plugin->argv[2] = "--and"; + this_monitoring_plugin->argv[3] = "now"; temp_string = (char *) _np_state_generate_key(); ok(!strcmp(temp_string, "94b5e17bf5abf51cb15aff5f69b96f2f8dac5ecd"), "Got based on expected argv" ); @@ -320,16 +320,16 @@ main (int argc, char **argv) ok(temp_state_key==NULL, "temp_state_key initially empty"); - this_nagios_plugin->argc=1; - this_nagios_plugin->argv[0] = "./test_utils"; + this_monitoring_plugin->argc=1; + this_monitoring_plugin->argv[0] = "./test_utils"; np_enable_state(NULL, 51); - temp_state_key = this_nagios_plugin->state; + temp_state_key = this_monitoring_plugin->state; ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); ok( !strcmp(temp_state_key->name, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got generated filename" ); np_enable_state("allowedchars_in_keyname", 77); - temp_state_key = this_nagios_plugin->state; + temp_state_key = this_monitoring_plugin->state; ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); ok( !strcmp(temp_state_key->name, "allowedchars_in_keyname"), "Got key name with valid chars" ); ok( !strcmp(temp_state_key->_filename, "/usr/local/nagios/var/check_test/allowedchars_in_keyname"), "Got internal filename" ); @@ -338,12 +338,12 @@ main (int argc, char **argv) /* Don't do this test just yet. Will die */ /* np_enable_state("bad^chars$in@here", 77); - temp_state_key = this_nagios_plugin->state; + temp_state_key = this_monitoring_plugin->state; ok( !strcmp(temp_state_key->name, "bad_chars_in_here"), "Got key name with bad chars replaced" ); */ np_enable_state("funnykeyname", 54); - temp_state_key = this_nagios_plugin->state; + temp_state_key = this_monitoring_plugin->state; ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); ok( !strcmp(temp_state_key->name, "funnykeyname"), "Got key name" ); @@ -367,9 +367,9 @@ main (int argc, char **argv) temp_state_key->_filename="var/statefile"; temp_state_data = np_state_read(); - ok( this_nagios_plugin->state->state_data!=NULL, "Got state data now" ) || diag("Are you running in right directory? Will get coredump next if not"); - ok( this_nagios_plugin->state->state_data->time==1234567890, "Got time" ); - ok( !strcmp((char *)this_nagios_plugin->state->state_data->data, "String to read"), "Data as expected" ); + ok( this_monitoring_plugin->state->state_data!=NULL, "Got state data now" ) || diag("Are you running in right directory? Will get coredump next if not"); + ok( this_monitoring_plugin->state->state_data->time==1234567890, "Got time" ); + ok( !strcmp((char *)this_monitoring_plugin->state->state_data->data, "String to read"), "Data as expected" ); temp_state_key->data_version=53; temp_state_data = np_state_read(); @@ -379,7 +379,7 @@ main (int argc, char **argv) temp_state_key->_filename="var/nonexistant"; temp_state_data = np_state_read(); ok( temp_state_data==NULL, "Missing file gives NULL" ); - ok( this_nagios_plugin->state->state_data==NULL, "No state information" ); + ok( this_monitoring_plugin->state->state_data==NULL, "No state information" ); temp_state_key->_filename="var/oldformat"; temp_state_data = np_state_read(); @@ -426,7 +426,7 @@ main (int argc, char **argv) temp_state_data = np_state_read(); /* Check time is set to current_time */ ok(system("cmp var/generated var/statefile > /dev/null")!=0, "Generated file should be different this time"); - ok(this_nagios_plugin->state->state_data->time-current_time<=1, "Has time generated from current time"); + ok(this_monitoring_plugin->state->state_data->time-current_time<=1, "Has time generated from current time"); /* Don't know how to automatically test this. Need to be able to redefine die and catch the error */ @@ -438,7 +438,7 @@ main (int argc, char **argv) np_cleanup(); - ok( this_nagios_plugin==NULL, "Free'd this_nagios_plugin" ); + ok( this_monitoring_plugin==NULL, "Free'd this_monitoring_plugin" ); return exit_status(); } diff --git a/lib/utils_base.c b/lib/utils_base.c index 54463e92..57d01e27 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c @@ -3,7 +3,7 @@ * utils_base.c * * License: GPL -* Copyright (c) 2006 Nagios Plugins Development Team +* Copyright (c) 2006 Monitoring Plugins Development Team * * Library of useful functions for plugins * @@ -33,53 +33,53 @@ #define np_free(ptr) { if(ptr) { free(ptr); ptr = NULL; } } -nagios_plugin *this_nagios_plugin=NULL; +monitoring_plugin *this_monitoring_plugin=NULL; int _np_state_read_file(FILE *); void np_init( char *plugin_name, int argc, char **argv ) { - if (this_nagios_plugin==NULL) { - this_nagios_plugin = calloc(1, sizeof(nagios_plugin)); - if (this_nagios_plugin==NULL) { + if (this_monitoring_plugin==NULL) { + this_monitoring_plugin = calloc(1, sizeof(monitoring_plugin)); + if (this_monitoring_plugin==NULL) { die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), strerror(errno)); } - this_nagios_plugin->plugin_name = strdup(plugin_name); - if (this_nagios_plugin->plugin_name==NULL) + this_monitoring_plugin->plugin_name = strdup(plugin_name); + if (this_monitoring_plugin->plugin_name==NULL) die(STATE_UNKNOWN, _("Cannot execute strdup: %s"), strerror(errno)); - this_nagios_plugin->argc = argc; - this_nagios_plugin->argv = argv; + this_monitoring_plugin->argc = argc; + this_monitoring_plugin->argv = argv; } } void np_set_args( int argc, char **argv ) { - if (this_nagios_plugin==NULL) + if (this_monitoring_plugin==NULL) die(STATE_UNKNOWN, _("This requires np_init to be called")); - this_nagios_plugin->argc = argc; - this_nagios_plugin->argv = argv; + this_monitoring_plugin->argc = argc; + this_monitoring_plugin->argv = argv; } void np_cleanup() { - if (this_nagios_plugin!=NULL) { - if(this_nagios_plugin->state!=NULL) { - if(this_nagios_plugin->state->state_data) { - np_free(this_nagios_plugin->state->state_data->data); - np_free(this_nagios_plugin->state->state_data); + if (this_monitoring_plugin!=NULL) { + if(this_monitoring_plugin->state!=NULL) { + if(this_monitoring_plugin->state->state_data) { + np_free(this_monitoring_plugin->state->state_data->data); + np_free(this_monitoring_plugin->state->state_data); } - np_free(this_nagios_plugin->state->name); - np_free(this_nagios_plugin->state); + np_free(this_monitoring_plugin->state->name); + np_free(this_monitoring_plugin->state); } - np_free(this_nagios_plugin->plugin_name); - np_free(this_nagios_plugin); + np_free(this_monitoring_plugin->plugin_name); + np_free(this_monitoring_plugin); } - this_nagios_plugin=NULL; + this_monitoring_plugin=NULL; } -/* Hidden function to get a pointer to this_nagios_plugin for testing */ -void _get_nagios_plugin( nagios_plugin **pointer ){ - *pointer = this_nagios_plugin; +/* Hidden function to get a pointer to this_monitoring_plugin for testing */ +void _get_monitoring_plugin( monitoring_plugin **pointer ){ + *pointer = this_monitoring_plugin; } void @@ -89,7 +89,7 @@ die (int result, const char *fmt, ...) va_start (ap, fmt); vprintf (fmt, ap); va_end (ap); - if(this_nagios_plugin!=NULL) { + if(this_monitoring_plugin!=NULL) { np_cleanup(); } exit (result); @@ -375,14 +375,14 @@ char *np_extract_value(const char *varlist, const char *name, char sep) { char *_np_state_generate_key() { struct sha1_ctx ctx; int i; - char **argv = this_nagios_plugin->argv; + char **argv = this_monitoring_plugin->argv; unsigned char result[20]; char keyname[41]; char *p=NULL; sha1_init_ctx(&ctx); - for(i=0; iargc; i++) { + for(i=0; iargc; i++) { sha1_process_bytes(argv[i], strlen(argv[i]), &ctx); } @@ -401,9 +401,9 @@ char *_np_state_generate_key() { } void _cleanup_state_data() { - if (this_nagios_plugin->state->state_data!=NULL) { - np_free(this_nagios_plugin->state->state_data->data); - np_free(this_nagios_plugin->state->state_data); + if (this_monitoring_plugin->state->state_data!=NULL) { + np_free(this_monitoring_plugin->state->state_data->data); + np_free(this_monitoring_plugin->state->state_data); } } @@ -432,7 +432,7 @@ void np_enable_state(char *keyname, int expected_data_version) { char *temp_keyname = NULL; char *p=NULL; - if(this_nagios_plugin==NULL) + if(this_monitoring_plugin==NULL) die(STATE_UNKNOWN, _("This requires np_init to be called")); this_state = (state_key *) calloc(1, sizeof(state_key)); @@ -456,15 +456,15 @@ void np_enable_state(char *keyname, int expected_data_version) { p++; } this_state->name=temp_keyname; - this_state->plugin_name=this_nagios_plugin->plugin_name; + this_state->plugin_name=this_monitoring_plugin->plugin_name; this_state->data_version=expected_data_version; this_state->state_data=NULL; /* Calculate filename */ - asprintf(&temp_filename, "%s/%s/%s", _np_state_calculate_location_prefix(), this_nagios_plugin->plugin_name, this_state->name); + asprintf(&temp_filename, "%s/%s/%s", _np_state_calculate_location_prefix(), this_monitoring_plugin->plugin_name, this_state->name); this_state->_filename=temp_filename; - this_nagios_plugin->state = this_state; + this_monitoring_plugin->state = this_state; } /* @@ -479,11 +479,11 @@ state_data *np_state_read() { FILE *statefile; int rc = FALSE; - if(this_nagios_plugin==NULL) + if(this_monitoring_plugin==NULL) die(STATE_UNKNOWN, _("This requires np_init to be called")); /* Open file. If this fails, no previous state found */ - statefile = fopen( this_nagios_plugin->state->_filename, "r" ); + statefile = fopen( this_monitoring_plugin->state->_filename, "r" ); if(statefile!=NULL) { this_state_data = (state_data *) calloc(1, sizeof(state_data)); @@ -492,7 +492,7 @@ state_data *np_state_read() { strerror(errno)); this_state_data->data=NULL; - this_nagios_plugin->state->state_data = this_state_data; + this_monitoring_plugin->state->state_data = this_state_data; rc = _np_state_read_file(statefile); @@ -503,10 +503,10 @@ state_data *np_state_read() { _cleanup_state_data(); } - return this_nagios_plugin->state->state_data; + return this_monitoring_plugin->state->state_data; } -/* +/* * Read the state file */ int _np_state_read_file(FILE *f) { @@ -544,7 +544,7 @@ int _np_state_read_file(FILE *f) { break; case STATE_DATA_VERSION: i=atoi(line); - if(i != this_nagios_plugin->state->data_version) + if(i != this_monitoring_plugin->state->data_version) failure++; else expected=STATE_DATA_TIME; @@ -555,13 +555,13 @@ int _np_state_read_file(FILE *f) { if(data_time > current_time) failure++; else { - this_nagios_plugin->state->state_data->time = data_time; + this_monitoring_plugin->state->state_data->time = data_time; expected=STATE_DATA_TEXT; } break; case STATE_DATA_TEXT: - this_nagios_plugin->state->state_data->data = strdup(line); - if(this_nagios_plugin->state->state_data->data==NULL) + this_monitoring_plugin->state->state_data->data = strdup(line); + if(this_monitoring_plugin->state->state_data->data==NULL) die(STATE_UNKNOWN, _("Cannot execute strdup: %s"), strerror(errno)); expected=STATE_DATA_END; status=TRUE; @@ -596,8 +596,8 @@ void np_state_write_string(time_t data_time, char *data_string) { current_time=data_time; /* If file doesn't currently exist, create directories */ - if(access(this_nagios_plugin->state->_filename,F_OK)!=0) { - asprintf(&directories, "%s", this_nagios_plugin->state->_filename); + if(access(this_monitoring_plugin->state->_filename,F_OK)!=0) { + asprintf(&directories, "%s", this_monitoring_plugin->state->_filename); if(directories==NULL) die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), strerror(errno)); @@ -607,7 +607,7 @@ void np_state_write_string(time_t data_time, char *data_string) { *p='\0'; if((access(directories,F_OK)!=0) && (mkdir(directories, S_IRWXU)!=0)) { /* Can't free this! Otherwise error message is wrong! */ - /* np_free(directories); */ + /* np_free(directories); */ die(STATE_UNKNOWN, _("Cannot create directory: %s"), directories); } *p='/'; @@ -616,7 +616,7 @@ void np_state_write_string(time_t data_time, char *data_string) { np_free(directories); } - asprintf(&temp_file,"%s.XXXXXX",this_nagios_plugin->state->_filename); + asprintf(&temp_file,"%s.XXXXXX",this_monitoring_plugin->state->_filename); if(temp_file==NULL) die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), strerror(errno)); @@ -636,7 +636,7 @@ void np_state_write_string(time_t data_time, char *data_string) { fprintf(fp,"# NP State file\n"); fprintf(fp,"%d\n",NP_STATE_FORMAT_VERSION); - fprintf(fp,"%d\n",this_nagios_plugin->state->data_version); + fprintf(fp,"%d\n",this_monitoring_plugin->state->data_version); fprintf(fp,"%lu\n",current_time); fprintf(fp,"%s\n",data_string); @@ -654,7 +654,7 @@ void np_state_write_string(time_t data_time, char *data_string) { die(STATE_UNKNOWN, _("Error writing temp file")); } - if(rename(temp_file, this_nagios_plugin->state->_filename)!=0) { + if(rename(temp_file, this_monitoring_plugin->state->_filename)!=0) { unlink(temp_file); np_free(temp_file); die(STATE_UNKNOWN, _("Cannot rename state temp file")); diff --git a/lib/utils_base.h b/lib/utils_base.h index 0cb371fd..3b00da57 100644 --- a/lib/utils_base.h +++ b/lib/utils_base.h @@ -1,6 +1,6 @@ #ifndef _UTILS_BASE_ #define _UTILS_BASE_ -/* Header file for nagios plugins utils_base.c */ +/* Header file for monitoring plugins utils_base.c */ #include "sha1.h" @@ -52,7 +52,7 @@ typedef struct np_struct { state_key *state; int argc; char **argv; - } nagios_plugin; + } monitoring_plugin; range *parse_range_string (char *); int _set_thresholds(thresholds **, char *, char *); diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c index 0c853dcc..4c6d0be1 100644 --- a/lib/utils_cmd.c +++ b/lib/utils_cmd.c @@ -1,9 +1,9 @@ /***************************************************************************** * -* Nagios run command utilities +* Monitoring run command utilities * * License: GPL -* Copyright (c) 2005-2006 Nagios Plugins Development Team +* Copyright (c) 2005-2006 Monitoring Plugins Development Team * * Description : * diff --git a/lib/utils_cmd.h b/lib/utils_cmd.h index 8ebb5894..36a6ff02 100644 --- a/lib/utils_cmd.h +++ b/lib/utils_cmd.h @@ -2,7 +2,7 @@ #define _UTILS_CMD_ /* - * Header file for nagios plugins utils_cmd.c + * Header file for monitoring plugins utils_cmd.c * * */ diff --git a/lib/utils_disk.c b/lib/utils_disk.c index 5be2b2c0..efe35fc5 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c @@ -3,7 +3,7 @@ * Library for check_disk * * License: GPL -* Copyright (c) 1999-2007 Nagios Plugins Development Team +* Copyright (c) 1999-2007 Monitoring Plugins Development Team * * Description: * diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c index 46ad7f72..b37c446f 100644 --- a/lib/utils_tcp.c +++ b/lib/utils_tcp.c @@ -3,7 +3,7 @@ * Library for check_tcp * * License: GPL -* Copyright (c) 1999-2013 Nagios Plugins Development Team +* Copyright (c) 1999-2013 Monitoring Plugins Development Team * * Description: * -- cgit v1.2.3