summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--ChangeLog4
-rw-r--r--NEWS3
-rw-r--r--THANKS.in1
-rw-r--r--doc/developer-guidelines.sgml8
-rw-r--r--doc/makefile2
-rw-r--r--lib/utils_base.c16
-rw-r--r--plugins-scripts/utils.sh.in11
-rw-r--r--plugins/check_dig.c19
-rw-r--r--plugins/check_ldap.c5
-rw-r--r--plugins/check_ntp.c9
-rw-r--r--plugins/check_ntp_peer.c3
-rw-r--r--plugins/check_ntp_time.c9
-rw-r--r--plugins/check_pgsql.c2
-rw-r--r--plugins/check_procs.c113
-rw-r--r--plugins/check_snmp.c49
-rw-r--r--plugins/check_ssh.c2
-rw-r--r--plugins/common.h1
-rw-r--r--plugins/t/check_dig.t22
-rwxr-xr-xtools/np_build_from_sf11
-rwxr-xr-xtools/sfwebcron34
-rwxr-xr-xtools/snapshot69
-rwxr-xr-xtools/update_man_pages34
23 files changed, 205 insertions, 224 deletions
diff --git a/.gitignore b/.gitignore
index 52ca6aa..bda7b27 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,8 @@ NP-VERSION-FILE
37 37
38# /doc/ 38# /doc/
39/doc/developer-guidelines.html 39/doc/developer-guidelines.html
40/doc/developer-guidelines.html.last
41/doc/jade-out.fot
40 42
41# /tap/ 43# /tap/
42/tap/.deps 44/tap/.deps
diff --git a/ChangeLog b/ChangeLog
index 050d42b..acc3575 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
12013-01-23 Robin Sonefors <robin.sonefors@op5.com>
2
3 * plugins/check_snmp.c: fix memory allocation if using >= 8 oids
4
12012-06-27 Holger Weiss <holger@zedat.fu-berlin.de> 52012-06-27 Holger Weiss <holger@zedat.fu-berlin.de>
2 6
3 * plugins/check_tcp.c: check_tcp: Print performance data even with 7 * plugins/check_tcp.c: check_tcp: Print performance data even with
diff --git a/NEWS b/NEWS
index f2ca7e5..293bd9d 100644
--- a/NEWS
+++ b/NEWS
@@ -3,10 +3,13 @@ This file documents the major additions and syntax changes between releases.
3... 3...
4 ENHANCEMENTS 4 ENHANCEMENTS
5 New check_dbi plugin for checking an (SQL) database using DBI 5 New check_dbi plugin for checking an (SQL) database using DBI
6 Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page)
7 Add performance data to check_procs
6 8
7 FIXES 9 FIXES
8 Change the MAIL FROM command generated by check_smtp to be RFC compliant 10 Change the MAIL FROM command generated by check_smtp to be RFC compliant
9 Fix compilation of check_http without SSL support 11 Fix compilation of check_http without SSL support
12 Fix check_snmp reversed threshold ranges (backward-compatibility)
10 13
111.4.16 27th June 2012 141.4.16 27th June 2012
12 ENHANCEMENTS 15 ENHANCEMENTS
diff --git a/THANKS.in b/THANKS.in
index 5193511..60f02cd 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -275,3 +275,4 @@ Tobias Brox
275William Leibzon 275William Leibzon
276Jochen Bern 276Jochen Bern
277Anders Kaseorg 277Anders Kaseorg
278Robin Sonefors
diff --git a/doc/developer-guidelines.sgml b/doc/developer-guidelines.sgml
index 1ce78ff..e7754f4 100644
--- a/doc/developer-guidelines.sgml
+++ b/doc/developer-guidelines.sgml
@@ -303,15 +303,15 @@
303 </row> 303 </row>
304 <row> 304 <row>
305 <entry>check_stuff -w~:0 -c10</entry> 305 <entry>check_stuff -w~:0 -c10</entry>
306 <entry>Critical if "stuff" is above 10; Warn if "stuff" is above zero</entry> 306 <entry>Critical if "stuff" is above 10; Warn if "stuff" is above zero (will be critical if "stuff" is less than 0)</entry>
307 </row> 307 </row>
308 <row> 308 <row>
309 <entry>check_stuff -c5:6</entry> 309 <entry>check_stuff -c5:6</entry>
310 <entry>The only noncritical range is 5:6</entry> 310 <entry>Critical if "stuff" is less than 5 or more than 6</entry>
311 </row> 311 </row>
312 <row> 312 <row>
313 <entry>check_stuff -c10:20</entry> 313 <entry>check_stuff -c@10:20</entry>
314 <entry>Critical if "stuff" is less than 10 or over 20</entry> 314 <entry>OK if stuff is less than 10 or higher than 20, otherwise critical </entry>
315 </row> 315 </row>
316 </tbody> 316 </tbody>
317 </tgroup> 317 </tgroup>
diff --git a/doc/makefile b/doc/makefile
index b1b56c1..89caf9e 100644
--- a/doc/makefile
+++ b/doc/makefile
@@ -8,4 +8,4 @@ developer-guidelines.html: developer-guidelines.sgml
8 fi 8 fi
9 9
10clean: 10clean:
11 rm -f developer-guidelines.html 11 rm -f developer-guidelines.html developer-guidelines.html.last jade-out.fot
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 1f705d9..c93e9c3 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -35,7 +35,7 @@ nagios_plugin *this_nagios_plugin=NULL;
35 35
36void np_init( char *plugin_name, int argc, char **argv ) { 36void np_init( char *plugin_name, int argc, char **argv ) {
37 if (this_nagios_plugin==NULL) { 37 if (this_nagios_plugin==NULL) {
38 this_nagios_plugin = malloc(sizeof(nagios_plugin)); 38 this_nagios_plugin = calloc(1, sizeof(nagios_plugin));
39 if (this_nagios_plugin==NULL) { 39 if (this_nagios_plugin==NULL) {
40 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 40 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
41 strerror(errno)); 41 strerror(errno));
@@ -108,7 +108,7 @@ range
108 double end; 108 double end;
109 char *end_str; 109 char *end_str;
110 110
111 temp_range = (range *) malloc(sizeof(range)); 111 temp_range = (range *) calloc(1, sizeof(range));
112 112
113 /* Set defaults */ 113 /* Set defaults */
114 temp_range->start = 0; 114 temp_range->start = 0;
@@ -154,7 +154,7 @@ _set_thresholds(thresholds **my_thresholds, char *warn_string, char *critical_st
154{ 154{
155 thresholds *temp_thresholds = NULL; 155 thresholds *temp_thresholds = NULL;
156 156
157 if ((temp_thresholds = malloc(sizeof(thresholds))) == NULL) 157 if ((temp_thresholds = calloc(1, sizeof(thresholds))) == NULL)
158 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 158 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
159 strerror(errno)); 159 strerror(errno));
160 160
@@ -335,13 +335,13 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
335 if (tmp = index(varlist, sep)) { 335 if (tmp = index(varlist, sep)) {
336 /* Value is delimited by a comma */ 336 /* Value is delimited by a comma */
337 if (tmp-varlist == 0) continue; 337 if (tmp-varlist == 0) continue;
338 value = (char *)malloc(tmp-varlist+1); 338 value = (char *)calloc(1, tmp-varlist+1);
339 strncpy(value, varlist, tmp-varlist); 339 strncpy(value, varlist, tmp-varlist);
340 value[tmp-varlist] = '\0'; 340 value[tmp-varlist] = '\0';
341 } else { 341 } else {
342 /* Value is delimited by a \0 */ 342 /* Value is delimited by a \0 */
343 if (strlen(varlist) == 0) continue; 343 if (strlen(varlist) == 0) continue;
344 value = (char *)malloc(strlen(varlist) + 1); 344 value = (char *)calloc(1, strlen(varlist) + 1);
345 strncpy(value, varlist, strlen(varlist)); 345 strncpy(value, varlist, strlen(varlist));
346 value[strlen(varlist)] = '\0'; 346 value[strlen(varlist)] = '\0';
347 } 347 }
@@ -431,7 +431,7 @@ void np_enable_state(char *keyname, int expected_data_version) {
431 if(this_nagios_plugin==NULL) 431 if(this_nagios_plugin==NULL)
432 die(STATE_UNKNOWN, _("This requires np_init to be called")); 432 die(STATE_UNKNOWN, _("This requires np_init to be called"));
433 433
434 this_state = (state_key *) malloc(sizeof(state_key)); 434 this_state = (state_key *) calloc(1, sizeof(state_key));
435 if(this_state==NULL) 435 if(this_state==NULL)
436 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 436 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
437 strerror(errno)); 437 strerror(errno));
@@ -482,7 +482,7 @@ state_data *np_state_read() {
482 statefile = fopen( this_nagios_plugin->state->_filename, "r" ); 482 statefile = fopen( this_nagios_plugin->state->_filename, "r" );
483 if(statefile!=NULL) { 483 if(statefile!=NULL) {
484 484
485 this_state_data = (state_data *) malloc(sizeof(state_data)); 485 this_state_data = (state_data *) calloc(1, sizeof(state_data));
486 if(this_state_data==NULL) 486 if(this_state_data==NULL)
487 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 487 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
488 strerror(errno)); 488 strerror(errno));
@@ -517,7 +517,7 @@ int _np_state_read_file(FILE *f) {
517 time(&current_time); 517 time(&current_time);
518 518
519 /* Note: This introduces a limit of 1024 bytes in the string data */ 519 /* Note: This introduces a limit of 1024 bytes in the string data */
520 line = (char *) malloc(1024); 520 line = (char *) calloc(1, 1024);
521 if(line==NULL) 521 if(line==NULL)
522 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"), 522 die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
523 strerror(errno)); 523 strerror(errno));
diff --git a/plugins-scripts/utils.sh.in b/plugins-scripts/utils.sh.in
index 5fae6ad..4a07df8 100644
--- a/plugins-scripts/utils.sh.in
+++ b/plugins-scripts/utils.sh.in
@@ -23,7 +23,16 @@ support() {
23 23
24# 24#
25# check_range takes a value and a range string, returning successfully if an 25# check_range takes a value and a range string, returning successfully if an
26# alert should be raised based on the range. 26# alert should be raised based on the range. Range values are inclusive.
27# Values may be integers or floats.
28#
29# Example usage:
30#
31# Generating an exit code of 1:
32# check_range 5 2:8
33#
34# Generating an exit code of 0:
35# check_range 1 2:8
27# 36#
28check_range() { 37check_range() {
29 local v range yes no err decimal start end cmp match 38 local v range yes no err decimal start end cmp match
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 893e0a1..3c80cb7 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -54,6 +54,7 @@ char *record_type = "A";
54char *expected_address = NULL; 54char *expected_address = NULL;
55char *dns_server = NULL; 55char *dns_server = NULL;
56char *dig_args = ""; 56char *dig_args = "";
57char *query_transport = "";
57int verbose = FALSE; 58int verbose = FALSE;
58int server_port = DEFAULT_PORT; 59int server_port = DEFAULT_PORT;
59double warning_interval = UNDEFINED; 60double warning_interval = UNDEFINED;
@@ -87,8 +88,8 @@ main (int argc, char **argv)
87 usage_va(_("Could not parse arguments")); 88 usage_va(_("Could not parse arguments"));
88 89
89 /* get the command to run */ 90 /* get the command to run */
90 xasprintf (&command_line, "%s @%s -p %d %s -t %s %s", 91 xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s",
91 PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args); 92 PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport);
92 93
93 alarm (timeout_interval); 94 alarm (timeout_interval);
94 gettimeofday (&tv, NULL); 95 gettimeofday (&tv, NULL);
@@ -199,6 +200,8 @@ process_arguments (int argc, char **argv)
199 {"record_type", required_argument, 0, 'T'}, 200 {"record_type", required_argument, 0, 'T'},
200 {"expected_address", required_argument, 0, 'a'}, 201 {"expected_address", required_argument, 0, 'a'},
201 {"port", required_argument, 0, 'p'}, 202 {"port", required_argument, 0, 'p'},
203 {"use-ipv4", no_argument, 0, '4'},
204 {"use-ipv6", no_argument, 0, '6'},
202 {0, 0, 0, 0} 205 {0, 0, 0, 0}
203 }; 206 };
204 207
@@ -206,7 +209,7 @@ process_arguments (int argc, char **argv)
206 return ERROR; 209 return ERROR;
207 210
208 while (1) { 211 while (1) {
209 c = getopt_long (argc, argv, "hVvt:l:H:w:c:T:p:a:A:", longopts, &option); 212 c = getopt_long (argc, argv, "hVvt:l:H:w:c:T:p:a:A:46", longopts, &option);
210 213
211 if (c == -1 || c == EOF) 214 if (c == -1 || c == EOF)
212 break; 215 break;
@@ -269,6 +272,12 @@ process_arguments (int argc, char **argv)
269 case 'a': 272 case 'a':
270 expected_address = optarg; 273 expected_address = optarg;
271 break; 274 break;
275 case '4':
276 query_transport = "-4";
277 break;
278 case '6':
279 query_transport = "-6";
280 break;
272 default: /* usage5 */ 281 default: /* usage5 */
273 usage5(); 282 usage5();
274 } 283 }
@@ -325,6 +334,10 @@ print_help (void)
325 334
326 printf (UT_HOST_PORT, 'p', myport); 335 printf (UT_HOST_PORT, 'p', myport);
327 336
337 printf (" %s\n","-4, --use-ipv4");
338 printf (" %s\n",_("Force dig to only use IPv4 query transport"));
339 printf (" %s\n","-6, --use-ipv6");
340 printf (" %s\n",_("Force dig to only use IPv6 query transport"));
328 printf (" %s\n","-l, --query_address=STRING"); 341 printf (" %s\n","-l, --query_address=STRING");
329 printf (" %s\n",_("Machine name to lookup")); 342 printf (" %s\n",_("Machine name to lookup"));
330 printf (" %s\n","-T, --record_type=STRING"); 343 printf (" %s\n","-T, --record_type=STRING");
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index 65db851..b05aca9 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -445,11 +445,6 @@ print_help (void)
445 printf (UT_SUPPORT); 445 printf (UT_SUPPORT);
446} 446}
447 447
448/* todo
449* add option -4 and -6 to the long manual
450*
451*/
452
453void 448void
454print_usage (void) 449print_usage (void)
455{ 450{
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 76d19ba..16be7c5 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -398,7 +398,11 @@ double offset_request(const char *host, int *status){
398 die(STATE_UNKNOWN, "can not create new socket"); 398 die(STATE_UNKNOWN, "can not create new socket");
399 } 399 }
400 if(connect(socklist[i], ai_tmp->ai_addr, ai_tmp->ai_addrlen)){ 400 if(connect(socklist[i], ai_tmp->ai_addr, ai_tmp->ai_addrlen)){
401 die(STATE_UNKNOWN, "can't create socket connection"); 401 /* don't die here, because it is enough if there is one server
402 answering in time. This also would break for dual ipv4/6 stacked
403 ntp servers when the client only supports on of them.
404 */
405 DBG(printf("can't create socket connection on peer %i: %s\n", i, strerror(errno)));
402 } else { 406 } else {
403 ufds[i].fd=socklist[i]; 407 ufds[i].fd=socklist[i];
404 ufds[i].events=POLLIN; 408 ufds[i].events=POLLIN;
@@ -845,6 +849,7 @@ void print_help(void){
845 printf (UT_HELP_VRSN); 849 printf (UT_HELP_VRSN);
846 printf (UT_EXTRA_OPTS); 850 printf (UT_EXTRA_OPTS);
847 printf (UT_HOST_PORT, 'p', "123"); 851 printf (UT_HOST_PORT, 'p', "123");
852 printf (UT_IPv46);
848 printf (" %s\n", "-w, --warning=THRESHOLD"); 853 printf (" %s\n", "-w, --warning=THRESHOLD");
849 printf (" %s\n", _("Offset to result in warning status (seconds)")); 854 printf (" %s\n", _("Offset to result in warning status (seconds)"));
850 printf (" %s\n", "-c, --critical=THRESHOLD"); 855 printf (" %s\n", "-c, --critical=THRESHOLD");
@@ -881,5 +886,5 @@ print_usage(void)
881 printf ("%s\n", _("WARNING: check_ntp is deprecated. Please use check_ntp_peer or")); 886 printf ("%s\n", _("WARNING: check_ntp is deprecated. Please use check_ntp_peer or"));
882 printf ("%s\n\n", _("check_ntp_time instead.")); 887 printf ("%s\n\n", _("check_ntp_time instead."));
883 printf ("%s\n", _("Usage:")); 888 printf ("%s\n", _("Usage:"));
884 printf(" %s -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n", progname); 889 printf(" %s -H <host> [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-4|-6] [-v verbose]\n", progname);
885} 890}
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index 50cb7b1..b59c056 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -660,6 +660,7 @@ void print_help(void){
660 print_usage(); 660 print_usage();
661 printf (UT_HELP_VRSN); 661 printf (UT_HELP_VRSN);
662 printf (UT_EXTRA_OPTS); 662 printf (UT_EXTRA_OPTS);
663 printf (UT_IPv46);
663 printf (UT_HOST_PORT, 'p', "123"); 664 printf (UT_HOST_PORT, 'p', "123");
664 printf (" %s\n", "-q, --quiet"); 665 printf (" %s\n", "-q, --quiet");
665 printf (" %s\n", _("Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized")); 666 printf (" %s\n", _("Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized"));
@@ -716,6 +717,6 @@ void
716print_usage(void) 717print_usage(void)
717{ 718{
718 printf ("%s\n", _("Usage:")); 719 printf ("%s\n", _("Usage:"));
719 printf(" %s -H <host> [-w <warn>] [-c <crit>] [-W <warn>] [-C <crit>]\n", progname); 720 printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-W <warn>] [-C <crit>]\n", progname);
720 printf(" [-j <warn>] [-k <crit>] [-v verbose]\n"); 721 printf(" [-j <warn>] [-k <crit>] [-v verbose]\n");
721} 722}
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index d543d6b..bbcaa0b 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -344,7 +344,11 @@ double offset_request(const char *host, int *status){
344 die(STATE_UNKNOWN, "can not create new socket"); 344 die(STATE_UNKNOWN, "can not create new socket");
345 } 345 }
346 if(connect(socklist[i], ai_tmp->ai_addr, ai_tmp->ai_addrlen)){ 346 if(connect(socklist[i], ai_tmp->ai_addr, ai_tmp->ai_addrlen)){
347 die(STATE_UNKNOWN, "can't create socket connection"); 347 /* don't die here, because it is enough if there is one server
348 answering in time. This also would break for dual ipv4/6 stacked
349 ntp servers when the client only supports on of them.
350 */
351 DBG(printf("can't create socket connection on peer %i: %s\n", i, strerror(errno)));
348 } else { 352 } else {
349 ufds[i].fd=socklist[i]; 353 ufds[i].fd=socklist[i];
350 ufds[i].events=POLLIN; 354 ufds[i].events=POLLIN;
@@ -602,6 +606,7 @@ void print_help(void){
602 print_usage(); 606 print_usage();
603 printf (UT_HELP_VRSN); 607 printf (UT_HELP_VRSN);
604 printf (UT_EXTRA_OPTS); 608 printf (UT_EXTRA_OPTS);
609 printf (UT_IPv46);
605 printf (UT_HOST_PORT, 'p', "123"); 610 printf (UT_HOST_PORT, 'p', "123");
606 printf (" %s\n", "-q, --quiet"); 611 printf (" %s\n", "-q, --quiet");
607 printf (" %s\n", _("Returns UNKNOWN instead of CRITICAL if offset cannot be found")); 612 printf (" %s\n", _("Returns UNKNOWN instead of CRITICAL if offset cannot be found"));
@@ -635,6 +640,6 @@ void
635print_usage(void) 640print_usage(void)
636{ 641{
637 printf ("%s\n", _("Usage:")); 642 printf ("%s\n", _("Usage:"));
638 printf(" %s -H <host> [-w <warn>] [-c <crit>] [-v verbose]\n", progname); 643 printf(" %s -H <host> [-4|-6] [-w <warn>] [-c <crit>] [-v verbose]\n", progname);
639} 644}
640 645
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 69edae7..8b0769f 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -475,6 +475,6 @@ void
475print_usage (void) 475print_usage (void)
476{ 476{
477 printf ("%s\n", _("Usage:")); 477 printf ("%s\n", _("Usage:"));
478 printf ("%s [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]\n", progname); 478 printf ("%s [-H <host>] [-4|-6] [-P <port>] [-c <critical time>] [-w <warning time>]\n", progname);
479 printf (" [-t <timeout>] [-d <database>] [-l <logname>] [-p <password>]\n"); 479 printf (" [-t <timeout>] [-d <database>] [-l <logname>] [-p <password>]\n");
480} 480}
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 2f2dcc5..00b032a 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -45,15 +45,13 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
45 45
46int process_arguments (int, char **); 46int process_arguments (int, char **);
47int validate_arguments (void); 47int validate_arguments (void);
48int check_thresholds (int);
49int convert_to_seconds (char *); 48int convert_to_seconds (char *);
50void print_help (void); 49void print_help (void);
51void print_usage (void); 50void print_usage (void);
52 51
53int wmax = -1; 52char *warning_range = NULL;
54int cmax = -1; 53char *critical_range = NULL;
55int wmin = -1; 54thresholds *procs_thresholds = NULL;
56int cmin = -1;
57 55
58int options = 0; /* bitmask of filter criteria to test against */ 56int options = 0; /* bitmask of filter criteria to test against */
59#define ALL 1 57#define ALL 1
@@ -238,14 +236,14 @@ main (int argc, char **argv)
238 } 236 }
239 237
240 if (metric == METRIC_VSZ) 238 if (metric == METRIC_VSZ)
241 i = check_thresholds (procvsz); 239 i = get_status ((double)procvsz, procs_thresholds);
242 else if (metric == METRIC_RSS) 240 else if (metric == METRIC_RSS)
243 i = check_thresholds (procrss); 241 i = get_status ((double)procrss, procs_thresholds);
244 /* TODO? float thresholds for --metric=CPU */ 242 /* TODO? float thresholds for --metric=CPU */
245 else if (metric == METRIC_CPU) 243 else if (metric == METRIC_CPU)
246 i = check_thresholds ((int)procpcpu); 244 i = get_status (procpcpu, procs_thresholds);
247 else if (metric == METRIC_ELAPSED) 245 else if (metric == METRIC_ELAPSED)
248 i = check_thresholds (procseconds); 246 i = get_status ((double)procseconds, procs_thresholds);
249 247
250 if (metric != METRIC_PROCS) { 248 if (metric != METRIC_PROCS) {
251 if (i == STATE_WARNING) { 249 if (i == STATE_WARNING) {
@@ -276,7 +274,7 @@ main (int argc, char **argv)
276 274
277 /* Needed if procs found, but none match filter */ 275 /* Needed if procs found, but none match filter */
278 if ( metric == METRIC_PROCS ) { 276 if ( metric == METRIC_PROCS ) {
279 result = max_state (result, check_thresholds (procs) ); 277 result = max_state (result, get_status ((double)procs, procs_thresholds) );
280 } 278 }
281 279
282 if ( result == STATE_OK ) { 280 if ( result == STATE_OK ) {
@@ -301,6 +299,13 @@ main (int argc, char **argv)
301 if ( verbose >= 1 && strcmp(fails,"") ) 299 if ( verbose >= 1 && strcmp(fails,"") )
302 printf (" [%s]", fails); 300 printf (" [%s]", fails);
303 301
302 if (metric == METRIC_PROCS)
303 printf (" | procs=%d;%s;%s;0;", procs,
304 warning_range ? warning_range : "",
305 critical_range ? critical_range : "");
306 else
307 printf (" | procs=%d;;;0; procs_warn=%d;;;0; procs_crit=%d;;;0;", procs, warn, crit);
308
304 printf ("\n"); 309 printf ("\n");
305 return result; 310 return result;
306} 311}
@@ -368,28 +373,10 @@ process_arguments (int argc, char **argv)
368 timeout_interval = atoi (optarg); 373 timeout_interval = atoi (optarg);
369 break; 374 break;
370 case 'c': /* critical threshold */ 375 case 'c': /* critical threshold */
371 if (is_integer (optarg)) 376 critical_range = optarg;
372 cmax = atoi (optarg);
373 else if (sscanf (optarg, ":%d", &cmax) == 1)
374 break;
375 else if (sscanf (optarg, "%d:%d", &cmin, &cmax) == 2)
376 break;
377 else if (sscanf (optarg, "%d:", &cmin) == 1)
378 break;
379 else
380 usage4 (_("Critical Process Count must be an integer!"));
381 break; 377 break;
382 case 'w': /* warning threshold */ 378 case 'w': /* warning threshold */
383 if (is_integer (optarg)) 379 warning_range = optarg;
384 wmax = atoi (optarg);
385 else if (sscanf (optarg, ":%d", &wmax) == 1)
386 break;
387 else if (sscanf (optarg, "%d:%d", &wmin, &wmax) == 2)
388 break;
389 else if (sscanf (optarg, "%d:", &wmin) == 1)
390 break;
391 else
392 usage4 (_("Warning Process Count must be an integer!"));
393 break; 380 break;
394 case 'p': /* process id */ 381 case 'p': /* process id */
395 if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) { 382 if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) {
@@ -518,16 +505,19 @@ process_arguments (int argc, char **argv)
518 } 505 }
519 506
520 c = optind; 507 c = optind;
521 if (wmax == -1 && argv[c]) 508 if ((! warning_range) && argv[c])
522 wmax = atoi (argv[c++]); 509 warning_range = argv[c++];
523 if (cmax == -1 && argv[c]) 510 if ((! critical_range) && argv[c])
524 cmax = atoi (argv[c++]); 511 critical_range = argv[c++];
525 if (statopts == NULL && argv[c]) { 512 if (statopts == NULL && argv[c]) {
526 xasprintf (&statopts, "%s", argv[c++]); 513 xasprintf (&statopts, "%s", argv[c++]);
527 xasprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts); 514 xasprintf (&fmt, _("%s%sSTATE = %s"), (fmt ? fmt : ""), (options ? ", " : ""), statopts);
528 options |= STAT; 515 options |= STAT;
529 } 516 }
530 517
518 /* this will abort in case of invalid ranges */
519 set_thresholds (&procs_thresholds, warning_range, critical_range);
520
531 return validate_arguments (); 521 return validate_arguments ();
532} 522}
533 523
@@ -536,27 +526,6 @@ process_arguments (int argc, char **argv)
536int 526int
537validate_arguments () 527validate_arguments ()
538{ 528{
539
540 if (wmax >= 0 && wmin == -1)
541 wmin = 0;
542 if (cmax >= 0 && cmin == -1)
543 cmin = 0;
544 if (wmax >= wmin && cmax >= cmin) { /* standard ranges */
545 if (wmax > cmax && cmax != -1) {
546 printf (_("wmax (%d) cannot be greater than cmax (%d)\n"), wmax, cmax);
547 return ERROR;
548 }
549 if (cmin > wmin && wmin != -1) {
550 printf (_("wmin (%d) cannot be less than cmin (%d)\n"), wmin, cmin);
551 return ERROR;
552 }
553 }
554
555/* if (wmax == -1 && cmax == -1 && wmin == -1 && cmin == -1) { */
556/* printf ("At least one threshold must be set\n"); */
557/* return ERROR; */
558/* } */
559
560 if (options == 0) 529 if (options == 0)
561 options = ALL; 530 options = ALL;
562 531
@@ -579,40 +548,6 @@ validate_arguments ()
579} 548}
580 549
581 550
582
583/* Check thresholds against value */
584int
585check_thresholds (int value)
586{
587 if (wmax == -1 && cmax == -1 && wmin == -1 && cmin == -1) {
588 return OK;
589 }
590 else if (cmax >= 0 && cmin >= 0 && cmax < cmin) {
591 if (value > cmax && value < cmin)
592 return STATE_CRITICAL;
593 }
594 else if (cmax >= 0 && value > cmax) {
595 return STATE_CRITICAL;
596 }
597 else if (cmin >= 0 && value < cmin) {
598 return STATE_CRITICAL;
599 }
600
601 if (wmax >= 0 && wmin >= 0 && wmax < wmin) {
602 if (value > wmax && value < wmin) {
603 return STATE_WARNING;
604 }
605 }
606 else if (wmax >= 0 && value > wmax) {
607 return STATE_WARNING;
608 }
609 else if (wmin >= 0 && value < wmin) {
610 return STATE_WARNING;
611 }
612 return STATE_OK;
613}
614
615
616/* convert the elapsed time to seconds */ 551/* convert the elapsed time to seconds */
617int 552int
618convert_to_seconds(char *etime) { 553convert_to_seconds(char *etime) {
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 2d9861b..7c5d0ec 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -144,6 +144,25 @@ double previous_value[MAX_OIDS];
144int perf_labels = 1; 144int perf_labels = 1;
145 145
146 146
147static char *fix_snmp_range(char *th)
148{
149 double left, right;
150 char *colon, *ret;
151 if (!(colon = strchr(th, ':')))
152 return th;
153 *colon = 0;
154
155 left = strtod(th, NULL);
156 right = strtod(colon + 1, NULL);
157 if (right >= left) {
158 return th;
159 }
160 ret = malloc(strlen(th) + strlen(colon + 1) + 2);
161 sprintf(ret, "@%s:%s", colon + 1, th);
162 free(th);
163 return ret;
164}
165
147int 166int
148main (int argc, char **argv) 167main (int argc, char **argv)
149{ 168{
@@ -181,8 +200,8 @@ main (int argc, char **argv)
181 bindtextdomain (PACKAGE, LOCALEDIR); 200 bindtextdomain (PACKAGE, LOCALEDIR);
182 textdomain (PACKAGE); 201 textdomain (PACKAGE);
183 202
184 labels = malloc (labels_size); 203 labels = malloc (labels_size * sizeof(*labels));
185 unitv = malloc (unitv_size); 204 unitv = malloc (unitv_size * sizeof(*unitv));
186 for (i = 0; i < MAX_OIDS; i++) 205 for (i = 0; i < MAX_OIDS; i++)
187 eval_method[i] = CHECK_UNDEF; 206 eval_method[i] = CHECK_UNDEF;
188 207
@@ -228,6 +247,10 @@ main (int argc, char **argv)
228 for (i=0; i<numoids; i++) { 247 for (i=0; i<numoids; i++) {
229 char *w = th_warn ? strndup(th_warn, strcspn(th_warn, ",")) : NULL; 248 char *w = th_warn ? strndup(th_warn, strcspn(th_warn, ",")) : NULL;
230 char *c = th_crit ? strndup(th_crit, strcspn(th_crit, ",")) : NULL; 249 char *c = th_crit ? strndup(th_crit, strcspn(th_crit, ",")) : NULL;
250 /* translate "2:1" to "@1:2" for backwards compatibility */
251 w = w ? fix_snmp_range(w) : NULL;
252 c = c ? fix_snmp_range(c) : NULL;
253
231 /* Skip empty thresholds, while avoiding segfault */ 254 /* Skip empty thresholds, while avoiding segfault */
232 set_thresholds(&thlds[i], 255 set_thresholds(&thlds[i],
233 w ? strpbrk(w, NP_THRESHOLDS_CHARS) : NULL, 256 w ? strpbrk(w, NP_THRESHOLDS_CHARS) : NULL,
@@ -396,7 +419,7 @@ main (int argc, char **argv)
396 show = strstr (response, "Timeticks: "); 419 show = strstr (response, "Timeticks: ");
397 } 420 }
398 else 421 else
399 show = response; 422 show = response + 3;
400 423
401 iresult = STATE_DEPENDENT; 424 iresult = STATE_DEPENDENT;
402 425
@@ -405,7 +428,7 @@ main (int argc, char **argv)
405 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) { 428 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
406 ptr = strpbrk (show, "0123456789"); 429 ptr = strpbrk (show, "0123456789");
407 if (ptr == NULL) 430 if (ptr == NULL)
408 die (STATE_UNKNOWN,_("No valid data returned")); 431 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
409 response_value[i] = strtod (ptr, NULL); 432 response_value[i] = strtod (ptr, NULL);
410 433
411 if(calculate_rate) { 434 if(calculate_rate) {
@@ -745,9 +768,9 @@ process_arguments (int argc, char **argv)
745 break; 768 break;
746 case 'l': /* label */ 769 case 'l': /* label */
747 nlabels++; 770 nlabels++;
748 if (nlabels >= labels_size) { 771 if (nlabels > labels_size) {
749 labels_size += 8; 772 labels_size += 8;
750 labels = realloc (labels, labels_size); 773 labels = realloc (labels, labels_size * sizeof(*labels));
751 if (labels == NULL) 774 if (labels == NULL)
752 die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), (int)nlabels); 775 die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), (int)nlabels);
753 } 776 }
@@ -757,13 +780,13 @@ process_arguments (int argc, char **argv)
757 if (ptr[0] == '\'') 780 if (ptr[0] == '\'')
758 labels[nlabels - 1] = ptr + 1; 781 labels[nlabels - 1] = ptr + 1;
759 while (ptr && (ptr = nextarg (ptr))) { 782 while (ptr && (ptr = nextarg (ptr))) {
760 if (nlabels >= labels_size) { 783 nlabels++;
784 if (nlabels > labels_size) {
761 labels_size += 8; 785 labels_size += 8;
762 labels = realloc (labels, labels_size); 786 labels = realloc (labels, labels_size * sizeof(*labels));
763 if (labels == NULL) 787 if (labels == NULL)
764 die (STATE_UNKNOWN, _("Could not reallocate labels\n")); 788 die (STATE_UNKNOWN, _("Could not reallocate labels\n"));
765 } 789 }
766 nlabels++;
767 ptr = thisarg (ptr); 790 ptr = thisarg (ptr);
768 if (ptr[0] == '\'') 791 if (ptr[0] == '\'')
769 labels[nlabels - 1] = ptr + 1; 792 labels[nlabels - 1] = ptr + 1;
@@ -774,9 +797,9 @@ process_arguments (int argc, char **argv)
774 case 'u': /* units */ 797 case 'u': /* units */
775 units = optarg; 798 units = optarg;
776 nunits++; 799 nunits++;
777 if (nunits >= unitv_size) { 800 if (nunits > unitv_size) {
778 unitv_size += 8; 801 unitv_size += 8;
779 unitv = realloc (unitv, unitv_size); 802 unitv = realloc (unitv, unitv_size * sizeof(*unitv));
780 if (unitv == NULL) 803 if (unitv == NULL)
781 die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), (int)nunits); 804 die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), (int)nunits);
782 } 805 }
@@ -786,9 +809,9 @@ process_arguments (int argc, char **argv)
786 if (ptr[0] == '\'') 809 if (ptr[0] == '\'')
787 unitv[nunits - 1] = ptr + 1; 810 unitv[nunits - 1] = ptr + 1;
788 while (ptr && (ptr = nextarg (ptr))) { 811 while (ptr && (ptr = nextarg (ptr))) {
789 if (nunits >= unitv_size) { 812 if (nunits > unitv_size) {
790 unitv_size += 8; 813 unitv_size += 8;
791 unitv = realloc (unitv, unitv_size); 814 unitv = realloc (unitv, unitv_size * sizeof(*unitv));
792 if (units == NULL) 815 if (units == NULL)
793 die (STATE_UNKNOWN, _("Could not realloc() units\n")); 816 die (STATE_UNKNOWN, _("Could not realloc() units\n"));
794 } 817 }
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 4d63394..6e8a5fc 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -307,6 +307,6 @@ void
307print_usage (void) 307print_usage (void)
308{ 308{
309 printf ("%s\n", _("Usage:")); 309 printf ("%s\n", _("Usage:"));
310 printf ("%s [-46] [-t <timeout>] [-r <remote version>] [-p <port>] <host>\n", progname); 310 printf ("%s [-4|-6] [-t <timeout>] [-r <remote version>] [-p <port>] <host>\n", progname);
311} 311}
312 312
diff --git a/plugins/common.h b/plugins/common.h
index 09af7e7..c0dc2f4 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -141,6 +141,7 @@
141#ifdef HAVE_GNUTLS_OPENSSL_H 141#ifdef HAVE_GNUTLS_OPENSSL_H
142# include <gnutls/openssl.h> 142# include <gnutls/openssl.h>
143#else 143#else
144# define OPENSSL_LOAD_CONF /* See the OPENSSL_config(3) man page. */
144# ifdef HAVE_SSL_H 145# ifdef HAVE_SSL_H
145# include <rsa.h> 146# include <rsa.h>
146# include <crypto.h> 147# include <crypto.h>
diff --git a/plugins/t/check_dig.t b/plugins/t/check_dig.t
index 323859e..1ab4b42 100644
--- a/plugins/t/check_dig.t
+++ b/plugins/t/check_dig.t
@@ -10,30 +10,30 @@ use NPTest;
10 10
11plan skip_all => "check_dig not compiled" unless (-x "check_dig"); 11plan skip_all => "check_dig not compiled" unless (-x "check_dig");
12 12
13plan tests => 12; 13plan tests => 16;
14 14
15my $successOutput = '/DNS OK - [\.0-9]+ seconds? response time/'; 15my $successOutput = '/DNS OK - [\.0-9]+ seconds? response time/';
16 16
17my $hostname_valid = getTestParameter( 17my $hostname_valid = getTestParameter(
18 "NP_HOSTNAME_VALID", 18 "NP_HOSTNAME_VALID",
19 "A valid (known to DNS) hostname", 19 "A valid (known to DNS) hostname",
20 "nagios.com" 20 "nagiosplugins.org"
21 ); 21 );
22 22
23my $hostname_valid_ip = getTestParameter( 23my $hostname_valid_ip = getTestParameter(
24 "NP_HOSTNAME_VALID_IP", 24 "NP_HOSTNAME_VALID_IP",
25 "The IP address of the valid hostname $hostname_valid", 25 "The IP address of the valid hostname $hostname_valid",
26 "66.118.156.50", 26 "67.207.143.200",
27 ); 27 );
28 28
29my $hostname_valid_reverse = getTestParameter( 29my $hostname_valid_reverse = getTestParameter(
30 "NP_HOSTNAME_VALID_REVERSE", 30 "NP_HOSTNAME_VALID_REVERSE",
31 "The hostname of $hostname_valid_ip", 31 "The hostname of $hostname_valid_ip",
32 "66-118-156-50.static.sagonet.net.", 32 "nagiosplugins.org.",
33 ); 33 );
34 34
35my $hostname_invalid = getTestParameter( 35my $hostname_invalid = getTestParameter(
36 "NP_HOSTNAME_INVALID", 36 "NP_HOSTNAME_INVALID",
37 "An invalid (not known to DNS) hostname", 37 "An invalid (not known to DNS) hostname",
38 "nosuchhost.altinity.com", 38 "nosuchhost.altinity.com",
39 ); 39 );
@@ -69,6 +69,14 @@ SKIP: {
69 cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server"); 69 cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
70 like ( $res->output, $successOutput, "Output OK" ); 70 like ( $res->output, $successOutput, "Output OK" );
71 71
72 $res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -4");
73 cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
74 like ( $res->output, $successOutput, "Output OK for IPv4" );
75
76 $res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -t 5 -6");
77 cmp_ok( $res->return_code, '==', 0, "Found $hostname_valid on $dns_server");
78 like ( $res->output, $successOutput, "Output OK for IPv6" );
79
72 $res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -a $hostname_valid_ip -t 5"); 80 $res = NPTest->testCmd("./check_dig -H $dns_server -l $hostname_valid -a $hostname_valid_ip -t 5");
73 cmp_ok( $res->return_code, '==', 0, "Got expected address"); 81 cmp_ok( $res->return_code, '==', 0, "Got expected address");
74 82
diff --git a/tools/np_build_from_sf b/tools/np_build_from_sf
new file mode 100755
index 0000000..7ba349a
--- /dev/null
+++ b/tools/np_build_from_sf
@@ -0,0 +1,11 @@
1#!/bin/bash
2
3set -xeu
4
5temp=$(mktemp -d)
6trap "cd $HOME; rm -rf $temp; exit 1" EXIT
7curl -sS http://nagiosplug.sourceforge.net/snapshot/nagios-plugins-HEAD.tar.gz|tar -C "$temp" --strip-components=1 -xzf -
8cd $temp
9./configure && make
10$HOME/bin/update_man_pages
11
diff --git a/tools/sfwebcron b/tools/sfwebcron
index d836a0f..0f31fcf 100755
--- a/tools/sfwebcron
+++ b/tools/sfwebcron
@@ -4,32 +4,32 @@
4# To update the developers-guidelines.html and put in html area 4# To update the developers-guidelines.html and put in html area
5# 5#
6# Install in cron with something like: 6# Install in cron with something like:
7# 47 7 * * * $HOME/bin/sfwebcron 7# 47 7 * * * $HOME/bin/sfwebcron >/tmp/sfwebcron.log 2>&1 || cat /tmp/sfwebcron.log
8 8
9function die { echo $1; exit 1; } 9set -eu
10trap 'echo "Command failed at line $LINENO"' ERR
10 11
11# Set working variables 12# Set working variables
12PROJECT=nagiosplug 13PROJECT=nagiosplug
13IN=${HOME}/tmp_sfwebcron 14IN=${HOME}/sfwebcron
14OUT_SERVER="tonvoon@shell.sf.net" 15PROBE="developer-guidelines.html.last"
15OUT="/home/groups/n/na/nagiosplug/htdocs" 16OUT_SERVER="tonvoon@frs.sourceforge.net"
16 17OUT_PATH="/home/groups/n/na/nagiosplug/htdocs"
17if [[ ! -e developer-guidelines.html.last ]] ; then
18 touch developer-guidelines.html.last
19fi
20 18
21# Get latest dev guildelines 19# Get latest dev guildelines
22[[ ! -d $IN ]] && mkdir $IN 20[[ ! -d $IN ]] && mkdir $IN
23cd $IN 21cd $IN
24if [[ ! -d doc ]] ; then 22if [[ ! -d nagios-plugins ]]
25 #cvs -z3 -d:pserver:anonymous@cvs1:/cvsroot/nagiosplug co nagiosplug || die "Cannot cvs" 23then
26 svn checkout http://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk/doc doc 24 git clone https://github.com/nagios-plugins/nagios-plugins.git nagios-plugins
27fi 25fi
28cd doc 26cd nagios-plugins/doc
29svn update 27git pull
30 28
31make 29make
32if [[ developer-guidelines.html -nt developer-guidelines.html.last ]] ; then 30if [[ ! -e $PROBE || developer-guidelines.html -nt $PROBE ]]
33 scp developer-guidelines.{html,sgml} $OUT_SERVER:$OUT 31then
34 touch developer-guidelines.html.last 32 rsync -av developer-guidelines.{html,sgml} $OUT_SERVER:$OUT_PATH/
33 touch $PROBE
35fi 34fi
35
diff --git a/tools/snapshot b/tools/snapshot
deleted file mode 100755
index 9fa61cf..0000000
--- a/tools/snapshot
+++ /dev/null
@@ -1,69 +0,0 @@
1#! /bin/sh
2
3# This scipt assumes that you have anonCVS for nagios and nagiosplug
4# in ${IN}
5
6# cvs -d:pserver:anonymous@cvs.nagiosplug.sourceforge.net:/cvsroot/nagiosplug login
7# cvs -z3 -d:pserver:anonymous@cvs.nagiosplug.sourceforge.net:/cvsroot/nagiosplug co nagiosplug
8#
9# cvs -d:pserver:anonymous@cvs.nagios.sourceforge.net:/cvsroot/nagios login
10# cvs -z3 -d:pserver:anonymous@cvs.nagios.sourceforge.net:/cvsroot/nagios co nagios
11
12# Set directories
13IN=${HOME}/sf
14OUT=/col/htdocs/src/nagios
15RPM_TOPDIR=${HOME}/redhat
16
17# Update nagiosplug CVS
18cd ${IN}/nagiosplug
19rm configure configure.in Makefile.in
20cvs update
21DS=`date -u +%Y%m%d%H%M`
22sed "s/^VER=.*/VER=${DS}/;s/^REL=.*/REL=snapshot/" configure.in > configure.tmp
23mv configure.tmp configure.in
24aclocal
25autoheader
26autoconf
27automake
28autoreconf
29
30# Make the Nagiosplug dist tarball
31rm -r build-dist
32mkdir build-dist
33cd build-dist
34../configure
35make dist
36cp -fv *.gz ${OUT}
37
38# Make the Nagiosplug custom RPM
39echo "%_topdir ${RPM_TOPDIR}" > ./.rpmrc
40mkdir -p ${RPM_TOPDIR}/RPMS/i386 ${RPM_TOPDIR}/SRPMS ${RPM_TOPDIR}/SOURCES ${RPM_TOPDIR}/BUILD ${RPM_TOPDIR}/SPECS
41rpm --rcfile "/usr/lib/rpm/rpmrc:${IN}/rpmrc" --define 'custom 1' -ta *.gz
42cp -fv ~/redhat/RPMS/i386/nagios-plugins-custom-*.i386.rpm /col/htdocs/src/nagios
43
44# Copy the new snapshot and delete the old ones
45cd ${OUT}
46GLOBIGNORE=nagios-plugins-${DS}-snapshot.tar.gz
47rm -f nagios-plugins-*.tar.gz
48GLOBIGNORE=nagios-plugins-custom-${DS}-snapshot.i386.rpm
49rm -f nagios-plugins-custom-*-snapshot.i386.rpm
50cd ~/redhat/SRPMS
51rm nagios-plugins-custom-${DS}-snapshot.src.rpm
52cd ~/redhat/RPMS/i386
53rm nagios-plugins-custom-${DS}-snapshot.i386.rpm
54
55# Update Nagios CVS
56cd ${IN}/sf/nagios
57rm configure configure.in nagios.spec base/nagios.c common/common.h \
58 html/main.html Makefile.in
59cvs update
60
61# Make the Nagios tarball
62DS=`date -u +%Y%m%d%H%M`
63./make-tarball ${DS}
64
65# Copy the new snapshot and delete the old ones
66mv ../nagios-${DS}.tar.gz /col/htdocs/src/nagios/
67GLOBIGNORE=${OUT}/nagios-${DS}.tar.gz
68rm ${OUT}/nagios-20*.tar.gz
69
diff --git a/tools/update_man_pages b/tools/update_man_pages
new file mode 100755
index 0000000..5c4a901
--- /dev/null
+++ b/tools/update_man_pages
@@ -0,0 +1,34 @@
1#!/usr/bin/perl
2use strict;
3use DBI;
4#$ENV{PERL5LIB}="plugins-scripts"; # Needed for utils.pm
5
6unless ($ENV{DRUPAL_PASSWORD}) {
7 die "Must set envvar for DRUPAL_PASSWORD";
8}
9
10my $dbh = DBI->connect("DBI:mysql:database=www;host=127.0.0.1", "www", $ENV{DRUPAL_PASSWORD});
11
12my @plugin_paths;
13push @plugin_paths, (grep { -x $_ && -f $_ } (<plugins-root/*>, <plugins/*>) );
14
15foreach my $plugin_path (@plugin_paths) {
16 my $plugin = $plugin_path;
17 $plugin =~ s%.*/%%;
18 my $help_option = "--help";
19 $help_option = "-h" if ($plugin eq "check_icmp");
20 my $help = `$plugin_path $help_option` || die "Cannot run $plugin -h";
21 $help =~ s/</&lt;/g;
22 $help =~ s/>/&gt;/g;
23
24 my $rows = $dbh->do("UPDATE node SET created=UNIX_TIMESTAMP(NOW()) WHERE title='$plugin'");
25 unless ($rows == 1) {
26 die "Cannot find $plugin in drupal to update - create book page first";
27 }
28
29 $dbh->do("UPDATE node_revisions SET timestamp=UNIX_TIMESTAMP(NOW()), log='Updated by update_online_manpage', teaser='$plugin --help', body=? WHERE title='$plugin'",
30 {},
31 "<pre>".$help."</pre>");
32}
33
34print "Finished\n";