summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am20
-rw-r--r--plugins/check_apt.c13
-rw-r--r--plugins/check_by_ssh.c18
-rw-r--r--plugins/check_cluster.c8
-rw-r--r--plugins/check_dbi.c14
-rw-r--r--plugins/check_dig.c18
-rw-r--r--plugins/check_disk.c31
-rw-r--r--plugins/check_dns.c26
-rw-r--r--plugins/check_dummy.c6
-rw-r--r--plugins/check_fping.c6
-rw-r--r--plugins/check_game.c8
-rw-r--r--plugins/check_hpjd.c6
-rw-r--r--plugins/check_http.c30
-rw-r--r--plugins/check_ide_smart.c121
-rw-r--r--plugins/check_ldap.c8
-rw-r--r--plugins/check_load.c6
-rw-r--r--plugins/check_mrtg.c8
-rw-r--r--plugins/check_mrtgtraf.c6
-rw-r--r--plugins/check_mysql.c12
-rw-r--r--plugins/check_mysql_query.c40
-rw-r--r--plugins/check_nagios.c6
-rw-r--r--plugins/check_nt.c14
-rw-r--r--plugins/check_ntp.c25
-rw-r--r--plugins/check_ntp_peer.c8
-rw-r--r--plugins/check_ntp_time.c12
-rw-r--r--plugins/check_nwstat.c8
-rw-r--r--plugins/check_overcr.c8
-rw-r--r--plugins/check_pgsql.c12
-rw-r--r--plugins/check_ping.c21
-rw-r--r--plugins/check_procs.c16
-rw-r--r--plugins/check_radius.c61
-rw-r--r--plugins/check_real.c9
-rw-r--r--plugins/check_smtp.c8
-rw-r--r--plugins/check_snmp.c20
-rw-r--r--plugins/check_ssh.c8
-rw-r--r--plugins/check_swap.c32
-rw-r--r--plugins/check_tcp.c11
-rw-r--r--plugins/check_time.c8
-rw-r--r--plugins/check_ups.c16
-rw-r--r--plugins/check_users.c50
-rw-r--r--plugins/common.h4
-rw-r--r--plugins/negate.c48
-rw-r--r--plugins/netutils.c4
-rw-r--r--plugins/netutils.h4
-rw-r--r--plugins/popen.c4
-rw-r--r--plugins/runcmd.c6
-rw-r--r--plugins/runcmd.h2
-rw-r--r--plugins/sslutils.c6
-rw-r--r--plugins/t/NPTest.cache.travis54
-rw-r--r--plugins/t/check_disk.t4
-rw-r--r--plugins/t/check_dns.t5
-rw-r--r--plugins/t/check_fping.t14
-rw-r--r--plugins/t/check_http.t24
-rw-r--r--plugins/t/check_mysql.t32
-rw-r--r--plugins/t/check_ntp.t10
-rw-r--r--plugins/t/check_procs.t7
-rw-r--r--plugins/t/check_snmp.t13
-rw-r--r--plugins/t/check_tcp.t18
-rw-r--r--plugins/t/check_udp.t2
-rw-r--r--plugins/t/negate.t2
-rwxr-xr-xplugins/tests/check_http.t29
-rwxr-xr-x[-rw-r--r--]plugins/tests/check_procs.t85
-rwxr-xr-xplugins/tests/check_snmp.t36
-rw-r--r--plugins/tests/check_snmp_agent.pl14
-rw-r--r--plugins/tests/var/ps_axwo.debian4
-rw-r--r--plugins/urlize.c15
-rw-r--r--plugins/utils.c2
-rw-r--r--plugins/utils.h28
68 files changed, 740 insertions, 494 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 031dd251..0ddf9bd1 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -11,9 +11,10 @@ endif
11 11
12AM_CFLAGS = -DNP_VERSION='"$(NP_VERSION)"' 12AM_CFLAGS = -DNP_VERSION='"$(NP_VERSION)"'
13 13
14VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t 14VPATH = $(top_srcdir) $(top_srcdir)/lib $(top_srcdir)/plugins $(top_srcdir)/plugins/t
15 15
16INCLUDES = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl @LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@ 16AM_CPPFLAGS = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl \
17 @LDAPINCLUDE@ @PGINCLUDE@ @SSLINCLUDE@
17 18
18localedir = $(datadir)/locale 19localedir = $(datadir)/locale
19# gettext docs say to use AM_CPPFLAGS, but per module_CPPFLAGS override this 20# gettext docs say to use AM_CPPFLAGS, but per module_CPPFLAGS override this
@@ -48,7 +49,7 @@ noinst_LIBRARIES = libnpcommon.a
48libnpcommon_a_SOURCES = utils.c netutils.c sslutils.c runcmd.c \ 49libnpcommon_a_SOURCES = utils.c netutils.c sslutils.c runcmd.c \
49 popen.c utils.h netutils.h popen.h common.h runcmd.c runcmd.h 50 popen.c utils.h netutils.h popen.h common.h runcmd.c runcmd.h
50 51
51BASEOBJS = libnpcommon.a ../lib/libnagiosplug.a ../gl/libgnu.a 52BASEOBJS = libnpcommon.a ../lib/libmonitoringplug.a ../gl/libgnu.a
52NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS) 53NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS)
53NETLIBS = $(NETOBJS) $(SOCKETLIBS) 54NETLIBS = $(NETOBJS) $(SOCKETLIBS)
54SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) 55SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS)
@@ -81,11 +82,11 @@ check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS)
81check_load_LDADD = $(BASEOBJS) 82check_load_LDADD = $(BASEOBJS)
82check_mrtg_LDADD = $(BASEOBJS) 83check_mrtg_LDADD = $(BASEOBJS)
83check_mrtgtraf_LDADD = $(BASEOBJS) 84check_mrtgtraf_LDADD = $(BASEOBJS)
84check_mysql_CFLAGS = $(MYSQLCFLAGS) -DNP_VERSION='"$(NP_VERSION)"' 85check_mysql_CFLAGS = $(AM_CFLAGS) $(MYSQLCFLAGS)
85check_mysql_CPPFLAGS = $(MYSQLINCLUDE) 86check_mysql_CPPFLAGS = $(AM_CPPFLAGS) $(MYSQLINCLUDE)
86check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS) 87check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS)
87check_mysql_query_CFLAGS = $(MYSQLCFLAGS) -DNP_VERSION='"$(NP_VERSION)"' 88check_mysql_query_CFLAGS = $(AM_CFLAGS) $(MYSQLCFLAGS)
88check_mysql_query_CPPFLAGS = $(MYSQLINCLUDE) 89check_mysql_query_CPPFLAGS = $(AM_CPPFLAGS) $(MYSQLINCLUDE)
89check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS) 90check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS)
90check_nagios_LDADD = $(BASEOBJS) 91check_nagios_LDADD = $(BASEOBJS)
91check_nt_LDADD = $(NETLIBS) 92check_nt_LDADD = $(NETLIBS)
@@ -106,7 +107,7 @@ check_tcp_LDADD = $(SSLOBJS)
106check_time_LDADD = $(NETLIBS) 107check_time_LDADD = $(NETLIBS)
107check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS) 108check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS)
108check_ups_LDADD = $(NETLIBS) 109check_ups_LDADD = $(NETLIBS)
109check_users_LDADD = $(BASEOBJS) 110check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS)
110check_by_ssh_LDADD = $(NETLIBS) 111check_by_ssh_LDADD = $(NETLIBS)
111check_ide_smart_LDADD = $(BASEOBJS) 112check_ide_smart_LDADD = $(BASEOBJS)
112negate_LDADD = $(BASEOBJS) 113negate_LDADD = $(BASEOBJS)
@@ -129,11 +130,10 @@ install-exec-hook:
129 cd $(DESTDIR)$(libexecdir) && \ 130 cd $(DESTDIR)$(libexecdir) && \
130 for i in $(check_tcp_programs) ; do rm -f $$i; ln -s check_tcp $$i ; done ;\ 131 for i in $(check_tcp_programs) ; do rm -f $$i; ln -s check_tcp $$i ; done ;\
131 if [ -x check_ldap ] ; then rm -f check_ldaps ; ln -s check_ldap check_ldaps ; fi 132 if [ -x check_ldap ] ; then rm -f check_ldaps ; ln -s check_ldap check_ldaps ; fi
132 133
133clean-local: 134clean-local:
134 rm -f $(check_tcp_programs) 135 rm -f $(check_tcp_programs)
135 rm -f NP-VERSION-FILE 136 rm -f NP-VERSION-FILE
136 137
137uninstall-local: 138uninstall-local:
138 cd $(DESTDIR)$(libexecdir) && rm -f $(check_tcp_programs) 139 cd $(DESTDIR)$(libexecdir) && rm -f $(check_tcp_programs)
139
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index daeb7578..07622c2f 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_apt plugin 3* Monitoring check_apt plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2006-2008 Nagios Plugins Development Team 6* Copyright (c) 2006-2008 Monitoring Plugins Development Team
7* 7*
8* Original author: Sean Finney 8* Original author: Sean Finney
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_apt"; 32const char *progname = "check_apt";
33const char *copyright = "2006-2008"; 33const char *copyright = "2006-2008";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "runcmd.h" 37#include "runcmd.h"
@@ -124,7 +124,7 @@ int main (int argc, char **argv) {
124 (stderr_warning)?" warnings detected":"", 124 (stderr_warning)?" warnings detected":"",
125 (stderr_warning && exec_warning)?",":"", 125 (stderr_warning && exec_warning)?",":"",
126 (exec_warning)?" errors detected":"", 126 (exec_warning)?" errors detected":"",
127 (stderr_warning||exec_warning)?". run with -v for information.":"", 127 (stderr_warning||exec_warning)?".":"",
128 packages_available, 128 packages_available,
129 sec_count 129 sec_count
130 ); 130 );
@@ -223,6 +223,9 @@ int run_upgrade(int *pkgcount, int *secpkgcount){
223 regex_t ireg, ereg, sreg; 223 regex_t ireg, ereg, sreg;
224 char *cmdline=NULL, rerrbuf[64]; 224 char *cmdline=NULL, rerrbuf[64];
225 225
226 /* initialize ereg as it is possible it is printed while uninitialized */
227 memset(&ereg, "\0", sizeof(ereg.buffer));
228
226 if(upgrade==NO_UPGRADE) return STATE_OK; 229 if(upgrade==NO_UPGRADE) return STATE_OK;
227 230
228 /* compile the regexps */ 231 /* compile the regexps */
@@ -430,7 +433,7 @@ print_help (void)
430 printf(UT_HELP_VRSN); 433 printf(UT_HELP_VRSN);
431 printf(UT_EXTRA_OPTS); 434 printf(UT_EXTRA_OPTS);
432 435
433 printf(UT_TIMEOUT, timeout_interval); 436 printf(UT_PLUG_TIMEOUT, timeout_interval);
434 437
435 printf (" %s\n", "-U, --upgrade=OPTS"); 438 printf (" %s\n", "-U, --upgrade=OPTS");
436 printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,")); 439 printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,"));
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index c5f0d529..58f333d3 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_by_ssh plugin 3* Monitoring check_by_ssh plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2008 Nagios Plugins Development Team 6* Copyright (c) 2000-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -28,7 +28,7 @@
28 28
29const char *progname = "check_by_ssh"; 29const char *progname = "check_by_ssh";
30const char *copyright = "2000-2008"; 30const char *copyright = "2000-2008";
31const char *email = "nagiosplug-devel@lists.sourceforge.net"; 31const char *email = "devel@monitoring-plugins.org";
32 32
33#include "common.h" 33#include "common.h"
34#include "utils.h" 34#include "utils.h"
@@ -246,7 +246,7 @@ process_arguments (int argc, char **argv)
246 } 246 }
247 service[services - 1] = p1; 247 service[services - 1] = p1;
248 break; 248 break;
249 case 'n': /* short name of host in nagios configuration */ 249 case 'n': /* short name of host in the monitoring configuration */
250 host_shortname = optarg; 250 host_shortname = optarg;
251 break; 251 break;
252 252
@@ -371,7 +371,7 @@ validate_arguments (void)
371 die (STATE_UNKNOWN, _("%s: In passive mode, you must provide a service name for each command.\n"), progname); 371 die (STATE_UNKNOWN, _("%s: In passive mode, you must provide a service name for each command.\n"), progname);
372 372
373 if (passive && host_shortname == NULL) 373 if (passive && host_shortname == NULL)
374 die (STATE_UNKNOWN, _("%s: In passive mode, you must provide the host short name from the nagios configs.\n"), progname); 374 die (STATE_UNKNOWN, _("%s: In passive mode, you must provide the host short name from the monitoring configs.\n"), progname);
375 375
376 return OK; 376 return OK;
377} 377}
@@ -416,11 +416,11 @@ print_help (void)
416 printf (" %s\n","-i, --identity=KEYFILE"); 416 printf (" %s\n","-i, --identity=KEYFILE");
417 printf (" %s\n", _("identity of an authorized key [optional]")); 417 printf (" %s\n", _("identity of an authorized key [optional]"));
418 printf (" %s\n","-O, --output=FILE"); 418 printf (" %s\n","-O, --output=FILE");
419 printf (" %s\n", _("external command file for nagios [optional]")); 419 printf (" %s\n", _("external command file for monitoring [optional]"));
420 printf (" %s\n","-s, --services=LIST"); 420 printf (" %s\n","-s, --services=LIST");
421 printf (" %s\n", _("list of nagios service names, separated by ':' [optional]")); 421 printf (" %s\n", _("list of monitoring service names, separated by ':' [optional]"));
422 printf (" %s\n","-n, --name=NAME"); 422 printf (" %s\n","-n, --name=NAME");
423 printf (" %s\n", _("short name of host in nagios configuration [optional]")); 423 printf (" %s\n", _("short name of host in the monitoring configuration [optional]"));
424 printf (" %s\n","-o, --ssh-option=OPTION"); 424 printf (" %s\n","-o, --ssh-option=OPTION");
425 printf (" %s\n", _("Call ssh with '-o OPTION' (may be used multiple times) [optional]")); 425 printf (" %s\n", _("Call ssh with '-o OPTION' (may be used multiple times) [optional]"));
426 printf (" %s\n","-F, --configfile"); 426 printf (" %s\n","-F, --configfile");
@@ -428,7 +428,7 @@ print_help (void)
428 printf (" %s\n","-q, --quiet"); 428 printf (" %s\n","-q, --quiet");
429 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); 429 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
430 printf (UT_WARN_CRIT); 430 printf (UT_WARN_CRIT);
431 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 431 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
432 printf (UT_VERBOSE); 432 printf (UT_VERBOSE);
433 printf("\n"); 433 printf("\n");
434 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with")); 434 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with"));
diff --git a/plugins/check_cluster.c b/plugins/check_cluster.c
index d4e39e0f..cf699e1f 100644
--- a/plugins/check_cluster.c
+++ b/plugins/check_cluster.c
@@ -1,10 +1,10 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* check_cluster.c - Host and Service Cluster Plugin for Nagios 2.x 3* check_cluster.c - Host and Service Cluster Plugin for Monitoring
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org) 6* Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)
7* Copyright (c) 2007 Nagios Plugins Development Team 7* Copyright (c) 2007 Monitoring Plugins Development Team
8* 8*
9* This program is free software: you can redistribute it and/or modify 9* This program is free software: you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by 10* it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
24 24
25const char *progname = "check_cluster"; 25const char *progname = "check_cluster";
26const char *copyright = "2000-2007"; 26const char *copyright = "2000-2007";
27const char *email = "nagiosplug-devel@lists.sourceforge.net"; 27const char *email = "devel@monitoring-plugins.org";
28 28
29#include "common.h" 29#include "common.h"
30#include "utils.h" 30#include "utils.h"
@@ -227,7 +227,7 @@ print_help(void)
227 printf ("Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)\n"); 227 printf ("Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)\n");
228 printf(COPYRIGHT, copyright, email); 228 printf(COPYRIGHT, copyright, email);
229 229
230 printf(_("Host/Service Cluster Plugin for Nagios 2")); 230 printf(_("Host/Service Cluster Plugin for Monitoring"));
231 printf("\n\n"); 231 printf("\n\n");
232 232
233 print_usage(); 233 print_usage();
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c
index 8c4a511d..a3d033f4 100644
--- a/plugins/check_dbi.c
+++ b/plugins/check_dbi.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_dbi plugin 3* Monitoring check_dbi plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2011 Nagios Plugins Development Team 6* Copyright (c) 2011 Monitoring Plugins Development Team
7* Author: Sebastian 'tokkee' Harl <sh@teamix.net> 7* Author: Sebastian 'tokkee' Harl <sh@teamix.net>
8* 8*
9* Description: 9* Description:
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_dbi"; 32const char *progname = "check_dbi";
33const char *copyright = "2011"; 33const char *copyright = "2011";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "utils.h" 37#include "utils.h"
@@ -215,7 +215,7 @@ main (int argc, char **argv)
215 } 215 }
216 216
217 if (dbi_conn_connect (conn) < 0) { 217 if (dbi_conn_connect (conn) < 0) {
218 np_dbi_print_error (conn, "UNKOWN - failed to connect to database"); 218 np_dbi_print_error (conn, "UNKNOWN - failed to connect to database");
219 return STATE_UNKNOWN; 219 return STATE_UNKNOWN;
220 } 220 }
221 221
@@ -241,7 +241,7 @@ main (int argc, char **argv)
241 printf ("Selecting database '%s'\n", np_dbi_database); 241 printf ("Selecting database '%s'\n", np_dbi_database);
242 242
243 if (dbi_conn_select_db (conn, np_dbi_database)) { 243 if (dbi_conn_select_db (conn, np_dbi_database)) {
244 np_dbi_print_error (conn, "UNKOWN - failed to select database '%s'", 244 np_dbi_print_error (conn, "UNKNOWN - failed to select database '%s'",
245 np_dbi_database); 245 np_dbi_database);
246 return STATE_UNKNOWN; 246 return STATE_UNKNOWN;
247 } 247 }
@@ -456,7 +456,7 @@ process_arguments (int argc, char **argv)
456 new = realloc (np_dbi_options, 456 new = realloc (np_dbi_options,
457 (np_dbi_options_num + 1) * sizeof (*new)); 457 (np_dbi_options_num + 1) * sizeof (*new));
458 if (! new) { 458 if (! new) {
459 printf ("UNKOWN - failed to reallocate memory\n"); 459 printf ("UNKNOWN - failed to reallocate memory\n");
460 exit (STATE_UNKNOWN); 460 exit (STATE_UNKNOWN);
461 } 461 }
462 462
@@ -562,7 +562,7 @@ print_help (void)
562 printf (" %s\n", _("(ignore the query result)")); 562 printf (" %s\n", _("(ignore the query result)"));
563 printf ("\n"); 563 printf ("\n");
564 564
565 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 565 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
566 566
567 printf (UT_VERBOSE); 567 printf (UT_VERBOSE);
568 568
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index c113d87b..d9481f2d 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_dig plugin 3* Monitoring check_dig plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2002-2008 Nagios Plugins Development Team 6* Copyright (c) 2002-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -34,7 +34,7 @@
34 34
35const char *progname = "check_dig"; 35const char *progname = "check_dig";
36const char *copyright = "2002-2008"; 36const char *copyright = "2002-2008";
37const char *email = "nagiosplug-devel@lists.sourceforge.net"; 37const char *email = "devel@monitoring-plugins.org";
38 38
39#include "common.h" 39#include "common.h"
40#include "netutils.h" 40#include "netutils.h"
@@ -48,6 +48,7 @@ void print_usage (void);
48 48
49#define UNDEFINED 0 49#define UNDEFINED 0
50#define DEFAULT_PORT 53 50#define DEFAULT_PORT 53
51#define DEFAULT_TRIES 3
51 52
52char *query_address = NULL; 53char *query_address = NULL;
53char *record_type = "A"; 54char *record_type = "A";
@@ -57,6 +58,7 @@ char *dig_args = "";
57char *query_transport = ""; 58char *query_transport = "";
58int verbose = FALSE; 59int verbose = FALSE;
59int server_port = DEFAULT_PORT; 60int server_port = DEFAULT_PORT;
61int number_tries = DEFAULT_TRIES;
60double warning_interval = UNDEFINED; 62double warning_interval = UNDEFINED;
61double critical_interval = UNDEFINED; 63double critical_interval = UNDEFINED;
62struct timeval tv; 64struct timeval tv;
@@ -72,6 +74,7 @@ main (int argc, char **argv)
72 long microsec; 74 long microsec;
73 double elapsed_time; 75 double elapsed_time;
74 int result = STATE_UNKNOWN; 76 int result = STATE_UNKNOWN;
77 int timeout_interval_dig;
75 78
76 setlocale (LC_ALL, ""); 79 setlocale (LC_ALL, "");
77 bindtextdomain (PACKAGE, LOCALEDIR); 80 bindtextdomain (PACKAGE, LOCALEDIR);
@@ -87,9 +90,12 @@ main (int argc, char **argv)
87 if (process_arguments (argc, argv) == ERROR) 90 if (process_arguments (argc, argv) == ERROR)
88 usage_va(_("Could not parse arguments")); 91 usage_va(_("Could not parse arguments"));
89 92
93 /* dig applies the timeout to each try, so we need to work around this */
94 timeout_interval_dig = timeout_interval / number_tries + number_tries;
95
90 /* get the command to run */ 96 /* get the command to run */
91 xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s", 97 xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s +tries=%d +time=%d",
92 PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport); 98 PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport, number_tries, timeout_interval_dig);
93 99
94 alarm (timeout_interval); 100 alarm (timeout_interval);
95 gettimeofday (&tv, NULL); 101 gettimeofday (&tv, NULL);
@@ -348,7 +354,7 @@ print_help (void)
348 printf (" %s\n","-A, --dig-arguments=STRING"); 354 printf (" %s\n","-A, --dig-arguments=STRING");
349 printf (" %s\n",_("Pass STRING as argument(s) to dig")); 355 printf (" %s\n",_("Pass STRING as argument(s) to dig"));
350 printf (UT_WARN_CRIT); 356 printf (UT_WARN_CRIT);
351 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 357 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
352 printf (UT_VERBOSE); 358 printf (UT_VERBOSE);
353 359
354 printf ("\n"); 360 printf ("\n");
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 04d588fb..925dfa82 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_disk plugin 3* Monitoring check_disk plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2008 Nagios Plugins Development Team 6* Copyright (c) 1999-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -29,7 +29,7 @@
29const char *progname = "check_disk"; 29const char *progname = "check_disk";
30const char *program_name = "check_disk"; /* Required for coreutils libs */ 30const char *program_name = "check_disk"; /* Required for coreutils libs */
31const char *copyright = "1999-2008"; 31const char *copyright = "1999-2008";
32const char *email = "nagiosplug-devel@lists.sourceforge.net"; 32const char *email = "devel@monitoring-plugins.org";
33 33
34 34
35#include "common.h" 35#include "common.h"
@@ -52,6 +52,11 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
52#endif 52#endif
53#include "regex.h" 53#include "regex.h"
54 54
55#ifdef __CYGWIN__
56# include <windows.h>
57# undef ERROR
58# define ERROR -1
59#endif
55 60
56/* If nonzero, show inode information. */ 61/* If nonzero, show inode information. */
57static int inode_format = 1; 62static int inode_format = 1;
@@ -175,6 +180,10 @@ main (int argc, char **argv)
175 struct fs_usage fsp, tmpfsp; 180 struct fs_usage fsp, tmpfsp;
176 struct parameter_list *temp_list, *path; 181 struct parameter_list *temp_list, *path;
177 182
183#ifdef __CYGWIN__
184 char mountdir[32];
185#endif
186
178 preamble = strdup (" - free space:"); 187 preamble = strdup (" - free space:");
179 output = strdup (""); 188 output = strdup ("");
180 details = strdup (""); 189 details = strdup ("");
@@ -221,7 +230,6 @@ main (int argc, char **argv)
221 230
222 /* Process for every path in list */ 231 /* Process for every path in list */
223 for (path = path_select_list; path; path=path->name_next) { 232 for (path = path_select_list; path; path=path->name_next) {
224
225 if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL) 233 if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL)
226 printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end, 234 printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end,
227 path->freespace_percent->critical->end); 235 path->freespace_percent->critical->end);
@@ -234,6 +242,13 @@ main (int argc, char **argv)
234 242
235 me = path->best_match; 243 me = path->best_match;
236 244
245#ifdef __CYGWIN__
246 if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11)
247 continue;
248 snprintf(mountdir, sizeof(mountdir), "%s:\\", me->me_mountdir + 10);
249 if (GetDriveType(mountdir) != DRIVE_FIXED)
250 me->me_remote = 1;
251#endif
237 /* Filters */ 252 /* Filters */
238 253
239 /* Remove filesystems already seen */ 254 /* Remove filesystems already seen */
@@ -877,7 +892,7 @@ print_help (void)
877 printf (" %s\n", "-K, --icritical=PERCENT%"); 892 printf (" %s\n", "-K, --icritical=PERCENT%");
878 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of inode space is free")); 893 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of inode space is free"));
879 printf (" %s\n", "-p, --path=PATH, --partition=PARTITION"); 894 printf (" %s\n", "-p, --path=PATH, --partition=PARTITION");
880 printf (" %s\n", _("Path or partition (may be repeated)")); 895 printf (" %s\n", _("Mount point or block device as emitted by the mount(8) command (may be repeated)"));
881 printf (" %s\n", "-x, --exclude_device=PATH <STRING>"); 896 printf (" %s\n", "-x, --exclude_device=PATH <STRING>");
882 printf (" %s\n", _("Ignore device (only works if -p unspecified)")); 897 printf (" %s\n", _("Ignore device (only works if -p unspecified)"));
883 printf (" %s\n", "-C, --clear"); 898 printf (" %s\n", "-C, --clear");
@@ -911,7 +926,7 @@ print_help (void)
911 printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)")); 926 printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)"));
912 printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION"); 927 printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION");
913 printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)")); 928 printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)"));
914 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 929 printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
915 printf (" %s\n", "-u, --units=STRING"); 930 printf (" %s\n", "-u, --units=STRING");
916 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); 931 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
917 printf (UT_VERBOSE); 932 printf (UT_VERBOSE);
@@ -970,6 +985,10 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
970 } else { 985 } else {
971 /* find all group members */ 986 /* find all group members */
972 for (p_list = path_select_list; p_list; p_list=p_list->name_next) { 987 for (p_list = path_select_list; p_list; p_list=p_list->name_next) {
988#ifdef __CYGWIN__
989 if (strncmp(p_list->name, "/cygdrive/", 10) != 0)
990 continue;
991#endif
973 if (p_list->group && ! (strcmp(p_list->group, p->group))) { 992 if (p_list->group && ! (strcmp(p_list->group, p->group))) {
974 stat_path(p_list); 993 stat_path(p_list);
975 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); 994 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp);
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index ac6cfc38..31a953d7 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_dns plugin 3* Monitoring check_dns plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2008 Nagios Plugins Development Team 6* Copyright (c) 2000-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_dns"; 32const char *progname = "check_dns";
33const char *copyright = "2000-2008"; 33const char *copyright = "2000-2008";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "utils.h" 37#include "utils.h"
@@ -242,7 +242,23 @@ main (int argc, char **argv)
242 } 242 }
243 printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time); 243 printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
244 printf (_(". %s returns %s"), query_address, address); 244 printf (_(". %s returns %s"), query_address, address);
245 printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); 245 if ((time_thresholds->warning != NULL) && (time_thresholds->critical != NULL)) {
246 printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
247 TRUE, time_thresholds->warning->end,
248 TRUE, time_thresholds->critical->end,
249 TRUE, 0, FALSE, 0));
250 } else if ((time_thresholds->warning == NULL) && (time_thresholds->critical != NULL)) {
251 printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
252 FALSE, 0,
253 TRUE, time_thresholds->critical->end,
254 TRUE, 0, FALSE, 0));
255 } else if ((time_thresholds->warning != NULL) && (time_thresholds->critical == NULL)) {
256 printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
257 TRUE, time_thresholds->warning->end,
258 FALSE, 0,
259 TRUE, 0, FALSE, 0));
260 } else
261 printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
246 } 262 }
247 else if (result == STATE_WARNING) 263 else if (result == STATE_WARNING)
248 printf (_("DNS WARNING - %s\n"), 264 printf (_("DNS WARNING - %s\n"),
@@ -474,7 +490,7 @@ print_help (void)
474 printf (" -c, --critical=seconds\n"); 490 printf (" -c, --critical=seconds\n");
475 printf (" %s\n", _("Return critical if elapsed time exceeds value. Default off")); 491 printf (" %s\n", _("Return critical if elapsed time exceeds value. Default off"));
476 492
477 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 493 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
478 494
479 printf (UT_SUPPORT); 495 printf (UT_SUPPORT);
480} 496}
diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c
index 3cfc9ede..3ed68717 100644
--- a/plugins/check_dummy.c
+++ b/plugins/check_dummy.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_dummy plugin 3* Monitoring check_dummy plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Nagios Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_dummy"; 31const char *progname = "check_dummy";
32const char *copyright = "1999-2007"; 32const char *copyright = "1999-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "utils.h" 36#include "utils.h"
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index dad000e6..46046b4f 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_fping plugin 3* Monitoring check_fping plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_fping"; 32const char *progname = "check_fping";
33const char *copyright = "2000-2007"; 33const char *copyright = "2000-2007";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "popen.h" 37#include "popen.h"
diff --git a/plugins/check_game.c b/plugins/check_game.c
index 89bb4b12..29e59e2f 100644
--- a/plugins/check_game.c
+++ b/plugins/check_game.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_game plugin 3* Monitoring check_game plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2002-2007 Nagios Plugins Development Team 6* Copyright (c) 2002-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_game"; 32const char *progname = "check_game";
33const char *copyright = "2002-2007"; 33const char *copyright = "2002-2007";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "utils.h" 37#include "utils.h"
@@ -312,7 +312,7 @@ print_help (void)
312 printf (" %s\n", "-pf"); 312 printf (" %s\n", "-pf");
313 printf (" %s\n", _("Field number in raw qstat output that contains ping time")); 313 printf (" %s\n", _("Field number in raw qstat output that contains ping time"));
314 314
315 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 315 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
316 316
317 printf ("\n"); 317 printf ("\n");
318 printf ("%s\n", _("Notes:")); 318 printf ("%s\n", _("Notes:"));
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 60e922ed..1e7605ba 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_hpjd plugin 3* Monitoring check_hpjd plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_hpjd"; 32const char *progname = "check_hpjd";
33const char *copyright = "2000-2007"; 33const char *copyright = "2000-2007";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "popen.h" 37#include "popen.h"
diff --git a/plugins/check_http.c b/plugins/check_http.c
index c36d916a..51679975 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_http plugin 3* Monitoring check_http plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2013 Nagios Plugins Development Team 6* Copyright (c) 1999-2013 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -35,7 +35,7 @@
35 35
36const char *progname = "check_http"; 36const char *progname = "check_http";
37const char *copyright = "1999-2013"; 37const char *copyright = "1999-2013";
38const char *email = "nagiosplug-devel@lists.sourceforge.net"; 38const char *email = "devel@monitoring-plugins.org";
39 39
40#include "common.h" 40#include "common.h"
41#include "netutils.h" 41#include "netutils.h"
@@ -57,7 +57,7 @@ enum {
57 57
58#ifdef HAVE_SSL 58#ifdef HAVE_SSL
59int check_cert = FALSE; 59int check_cert = FALSE;
60int ssl_version; 60int ssl_version = 0;
61int days_till_exp_warn, days_till_exp_crit; 61int days_till_exp_warn, days_till_exp_crit;
62char *randbuff; 62char *randbuff;
63X509 *server_cert; 63X509 *server_cert;
@@ -157,7 +157,7 @@ main (int argc, char **argv)
157 /* Set default URL. Must be malloced for subsequent realloc if --onredirect=follow */ 157 /* Set default URL. Must be malloced for subsequent realloc if --onredirect=follow */
158 server_url = strdup(HTTP_URL); 158 server_url = strdup(HTTP_URL);
159 server_url_length = strlen(server_url); 159 server_url_length = strlen(server_url);
160 xasprintf (&user_agent, "User-Agent: check_http/v%s (nagios-plugins %s)", 160 xasprintf (&user_agent, "User-Agent: check_http/v%s (monitoring-plugins %s)",
161 NP_VERSION, VERSION); 161 NP_VERSION, VERSION);
162 162
163 /* Parse extra opts if any */ 163 /* Parse extra opts if any */
@@ -257,7 +257,7 @@ process_arguments (int argc, char **argv)
257 } 257 }
258 258
259 while (1) { 259 while (1) {
260 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:N:E", longopts, &option); 260 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NE", longopts, &option);
261 if (c == -1 || c == EOF) 261 if (c == -1 || c == EOF)
262 break; 262 break;
263 263
@@ -339,10 +339,10 @@ process_arguments (int argc, char **argv)
339 case 'S': /* use SSL */ 339 case 'S': /* use SSL */
340#ifdef HAVE_SSL 340#ifdef HAVE_SSL
341 enable_ssl: 341 enable_ssl:
342 /* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple
343 parameters, like -S and -C combinations */
342 use_ssl = TRUE; 344 use_ssl = TRUE;
343 if (optarg == NULL || c != 'S') 345 if (c=='S' && optarg != NULL) {
344 ssl_version = 0;
345 else {
346 ssl_version = atoi(optarg); 346 ssl_version = atoi(optarg);
347 if (ssl_version < 1 || ssl_version > 3) 347 if (ssl_version < 1 || ssl_version > 3)
348 usage4 (_("Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 (SSLv3)")); 348 usage4 (_("Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 (SSLv3)"));
@@ -1243,6 +1243,7 @@ redir (char *pos, char *status_line)
1243 if (addr == NULL) 1243 if (addr == NULL)
1244 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate addr\n")); 1244 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate addr\n"));
1245 1245
1246 memset(addr, 0, MAX_IPV4_HOSTLENGTH);
1246 url = malloc (strcspn (pos, "\r\n")); 1247 url = malloc (strcspn (pos, "\r\n"));
1247 if (url == NULL) 1248 if (url == NULL)
1248 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate URL\n")); 1249 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate URL\n"));
@@ -1333,8 +1334,8 @@ redir (char *pos, char *status_line)
1333 max_depth, type, addr, i, url, (display_html ? "</A>" : "")); 1334 max_depth, type, addr, i, url, (display_html ? "</A>" : ""));
1334 1335
1335 if (server_port==i && 1336 if (server_port==i &&
1336 !strcmp(server_address, addr) && 1337 !strncmp(server_address, addr, MAX_IPV4_HOSTLENGTH) &&
1337 (host_name && !strcmp(host_name, addr)) && 1338 (host_name && !strncmp(host_name, addr, MAX_IPV4_HOSTLENGTH)) &&
1338 !strcmp(server_url, url)) 1339 !strcmp(server_url, url))
1339 die (STATE_WARNING, 1340 die (STATE_WARNING,
1340 _("HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"), 1341 _("HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"),
@@ -1343,11 +1344,11 @@ redir (char *pos, char *status_line)
1343 strcpy (server_type, type); 1344 strcpy (server_type, type);
1344 1345
1345 free (host_name); 1346 free (host_name);
1346 host_name = strdup (addr); 1347 host_name = strndup (addr, MAX_IPV4_HOSTLENGTH);
1347 1348
1348 if (!(followsticky & STICKY_HOST)) { 1349 if (!(followsticky & STICKY_HOST)) {
1349 free (server_address); 1350 free (server_address);
1350 server_address = strdup (addr); 1351 server_address = strndup (addr, MAX_IPV4_HOSTLENGTH);
1351 } 1352 }
1352 if (!(followsticky & STICKY_PORT)) { 1353 if (!(followsticky & STICKY_PORT)) {
1353 server_port = i; 1354 server_port = i;
@@ -1366,6 +1367,7 @@ redir (char *pos, char *status_line)
1366 printf (_("Redirection to %s://%s:%d%s\n"), server_type, 1367 printf (_("Redirection to %s://%s:%d%s\n"), server_type,
1367 host_name ? host_name : server_address, server_port, server_url); 1368 host_name ? host_name : server_address, server_port, server_url);
1368 1369
1370 free(addr);
1369 check_http (); 1371 check_http ();
1370} 1372}
1371 1373
@@ -1534,7 +1536,7 @@ print_help (void)
1534 1536
1535 printf (UT_WARN_CRIT); 1537 printf (UT_WARN_CRIT);
1536 1538
1537 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1539 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1538 1540
1539 printf (UT_VERBOSE); 1541 printf (UT_VERBOSE);
1540 1542
diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c
index 0a8009ab..47605e96 100644
--- a/plugins/check_ide_smart.c
+++ b/plugins/check_ide_smart.c
@@ -1,13 +1,13 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_ide_smart plugin 3* Monitoring check_ide_smart plugin
4* ide-smart 1.3 - IDE S.M.A.R.T. checking tool 4* ide-smart 1.3 - IDE S.M.A.R.T. checking tool
5* 5*
6* License: GPL 6* License: GPL
7* Copyright (C) 1998-1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org> 7* Copyright (C) 1998-1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>
8* 1998 Gadi Oxman <gadio@netvision.net.il> 8* 1998 Gadi Oxman <gadio@netvision.net.il>
9* Copyright (c) 2000 Robert Dale <rdale@digital-mission.com> 9* Copyright (c) 2000 Robert Dale <rdale@digital-mission.com>
10* Copyright (c) 2000-2007 Nagios Plugins Development Team 10* Copyright (c) 2000-2007 Monitoring Plugins Development Team
11* 11*
12* Description: 12* Description:
13* 13*
@@ -35,7 +35,7 @@
35 35
36const char *progname = "check_ide_smart"; 36const char *progname = "check_ide_smart";
37const char *copyright = "1998-2007"; 37const char *copyright = "1998-2007";
38const char *email = "nagiosplug-devel@lists.sourceforge.net"; 38const char *email = "devel@monitoring-plugins.org";
39 39
40#include "common.h" 40#include "common.h"
41#include "utils.h" 41#include "utils.h"
@@ -172,12 +172,12 @@ void print_value (value_t *, threshold_t *);
172void print_values (values_t *, thresholds_t *); 172void print_values (values_t *, thresholds_t *);
173int smart_cmd_simple (int, enum SmartCommand, __u8, char); 173int smart_cmd_simple (int, enum SmartCommand, __u8, char);
174int smart_read_thresholds (int, thresholds_t *); 174int smart_read_thresholds (int, thresholds_t *);
175int verbose = FALSE;
175 176
176int 177int
177main (int argc, char *argv[]) 178main (int argc, char *argv[])
178{ 179{
179 char *device = NULL; 180 char *device = NULL;
180 int command = -1;
181 int o, longindex; 181 int o, longindex;
182 int retval = 0; 182 int retval = 0;
183 183
@@ -191,7 +191,7 @@ main (int argc, char *argv[])
191 {"quiet-check", no_argument, 0, 'q'}, 191 {"quiet-check", no_argument, 0, 'q'},
192 {"auto-on", no_argument, 0, '1'}, 192 {"auto-on", no_argument, 0, '1'},
193 {"auto-off", no_argument, 0, '0'}, 193 {"auto-off", no_argument, 0, '0'},
194 {"nagios", no_argument, 0, 'n'}, 194 {"nagios", no_argument, 0, 'n'}, /* DEPRECATED, but we still accept it */
195 {"help", no_argument, 0, 'h'}, 195 {"help", no_argument, 0, 'h'},
196 {"version", no_argument, 0, 'V'}, 196 {"version", no_argument, 0, 'V'},
197 {0, 0, 0, 0} 197 {0, 0, 0, 0}
@@ -206,7 +206,7 @@ main (int argc, char *argv[])
206 206
207 while (1) { 207 while (1) {
208 208
209 o = getopt_long (argc, argv, "+d:iq10nhV", longopts, &longindex); 209 o = getopt_long (argc, argv, "+d:iq10nhVv", longopts, &longindex);
210 210
211 if (o == -1 || o == EOF || o == 1) 211 if (o == -1 || o == EOF || o == 1)
212 break; 212 break;
@@ -216,19 +216,21 @@ main (int argc, char *argv[])
216 device = optarg; 216 device = optarg;
217 break; 217 break;
218 case 'q': 218 case 'q':
219 command = 3; 219 fprintf (stderr, "%s\n", _("DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."));
220 fprintf (stderr, "%s\n", _("Nagios-compatible output is now always returned."));
220 break; 221 break;
221 case 'i': 222 case 'i':
222 command = 2;
223 break;
224 case '1': 223 case '1':
225 command = 1;
226 break;
227 case '0': 224 case '0':
228 command = 0; 225 printf ("%s\n", _("SMART commands are broken and have been disabled (See Notes in --help)."));
226 return STATE_CRITICAL;
229 break; 227 break;
230 case 'n': 228 case 'n':
231 command = 4; 229 fprintf (stderr, "%s\n", _("DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"));
230 fprintf (stderr, "%s\n", _("default and will be removed from future releases."));
231 break;
232 case 'v': /* verbose */
233 verbose = TRUE;
232 break; 234 break;
233 case 'h': 235 case 'h':
234 print_help (); 236 print_help ();
@@ -257,37 +259,16 @@ main (int argc, char *argv[])
257 return STATE_CRITICAL; 259 return STATE_CRITICAL;
258 } 260 }
259 261
260 if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, TRUE)) { 262 if (smart_cmd_simple (fd, SMART_CMD_ENABLE, 0, FALSE)) {
261 printf (_("CRITICAL - SMART_CMD_ENABLE\n")); 263 printf (_("CRITICAL - SMART_CMD_ENABLE\n"));
262 return STATE_CRITICAL; 264 return STATE_CRITICAL;
263 } 265 }
264 266
265 switch (command) { 267 smart_read_values (fd, &values);
266 case 0: 268 smart_read_thresholds (fd, &thresholds);
267 retval = smart_cmd_simple (fd, SMART_CMD_AUTO_OFFLINE, 0, TRUE); 269 retval = nagios (&values, &thresholds);
268 break; 270 if (verbose) print_values (&values, &thresholds);
269 case 1: 271
270 retval = smart_cmd_simple (fd, SMART_CMD_AUTO_OFFLINE, 0xF8, TRUE);
271 break;
272 case 2:
273 retval = smart_cmd_simple (fd, SMART_CMD_IMMEDIATE_OFFLINE, 0, TRUE);
274 break;
275 case 3:
276 smart_read_values (fd, &values);
277 smart_read_thresholds (fd, &thresholds);
278 retval = values_not_passed (&values, &thresholds);
279 break;
280 case 4:
281 smart_read_values (fd, &values);
282 smart_read_thresholds (fd, &thresholds);
283 retval = nagios (&values, &thresholds);
284 break;
285 default:
286 smart_read_values (fd, &values);
287 smart_read_thresholds (fd, &thresholds);
288 print_values (&values, &thresholds);
289 break;
290 }
291 close (fd); 272 close (fd);
292 return retval; 273 return retval;
293} 274}
@@ -368,7 +349,7 @@ values_not_passed (values_t * p, thresholds_t * t)
368 int i; 349 int i;
369 for (i = 0; i < NR_ATTRIBUTES; i++) { 350 for (i = 0; i < NR_ATTRIBUTES; i++) {
370 if (value->id && threshold->id && value->id == threshold->id) { 351 if (value->id && threshold->id && value->id == threshold->id) {
371 if (value->value <= threshold->threshold) { 352 if (value->value < threshold->threshold) {
372 ++failed; 353 ++failed;
373 } 354 }
374 else { 355 else {
@@ -397,7 +378,7 @@ nagios (values_t * p, thresholds_t * t)
397 int i; 378 int i;
398 for (i = 0; i < NR_ATTRIBUTES; i++) { 379 for (i = 0; i < NR_ATTRIBUTES; i++) {
399 if (value->id && threshold->id && value->id == threshold->id) { 380 if (value->id && threshold->id && value->id == threshold->id) {
400 if (value->value <= threshold->threshold) { 381 if (value->value < threshold->threshold) {
401 ++failed; 382 ++failed;
402 if (value->status & 1) { 383 if (value->status & 1) {
403 status = PREFAILURE; 384 status = PREFAILURE;
@@ -438,7 +419,7 @@ nagios (values_t * p, thresholds_t * t)
438 status=STATE_OK; 419 status=STATE_OK;
439 break; 420 break;
440 default: 421 default:
441 printf (_("ERROR - Status '%d' unkown. %d/%d tests passed\n"), status, 422 printf (_("ERROR - Status '%d' unknown. %d/%d tests passed\n"), status,
442 passed, total); 423 passed, total);
443 status = STATE_UNKNOWN; 424 status = STATE_UNKNOWN;
444 break; 425 break;
@@ -454,7 +435,7 @@ print_value (value_t * p, threshold_t * t)
454 printf ("Id=%3d, Status=%2d {%s , %s}, Value=%3d, Threshold=%3d, %s\n", 435 printf ("Id=%3d, Status=%2d {%s , %s}, Value=%3d, Threshold=%3d, %s\n",
455 p->id, p->status, p->status & 1 ? "PreFailure" : "Advisory ", 436 p->id, p->status, p->status & 1 ? "PreFailure" : "Advisory ",
456 p->status & 2 ? "OnLine " : "OffLine", p->value, t->threshold, 437 p->status & 2 ? "OnLine " : "OffLine", p->value, t->threshold,
457 p->value > t->threshold ? "Passed" : "Failed"); 438 p->value >= t->threshold ? "Passed" : "Failed");
458} 439}
459 440
460 441
@@ -495,7 +476,7 @@ print_values (values_t * p, thresholds_t * t)
495int 476int
496smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error) 477smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error)
497{ 478{
498 int e = 0; 479 int e = STATE_UNKNOWN;
499#ifdef __linux__ 480#ifdef __linux__
500 __u8 args[4]; 481 __u8 args[4];
501 args[0] = WIN_SMART; 482 args[0] = WIN_SMART;
@@ -503,11 +484,15 @@ smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error)
503 args[2] = smart_command[command].value; 484 args[2] = smart_command[command].value;
504 args[3] = 0; 485 args[3] = 0;
505 if (ioctl (fd, HDIO_DRIVE_CMD, &args)) { 486 if (ioctl (fd, HDIO_DRIVE_CMD, &args)) {
506 e = errno; 487 e = STATE_CRITICAL;
507 if (show_error) { 488 if (show_error)
508 printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno)); 489 printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno));
509 } 490 } else {
491 e = STATE_OK;
492 if (show_error)
493 printf (_("OK - Command sent (%s)\n"), smart_command[command].text);
510 } 494 }
495
511#endif /* __linux__ */ 496#endif /* __linux__ */
512#ifdef __NetBSD__ 497#ifdef __NetBSD__
513 struct atareq req; 498 struct atareq req;
@@ -528,10 +513,15 @@ smart_cmd_simple (int fd, enum SmartCommand command, __u8 val0, char show_error)
528 } 513 }
529 514
530 if (errno != 0) { 515 if (errno != 0) {
531 e = errno; 516 e = STATE_CRITICAL;
532 printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno)); 517 if (show_error)
533 return e; 518 printf (_("CRITICAL - %s: %s\n"), smart_command[command].text, strerror (errno));
519 } else {
520 e = STATE_OK;
521 if (show_error)
522 printf (_("OK - Command sent (%s)\n"), smart_command[command].text);
534 } 523 }
524
535#endif /* __NetBSD__ */ 525#endif /* __NetBSD__ */
536 return e; 526 return e;
537} 527}
@@ -592,8 +582,8 @@ print_help (void)
592{ 582{
593 print_revision (progname, NP_VERSION); 583 print_revision (progname, NP_VERSION);
594 584
595 printf ("Nagios feature - 1999 Robert Dale <rdale@digital-mission.com>\n");
596 printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n"); 585 printf ("(C) 1999 Ragnar Hojland Espinosa <ragnar@lightside.dhis.org>\n");
586 printf ("Plugin implementation - 1999 Robert Dale <rdale@digital-mission.com>\n");
597 printf (COPYRIGHT, copyright, email); 587 printf (COPYRIGHT, copyright, email);
598 588
599 printf (_("This plugin checks a local hard drive with the (Linux specific) SMART interface [http://smartlinux.sourceforge.net/smart/index.php].")); 589 printf (_("This plugin checks a local hard drive with the (Linux specific) SMART interface [http://smartlinux.sourceforge.net/smart/index.php]."));
@@ -607,17 +597,19 @@ print_help (void)
607 597
608 printf (" %s\n", "-d, --device=DEVICE"); 598 printf (" %s\n", "-d, --device=DEVICE");
609 printf (" %s\n", _("Select device DEVICE")); 599 printf (" %s\n", _("Select device DEVICE"));
610 printf (" %s\n", _("Note: if the device is selected with this option, _no_ other options are accepted")); 600 printf (" %s\n", _("Note: if the device is specified without this option, any further option will"));
611 printf (" %s\n", "-i, --immediate"); 601 printf (" %s\n", _("be ignored."));
612 printf (" %s\n", _("Perform immediately offline tests")); 602
613 printf (" %s\n", "-q, --quiet-check"); 603 printf (UT_VERBOSE);
614 printf (" %s\n", _("Returns the number of failed tests")); 604
615 printf (" %s\n", "-1, --auto-on"); 605 printf ("\n");
616 printf (" %s\n", _("Turn on automatic offline tests")); 606 printf ("%s\n", _("Notes:"));
617 printf (" %s\n", "-0, --auto-off"); 607 printf (" %s\n", _("The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"));
618 printf (" %s\n", _("Turn off automatic offline tests")); 608 printf (" %s\n", _("broken in an underhand manner and have been disabled. You can use smartctl"));
619 printf (" %s\n", "-n, --nagios"); 609 printf (" %s\n", _("instead:"));
620 printf (" %s\n", _("Output suitable for Nagios")); 610 printf (" %s\n", _("-0/--auto-off: use \"smartctl --offlineauto=off\""));
611 printf (" %s\n", _("-1/--auto-on: use \"smartctl --offlineauto=on\""));
612 printf (" %s\n", _("-i/--immediate: use \"smartctl --test=offline\""));
621 613
622 printf (UT_SUPPORT); 614 printf (UT_SUPPORT);
623} 615}
@@ -638,6 +630,5 @@ void
638print_usage (void) 630print_usage (void)
639{ 631{
640 printf ("%s\n", _("Usage:")); 632 printf ("%s\n", _("Usage:"));
641 printf ("%s [-d <device>] [-i <immediate>] [-q quiet] [-1 <auto-on>]",progname); 633 printf ("%s [-d <device>] [-v]", progname);
642 printf (" [-O <auto-off>] [-n <nagios>]\n");
643} 634}
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index b05aca9a..c371be97 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_ldap plugin 3* Monitoring check_ldap plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2008 Nagios Plugins Development Team 6* Copyright (c) 2000-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -29,7 +29,7 @@
29/* progname may be check_ldaps */ 29/* progname may be check_ldaps */
30char *progname = "check_ldap"; 30char *progname = "check_ldap";
31const char *copyright = "2000-2008"; 31const char *copyright = "2000-2008";
32const char *email = "nagiosplug-devel@lists.sourceforge.net"; 32const char *email = "devel@monitoring-plugins.org";
33 33
34#include "common.h" 34#include "common.h"
35#include "netutils.h" 35#include "netutils.h"
@@ -430,7 +430,7 @@ print_help (void)
430 430
431 printf (UT_WARN_CRIT); 431 printf (UT_WARN_CRIT);
432 432
433 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 433 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
434 434
435 printf (UT_VERBOSE); 435 printf (UT_VERBOSE);
436 436
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 296a8233..cde63e56 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_load plugin 3* Monitoring check_load plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Nagios Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_load"; 31const char *progname = "check_load";
32const char *copyright = "1999-2007"; 32const char *copyright = "1999-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "utils.h" 36#include "utils.h"
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c
index d6162f35..cf3fe044 100644
--- a/plugins/check_mrtg.c
+++ b/plugins/check_mrtg.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_mrtg plugin 3* Monitoring check_mrtg plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Nagios Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_mrtg"; 32const char *progname = "check_mrtg";
33const char *copyright = "1999-2007"; 33const char *copyright = "1999-2007";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "utils.h" 37#include "utils.h"
@@ -356,7 +356,7 @@ print_help (void)
356 printf (" %s\n", _("This plugin is useful for monitoring MRTG data that does not correspond to")); 356 printf (" %s\n", _("This plugin is useful for monitoring MRTG data that does not correspond to"));
357 printf (" %s\n", _("bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth).")); 357 printf (" %s\n", _("bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."));
358 printf (" %s\n", _("It can be used to monitor any kind of data that MRTG is monitoring - errors,")); 358 printf (" %s\n", _("It can be used to monitor any kind of data that MRTG is monitoring - errors,"));
359 printf (" %s\n", _("packets/sec, etc. I use MRTG in conjuction with the Novell NLM that allows")); 359 printf (" %s\n", _("packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"));
360 printf (" %s\n", _("me to track processor utilization, user connections, drive space, etc and")); 360 printf (" %s\n", _("me to track processor utilization, user connections, drive space, etc and"));
361 printf (" %s\n\n", _("this plugin works well for monitoring that kind of data as well.")); 361 printf (" %s\n\n", _("this plugin works well for monitoring that kind of data as well."));
362 362
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c
index a8226514..32ba0507 100644
--- a/plugins/check_mrtgtraf.c
+++ b/plugins/check_mrtgtraf.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_mrtgtraf plugin 3* Monitoring check_mrtgtraf plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Nagios Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -34,7 +34,7 @@
34 34
35const char *progname = "check_mrtgtraf"; 35const char *progname = "check_mrtgtraf";
36const char *copyright = "1999-2007"; 36const char *copyright = "1999-2007";
37const char *email = "nagiosplug-devel@lists.sourceforge.net"; 37const char *email = "devel@monitoring-plugins.org";
38 38
39int process_arguments (int, char **); 39int process_arguments (int, char **);
40int validate_arguments (void); 40int validate_arguments (void);
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index db670e2d..4f09e5f8 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -1,11 +1,11 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_mysql plugin 3* Monitoring check_mysql plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at) 6* Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)
7* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) 7* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
8* Copyright (c) 1999-2011 Nagios Plugins Development Team 8* Copyright (c) 1999-2011 Monitoring Plugins Development Team
9* 9*
10* Description: 10* Description:
11* 11*
@@ -32,7 +32,7 @@
32 32
33const char *progname = "check_mysql"; 33const char *progname = "check_mysql";
34const char *copyright = "1999-2011"; 34const char *copyright = "1999-2011";
35const char *email = "nagiosplug-devel@lists.sourceforge.net"; 35const char *email = "devel@monitoring-plugins.org";
36 36
37#define SLAVERESULTSIZE 70 37#define SLAVERESULTSIZE 70
38 38
@@ -476,12 +476,6 @@ validate_arguments (void)
476 if (db_user == NULL) 476 if (db_user == NULL)
477 db_user = strdup(""); 477 db_user = strdup("");
478 478
479 if (opt_file == NULL)
480 opt_file = strdup("");
481
482 if (opt_group == NULL)
483 opt_group = strdup("");
484
485 if (db_host == NULL) 479 if (db_host == NULL)
486 db_host = strdup(""); 480 db_host = strdup("");
487 481
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index 0bb83c3e..71ab7768 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_mysql_query plugin 3* Monitoring check_mysql_query plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2006-2009 Nagios Plugins Development Team 6* Copyright (c) 2006-2009 Monitoring Plugins Development Team
7* Original code from check_mysql, copyright 1999 Didi Rieder 7* Original code from check_mysql, copyright 1999 Didi Rieder
8* 8*
9* Description: 9* Description:
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_mysql_query"; 32const char *progname = "check_mysql_query";
33const char *copyright = "1999-2007"; 33const char *copyright = "1999-2007";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "utils.h" 37#include "utils.h"
@@ -46,6 +46,8 @@ char *db_host = NULL;
46char *db_socket = NULL; 46char *db_socket = NULL;
47char *db_pass = NULL; 47char *db_pass = NULL;
48char *db = NULL; 48char *db = NULL;
49char *opt_file = NULL;
50char *opt_group = NULL;
49unsigned int db_port = MYSQL_PORT; 51unsigned int db_port = MYSQL_PORT;
50 52
51int process_arguments (int, char **); 53int process_arguments (int, char **);
@@ -83,7 +85,13 @@ main (int argc, char **argv)
83 /* initialize mysql */ 85 /* initialize mysql */
84 mysql_init (&mysql); 86 mysql_init (&mysql);
85 87
86 mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client"); 88 if (opt_file != NULL)
89 mysql_options(&mysql,MYSQL_READ_DEFAULT_FILE,opt_file);
90
91 if (opt_group != NULL)
92 mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,opt_group);
93 else
94 mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client");
87 95
88 /* establish a connection to the server and error checking */ 96 /* establish a connection to the server and error checking */
89 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { 97 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
@@ -152,7 +160,13 @@ main (int argc, char **argv)
152 } else if (status == STATE_CRITICAL) { 160 } else if (status == STATE_CRITICAL) {
153 printf("QUERY %s: ", _("CRITICAL")); 161 printf("QUERY %s: ", _("CRITICAL"));
154 } 162 }
155 printf(_("'%s' returned %f"), sql_query, value); 163 printf(_("'%s' returned %f | %s"), sql_query, value,
164 fperfdata("result", value, "",
165 my_thresholds->warning?TRUE:FALSE, my_thresholds->warning?my_thresholds->warning->end:0,
166 my_thresholds->critical?TRUE:FALSE, my_thresholds->critical?my_thresholds->critical->end:0,
167 FALSE, 0,
168 FALSE, 0)
169 );
156 printf("\n"); 170 printf("\n");
157 171
158 return status; 172 return status;
@@ -174,6 +188,8 @@ process_arguments (int argc, char **argv)
174 {"database", required_argument, 0, 'd'}, 188 {"database", required_argument, 0, 'd'},
175 {"username", required_argument, 0, 'u'}, 189 {"username", required_argument, 0, 'u'},
176 {"password", required_argument, 0, 'p'}, 190 {"password", required_argument, 0, 'p'},
191 {"file", required_argument, 0, 'f'},
192 {"group", required_argument, 0, 'g'},
177 {"port", required_argument, 0, 'P'}, 193 {"port", required_argument, 0, 'P'},
178 {"verbose", no_argument, 0, 'v'}, 194 {"verbose", no_argument, 0, 'v'},
179 {"version", no_argument, 0, 'V'}, 195 {"version", no_argument, 0, 'V'},
@@ -188,7 +204,7 @@ process_arguments (int argc, char **argv)
188 return ERROR; 204 return ERROR;
189 205
190 while (1) { 206 while (1) {
191 c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:", longopts, &option); 207 c = getopt_long (argc, argv, "hvVP:p:u:d:H:s:q:w:c:f:g:", longopts, &option);
192 208
193 if (c == -1 || c == EOF) 209 if (c == -1 || c == EOF)
194 break; 210 break;
@@ -220,6 +236,12 @@ process_arguments (int argc, char **argv)
220 optarg++; 236 optarg++;
221 } 237 }
222 break; 238 break;
239 case 'f': /* client options file */
240 opt_file = optarg;
241 break;
242 case 'g': /* client options group */
243 opt_group = optarg;
244 break;
223 case 'P': /* critical time threshold */ 245 case 'P': /* critical time threshold */
224 db_port = atoi (optarg); 246 db_port = atoi (optarg);
225 break; 247 break;
@@ -299,6 +321,10 @@ print_help (void)
299 printf (" %s\n", _("Use the specified socket (has no effect if -H is used)")); 321 printf (" %s\n", _("Use the specified socket (has no effect if -H is used)"));
300 printf (" -d, --database=STRING\n"); 322 printf (" -d, --database=STRING\n");
301 printf (" %s\n", _("Database to check")); 323 printf (" %s\n", _("Database to check"));
324 printf (" %s\n", "-f, --file=STRING");
325 printf (" %s\n", _("Read from the specified client options file"));
326 printf (" %s\n", "-g, --group=STRING");
327 printf (" %s\n", _("Use a client options group"));
302 printf (" -u, --username=STRING\n"); 328 printf (" -u, --username=STRING\n");
303 printf (" %s\n", _("Username to login with")); 329 printf (" %s\n", _("Username to login with"));
304 printf (" -p, --password=STRING\n"); 330 printf (" -p, --password=STRING\n");
@@ -324,5 +350,5 @@ print_usage (void)
324{ 350{
325 printf ("%s\n", _("Usage:")); 351 printf ("%s\n", _("Usage:"));
326 printf (" %s -q SQL_query [-w warn] [-c crit] [-H host] [-P port] [-s socket]\n",progname); 352 printf (" %s -q SQL_query [-w warn] [-c crit] [-H host] [-P port] [-s socket]\n",progname);
327 printf (" [-d database] [-u user] [-p password]\n"); 353 printf (" [-d database] [-u user] [-p password] [-f optfile] [-g group]\n");
328} 354}
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c
index 4fd6342d..791b6dbe 100644
--- a/plugins/check_nagios.c
+++ b/plugins/check_nagios.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_nagios plugin 3* Monitoring check_nagios plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Nagios Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -34,7 +34,7 @@
34 34
35const char *progname = "check_nagios"; 35const char *progname = "check_nagios";
36const char *copyright = "1999-2007"; 36const char *copyright = "1999-2007";
37const char *email = "nagiosplug-devel@lists.sourceforge.net"; 37const char *email = "devel@monitoring-plugins.org";
38 38
39#include "common.h" 39#include "common.h"
40#include "runcmd.h" 40#include "runcmd.h"
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 52bbd1c5..fefbfb7a 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -1,10 +1,10 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_nt plugin 3* Monitoring check_nt plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2002 Yves Rubin (rubiyz@yahoo.com) 6* Copyright (c) 2000-2002 Yves Rubin (rubiyz@yahoo.com)
7* Copyright (c) 2003-2007 Nagios Plugins Development Team 7* Copyright (c) 2003-2007 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
@@ -34,7 +34,7 @@
34 34
35const char *progname = "check_nt"; 35const char *progname = "check_nt";
36const char *copyright = "2000-2007"; 36const char *copyright = "2000-2007";
37const char *email = "nagiosplug-devel@lists.sourceforge.net"; 37const char *email = "devel@monitoring-plugins.org";
38 38
39#include "common.h" 39#include "common.h"
40#include "netutils.h" 40#include "netutils.h"
@@ -203,7 +203,7 @@ int main(int argc, char **argv){
203 updays = uptime / 86400; 203 updays = uptime / 86400;
204 uphours = (uptime % 86400) / 3600; 204 uphours = (uptime % 86400) / 3600;
205 upminutes = ((uptime % 86400) % 3600) / 60; 205 upminutes = ((uptime % 86400) % 3600) / 60;
206 xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes); 206 xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)|uptime=%lu"), updays, uphours, upminutes, uptime);
207 if (check_critical_value==TRUE && uptime <= critical_value) 207 if (check_critical_value==TRUE && uptime <= critical_value)
208 return_code=STATE_CRITICAL; 208 return_code=STATE_CRITICAL;
209 else if (check_warning_value==TRUE && uptime <= warning_value) 209 else if (check_warning_value==TRUE && uptime <= warning_value)
@@ -293,10 +293,10 @@ int main(int argc, char **argv){
293 293
294 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here, 294 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
295 which equals RAM + Pagefiles. */ 295 which equals RAM + Pagefiles. */
296 xasprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"), 296 xasprintf(&output_message,_("Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"),
297 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space, 297 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
298 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); 298 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
299 xasprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567, 299 xasprintf(&perfdata,_("'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
300 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567); 300 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
301 301
302 return_code=STATE_OK; 302 return_code=STATE_OK;
@@ -750,7 +750,7 @@ void print_help(void)
750 printf (" %s\n", _("The purpose of this is to be run from command line to determine what instances")); 750 printf (" %s\n", _("The purpose of this is to be run from command line to determine what instances"));
751 printf (" %s\n", _(" are available for monitoring without having to log onto the Windows server")); 751 printf (" %s\n", _(" are available for monitoring without having to log onto the Windows server"));
752 printf (" %s\n", _(" to run Perfmon directly.")); 752 printf (" %s\n", _(" to run Perfmon directly."));
753 printf (" %s\n", _("It can also be used in scripts that automatically create Nagios service")); 753 printf (" %s\n", _("It can also be used in scripts that automatically create the monitoring service"));
754 printf (" %s\n", _(" configuration files.")); 754 printf (" %s\n", _(" configuration files."));
755 printf (" %s\n", _("Some examples:")); 755 printf (" %s\n", _("Some examples:"));
756 printf (" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process")); 756 printf (" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"));
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 16be7c51..09a923eb 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -1,10 +1,10 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_ntp plugin 3* Monitoring check_ntp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2006 Sean Finney <seanius@seanius.net> 6* Copyright (c) 2006 Sean Finney <seanius@seanius.net>
7* Copyright (c) 2006-2008 Nagios Plugins Development Team 7* Copyright (c) 2006-2008 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
@@ -32,7 +32,7 @@
32 32
33const char *progname = "check_ntp"; 33const char *progname = "check_ntp";
34const char *copyright = "2006-2008"; 34const char *copyright = "2006-2008";
35const char *email = "nagiosplug-devel@lists.sourceforge.net"; 35const char *email = "devel@monitoring-plugins.org";
36 36
37#include "common.h" 37#include "common.h"
38#include "netutils.h" 38#include "netutils.h"
@@ -54,7 +54,9 @@ void print_help (void);
54void print_usage (void); 54void print_usage (void);
55 55
56/* number of times to perform each request to get a good average. */ 56/* number of times to perform each request to get a good average. */
57#ifndef AVG_NUM
57#define AVG_NUM 4 58#define AVG_NUM 4
59#endif
58 60
59/* max size of control message data */ 61/* max size of control message data */
60#define MAX_CM_SIZE 468 62#define MAX_CM_SIZE 468
@@ -480,7 +482,7 @@ double offset_request(const char *host, int *status){
480 } else { 482 } else {
481 /* finally, calculate the average offset */ 483 /* finally, calculate the average offset */
482 for(i=0; i<servers[best_index].num_responses;i++){ 484 for(i=0; i<servers[best_index].num_responses;i++){
483 avg_offset+=servers[best_index].offset[j]; 485 avg_offset+=servers[best_index].offset[i];
484 } 486 }
485 avg_offset/=servers[best_index].num_responses; 487 avg_offset/=servers[best_index].num_responses;
486 } 488 }
@@ -515,13 +517,14 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
515double jitter_request(const char *host, int *status){ 517double jitter_request(const char *host, int *status){
516 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0; 518 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
517 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0; 519 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
518 int peers_size=0, peer_offset=0; 520 int peers_size=0, peer_offset=0, bytes_read=0;
519 ntp_assoc_status_pair *peers=NULL; 521 ntp_assoc_status_pair *peers=NULL;
520 ntp_control_message req; 522 ntp_control_message req;
521 const char *getvar = "jitter"; 523 const char *getvar = "jitter";
522 double rval = 0.0, jitter = -1.0; 524 double rval = 0.0, jitter = -1.0;
523 char *startofvalue=NULL, *nptr=NULL; 525 char *startofvalue=NULL, *nptr=NULL;
524 void *tmp; 526 void *tmp;
527 int ntp_cm_ints = sizeof(uint16_t) * 5 + sizeof(uint8_t) * 2;
525 528
526 /* Long-winded explanation: 529 /* Long-winded explanation:
527 * Getting the jitter requires a number of steps: 530 * Getting the jitter requires a number of steps:
@@ -606,7 +609,15 @@ double jitter_request(const char *host, int *status){
606 609
607 req.count = htons(MAX_CM_SIZE); 610 req.count = htons(MAX_CM_SIZE);
608 DBG(printf("recieving READVAR response...\n")); 611 DBG(printf("recieving READVAR response...\n"));
609 read(conn, &req, SIZEOF_NTPCM(req)); 612
613 /* cov-66524 - req.data not null terminated before usage. Also covers verifying struct was returned correctly*/
614 if ((bytes_read = read(conn, &req, SIZEOF_NTPCM(req))) == -1)
615 die(STATE_UNKNOWN, _("Cannot read from socket: %s"), strerror(errno));
616 if (bytes_read != ntp_cm_ints + req.count)
617 die(STATE_UNKNOWN, _("Invalid NTP response: %d bytes read does not equal %d plus %d data segment"), bytes_read, ntp_cm_ints, req.count);
618 /* else null terminate */
619 strncpy(req.data[req.count], "\0", 1);
620
610 DBG(print_ntp_control_message(&req)); 621 DBG(print_ntp_control_message(&req));
611 622
612 if(req.op&REM_ERROR && strstr(getvar, "jitter")) { 623 if(req.op&REM_ERROR && strstr(getvar, "jitter")) {
@@ -858,7 +869,7 @@ void print_help(void){
858 printf (" %s\n", _("Warning threshold for jitter")); 869 printf (" %s\n", _("Warning threshold for jitter"));
859 printf (" %s\n", "-k, --jcrit=THRESHOLD"); 870 printf (" %s\n", "-k, --jcrit=THRESHOLD");
860 printf (" %s\n", _("Critical threshold for jitter")); 871 printf (" %s\n", _("Critical threshold for jitter"));
861 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 872 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
862 printf (UT_VERBOSE); 873 printf (UT_VERBOSE);
863 874
864 printf("\n"); 875 printf("\n");
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index 76152e17..8dc19788 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -1,10 +1,10 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_ntp_peer plugin 3* Monitoring check_ntp_peer plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2006 Sean Finney <seanius@seanius.net> 6* Copyright (c) 2006 Sean Finney <seanius@seanius.net>
7* Copyright (c) 2006-2008 Nagios Plugins Development Team 7* Copyright (c) 2006-2008 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
@@ -37,7 +37,7 @@
37 37
38const char *progname = "check_ntp_peer"; 38const char *progname = "check_ntp_peer";
39const char *copyright = "2006-2008"; 39const char *copyright = "2006-2008";
40const char *email = "nagiosplug-devel@lists.sourceforge.net"; 40const char *email = "devel@monitoring-plugins.org";
41 41
42#include "common.h" 42#include "common.h"
43#include "netutils.h" 43#include "netutils.h"
@@ -686,7 +686,7 @@ void print_help(void){
686 printf (" %s\n", _("Warning threshold for number of usable time sources (\"truechimers\")")); 686 printf (" %s\n", _("Warning threshold for number of usable time sources (\"truechimers\")"));
687 printf (" %s\n", "-n, --tcrit=THRESHOLD"); 687 printf (" %s\n", "-n, --tcrit=THRESHOLD");
688 printf (" %s\n", _("Critical threshold for number of usable time sources (\"truechimers\")")); 688 printf (" %s\n", _("Critical threshold for number of usable time sources (\"truechimers\")"));
689 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 689 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
690 printf (UT_VERBOSE); 690 printf (UT_VERBOSE);
691 691
692 printf("\n"); 692 printf("\n");
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index bbcaa0ba..72dffbd8 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -1,10 +1,10 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_ntp_time plugin 3* Monitoring check_ntp_time plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2006 Sean Finney <seanius@seanius.net> 6* Copyright (c) 2006 Sean Finney <seanius@seanius.net>
7* Copyright (c) 2006-2008 Nagios Plugins Development Team 7* Copyright (c) 2006-2008 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
@@ -36,7 +36,7 @@
36 36
37const char *progname = "check_ntp_time"; 37const char *progname = "check_ntp_time";
38const char *copyright = "2006-2008"; 38const char *copyright = "2006-2008";
39const char *email = "nagiosplug-devel@lists.sourceforge.net"; 39const char *email = "devel@monitoring-plugins.org";
40 40
41#include "common.h" 41#include "common.h"
42#include "netutils.h" 42#include "netutils.h"
@@ -55,7 +55,9 @@ void print_help (void);
55void print_usage (void); 55void print_usage (void);
56 56
57/* number of times to perform each request to get a good average. */ 57/* number of times to perform each request to get a good average. */
58#ifndef AVG_NUM
58#define AVG_NUM 4 59#define AVG_NUM 4
60#endif
59 61
60/* max size of control message data */ 62/* max size of control message data */
61#define MAX_CM_SIZE 468 63#define MAX_CM_SIZE 468
@@ -426,7 +428,7 @@ double offset_request(const char *host, int *status){
426 } else { 428 } else {
427 /* finally, calculate the average offset */ 429 /* finally, calculate the average offset */
428 for(i=0; i<servers[best_index].num_responses;i++){ 430 for(i=0; i<servers[best_index].num_responses;i++){
429 avg_offset+=servers[best_index].offset[j]; 431 avg_offset+=servers[best_index].offset[i];
430 } 432 }
431 avg_offset/=servers[best_index].num_responses; 433 avg_offset/=servers[best_index].num_responses;
432 } 434 }
@@ -614,7 +616,7 @@ void print_help(void){
614 printf (" %s\n", _("Offset to result in warning status (seconds)")); 616 printf (" %s\n", _("Offset to result in warning status (seconds)"));
615 printf (" %s\n", "-c, --critical=THRESHOLD"); 617 printf (" %s\n", "-c, --critical=THRESHOLD");
616 printf (" %s\n", _("Offset to result in critical status (seconds)")); 618 printf (" %s\n", _("Offset to result in critical status (seconds)"));
617 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 619 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
618 printf (UT_VERBOSE); 620 printf (UT_VERBOSE);
619 621
620 printf("\n"); 622 printf("\n");
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index 6ebe8f83..1a7bfa16 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_nwstat plugin 3* Monitoring check_nwstat plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_nwstat"; 32const char *progname = "check_nwstat";
33const char *copyright = "2000-2007"; 33const char *copyright = "2000-2007";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "netutils.h" 37#include "netutils.h"
@@ -1664,7 +1664,7 @@ void print_help(void)
1664 printf (" %s\n", "-o, --osversion"); 1664 printf (" %s\n", "-o, --osversion");
1665 printf (" %s\n", _("Include server version string in results")); 1665 printf (" %s\n", _("Include server version string in results"));
1666 1666
1667 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1667 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1668 1668
1669 printf ("\n"); 1669 printf ("\n");
1670 printf ("%s\n", _("Notes:")); 1670 printf ("%s\n", _("Notes:"));
diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c
index 95977e91..af5eb9b9 100644
--- a/plugins/check_overcr.c
+++ b/plugins/check_overcr.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_overcr plugin 3* Monitoring check_overcr plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,7 +31,7 @@
31 31
32const char *progname = "check_overcr"; 32const char *progname = "check_overcr";
33const char *copyright = "2000-2007"; 33const char *copyright = "2000-2007";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#include "common.h" 36#include "common.h"
37#include "netutils.h" 37#include "netutils.h"
@@ -442,7 +442,7 @@ print_help (void)
442 printf (" %s\n", _("NET<port> = number of active connections on TCP port <port>")); 442 printf (" %s\n", _("NET<port> = number of active connections on TCP port <port>"));
443 printf (" %s\n", _("UPTIME = system uptime in seconds")); 443 printf (" %s\n", _("UPTIME = system uptime in seconds"));
444 444
445 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 445 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
446 446
447 printf (UT_VERBOSE); 447 printf (UT_VERBOSE);
448 448
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index 324bd5f4..9bad1ec5 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_pgsql plugin 3* Monitoring check_pgsql plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2011 Nagios Plugins Development Team 6* Copyright (c) 1999-2011 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_pgsql"; 31const char *progname = "check_pgsql";
32const char *copyright = "1999-2011"; 32const char *copyright = "1999-2011";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "utils.h" 36#include "utils.h"
@@ -514,7 +514,7 @@ print_help (void)
514 514
515 printf (" %s\n", "-d, --database=STRING"); 515 printf (" %s\n", "-d, --database=STRING");
516 printf (" %s", _("Database to check ")); 516 printf (" %s", _("Database to check "));
517 printf (_("(default: %s)"), DEFAULT_DB); 517 printf (_("(default: %s)\n"), DEFAULT_DB);
518 printf (" %s\n", "-l, --logname = STRING"); 518 printf (" %s\n", "-l, --logname = STRING");
519 printf (" %s\n", _("Login name of user")); 519 printf (" %s\n", _("Login name of user"));
520 printf (" %s\n", "-p, --password = STRING"); 520 printf (" %s\n", "-p, --password = STRING");
@@ -524,7 +524,7 @@ print_help (void)
524 524
525 printf (UT_WARN_CRIT); 525 printf (UT_WARN_CRIT);
526 526
527 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 527 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
528 528
529 printf (" %s\n", "-q, --query=STRING"); 529 printf (" %s\n", "-q, --query=STRING");
530 printf (" %s\n", _("SQL query to run. Only first column in first row will be read")); 530 printf (" %s\n", _("SQL query to run. Only first column in first row will be read"));
@@ -563,7 +563,7 @@ print_help (void)
563 printf (" %s\n", _("connect to a remote host, be sure that the remote postmaster accepts TCP/IP")); 563 printf (" %s\n", _("connect to a remote host, be sure that the remote postmaster accepts TCP/IP"));
564 printf (" %s\n\n", _("connections (start the postmaster with the -i option).")); 564 printf (" %s\n\n", _("connections (start the postmaster with the -i option)."));
565 565
566 printf (" %s\n", _("Typically, the nagios user (unless the --logname option is used) should be")); 566 printf (" %s\n", _("Typically, the monitoring user (unless the --logname option is used) should be"));
567 printf (" %s\n", _("able to connect to the database without a password. The plugin can also send")); 567 printf (" %s\n", _("able to connect to the database without a password. The plugin can also send"));
568 printf (" %s\n", _("a password, but no effort is made to obsure or encrypt the password.")); 568 printf (" %s\n", _("a password, but no effort is made to obsure or encrypt the password."));
569 569
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index eef2195b..dbc5c3e4 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_ping plugin 3* Monitoring check_ping plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_ping"; 31const char *progname = "check_ping";
32const char *copyright = "2000-2007"; 32const char *copyright = "2000-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "netutils.h" 36#include "netutils.h"
@@ -458,7 +458,8 @@ run_ping (const char *cmd, const char *addr)
458 (sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time%n",&pl,&match) && match) || 458 (sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time%n",&pl,&match) && match) ||
459 (sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time%n",&pl,&match) && match) || 459 (sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time%n",&pl,&match) && match) ||
460 (sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) || 460 (sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
461 (sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) 461 (sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
462 (sscanf(buf,"%*[^(](%d%% %*[^)])%n",&pl,&match) && match)
462 ) 463 )
463 continue; 464 continue;
464 465
@@ -471,7 +472,9 @@ run_ping (const char *cmd, const char *addr)
471 (sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f%n",&rta,&match) && match) || 472 (sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
472 (sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f%n",&rta,&match) && match) || 473 (sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f%n",&rta,&match) && match) ||
473 (sscanf(buf,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f%n",&rta,&match) && match) || 474 (sscanf(buf,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
474 (sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms%n",&rta,&match) && match)) 475 (sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms%n",&rta,&match) && match) ||
476 (sscanf(buf, "%*[^=] = %*fms, %*[^=] = %*fms, %*[^=] = %fms%n", &rta, &match) && match)
477 )
475 continue; 478 continue;
476 } 479 }
477 480
@@ -482,7 +485,11 @@ run_ping (const char *cmd, const char *addr)
482 /* check stderr, setting at least WARNING if there is output here */ 485 /* check stderr, setting at least WARNING if there is output here */
483 /* Add warning into warn_text */ 486 /* Add warning into warn_text */
484 while (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) { 487 while (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) {
485 if (! strstr(buf,"WARNING - no SO_TIMESTAMP support, falling back to SIOCGSTAMP")) { 488 if (
489 ! strstr(buf,"WARNING - no SO_TIMESTAMP support, falling back to SIOCGSTAMP")
490 && ! strstr(buf,"Warning: time of day goes back")
491
492 ) {
486 if (verbose >= 3) { 493 if (verbose >= 3) {
487 printf("Got stderr: %s", buf); 494 printf("Got stderr: %s", buf);
488 } 495 }
@@ -581,7 +588,7 @@ print_help (void)
581 printf (" %s\n", "-L, --link"); 588 printf (" %s\n", "-L, --link");
582 printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)")); 589 printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)"));
583 590
584 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 591 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
585 592
586 printf ("\n"); 593 printf ("\n");
587 printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel")); 594 printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"));
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index d20b027f..402aac53 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_procs plugin 3* Monitoring check_procs plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2008 Nagios Plugins Development Team 6* Copyright (c) 2000-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -34,7 +34,7 @@
34const char *progname = "check_procs"; 34const char *progname = "check_procs";
35const char *program_name = "check_procs"; /* Required for coreutils libs */ 35const char *program_name = "check_procs"; /* Required for coreutils libs */
36const char *copyright = "2000-2008"; 36const char *copyright = "2000-2008";
37const char *email = "nagiosplug-devel@lists.sourceforge.net"; 37const char *email = "devel@monitoring-plugins.org";
38 38
39#include "common.h" 39#include "common.h"
40#include "utils.h" 40#include "utils.h"
@@ -123,6 +123,7 @@ main (int argc, char **argv)
123 char *procprog; 123 char *procprog;
124 124
125 pid_t mypid = 0; 125 pid_t mypid = 0;
126 pid_t myppid = 0;
126 struct stat statbuf; 127 struct stat statbuf;
127 dev_t mydev = 0; 128 dev_t mydev = 0;
128 ino_t myino = 0; 129 ino_t myino = 0;
@@ -172,6 +173,7 @@ main (int argc, char **argv)
172 173
173 /* find ourself */ 174 /* find ourself */
174 mypid = getpid(); 175 mypid = getpid();
176 myppid = getppid();
175 if (usepid || stat_exe(mypid, &statbuf) == -1) { 177 if (usepid || stat_exe(mypid, &statbuf) == -1) {
176 /* usepid might have been set by -T */ 178 /* usepid might have been set by -T */
177 usepid = 1; 179 usepid = 1;
@@ -241,6 +243,12 @@ main (int argc, char **argv)
241 printf("not considering - is myself or gone\n"); 243 printf("not considering - is myself or gone\n");
242 continue; 244 continue;
243 } 245 }
246 /* Ignore parent*/
247 else if (myppid == procpid) {
248 if (verbose >= 3)
249 printf("not considering - is parent\n");
250 continue;
251 }
244 252
245 /* filter kernel threads (childs of KTHREAD_PARENT)*/ 253 /* filter kernel threads (childs of KTHREAD_PARENT)*/
246 /* TODO adapt for other OSes than GNU/Linux 254 /* TODO adapt for other OSes than GNU/Linux
@@ -707,7 +715,7 @@ print_help (void)
707#if defined( __linux__ ) 715#if defined( __linux__ )
708 printf (" %s\n", _("ELAPSED - time elapsed in seconds")); 716 printf (" %s\n", _("ELAPSED - time elapsed in seconds"));
709#endif /* defined(__linux__) */ 717#endif /* defined(__linux__) */
710 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 718 printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
711 719
712 printf (" %s\n", "-v, --verbose"); 720 printf (" %s\n", "-v, --verbose");
713 printf (" %s\n", _("Extra information. Up to 3 verbosity levels")); 721 printf (" %s\n", _("Extra information. Up to 3 verbosity levels"));
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index e54105b0..b2943475 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_radius plugin 3* Monitoring check_radius plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2008 Nagios Plugins Development Team 6* Copyright (c) 1999-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,15 +30,16 @@
30 30
31const char *progname = "check_radius"; 31const char *progname = "check_radius";
32const char *copyright = "2000-2008"; 32const char *copyright = "2000-2008";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "utils.h" 36#include "utils.h"
37#include "netutils.h" 37#include "netutils.h"
38 38
39#ifdef HAVE_LIBRADIUSCLIENT_NG 39#if defined(HAVE_LIBFREERADIUS_CLIENT)
40#include <freeradius-client.h>
41#elif defined(HAVE_LIBRADIUSCLIENT_NG)
40#include <radiusclient-ng.h> 42#include <radiusclient-ng.h>
41rc_handle *rch = NULL;
42#else 43#else
43#include <radiusclient.h> 44#include <radiusclient.h>
44#endif 45#endif
@@ -47,11 +48,14 @@ int process_arguments (int, char **);
47void print_help (void); 48void print_help (void);
48void print_usage (void); 49void print_usage (void);
49 50
50/* libradiusclient(-ng) wrapper functions */ 51#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
51#ifdef HAVE_LIBRADIUSCLIENT_NG
52#define my_rc_conf_str(a) rc_conf_str(rch,a) 52#define my_rc_conf_str(a) rc_conf_str(rch,a)
53#define my_rc_send_server(a,b) rc_send_server(rch,a,b) 53#define my_rc_send_server(a,b) rc_send_server(rch,a,b)
54#ifdef HAVE_LIBFREERADIUS_CLIENT
55#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,(a)->secret,e,f)
56#else
54#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f) 57#define my_rc_buildreq(a,b,c,d,e,f) rc_buildreq(rch,a,b,c,d,e,f)
58#endif
55#define my_rc_own_ipaddress() rc_own_ipaddress(rch) 59#define my_rc_own_ipaddress() rc_own_ipaddress(rch)
56#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d) 60#define my_rc_avpair_add(a,b,c,d) rc_avpair_add(rch,a,b,c,-1,d)
57#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a) 61#define my_rc_read_dictionary(a) rc_read_dictionary(rch, a)
@@ -72,6 +76,10 @@ void print_usage (void);
72 76
73int my_rc_read_config(char *); 77int my_rc_read_config(char *);
74 78
79#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
80rc_handle *rch = NULL;
81#endif
82
75char *server = NULL; 83char *server = NULL;
76char *username = NULL; 84char *username = NULL;
77char *password = NULL; 85char *password = NULL;
@@ -142,11 +150,10 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
142int 150int
143main (int argc, char **argv) 151main (int argc, char **argv)
144{ 152{
145 UINT4 service;
146 char msg[BUFFER_LEN]; 153 char msg[BUFFER_LEN];
147 SEND_DATA data; 154 SEND_DATA data;
148 int result = STATE_UNKNOWN; 155 int result = STATE_UNKNOWN;
149 UINT4 client_id; 156 uint32_t client_id, service;
150 char *str; 157 char *str;
151 158
152 setlocale (LC_ALL, ""); 159 setlocale (LC_ALL, "");
@@ -162,7 +169,7 @@ main (int argc, char **argv)
162 str = strdup ("dictionary"); 169 str = strdup ("dictionary");
163 if ((config_file && my_rc_read_config (config_file)) || 170 if ((config_file && my_rc_read_config (config_file)) ||
164 my_rc_read_dictionary (my_rc_conf_str (str))) 171 my_rc_read_dictionary (my_rc_conf_str (str)))
165 die (STATE_UNKNOWN, _("Config file error")); 172 die (STATE_UNKNOWN, _("Config file error\n"));
166 173
167 service = PW_AUTHENTICATE_ONLY; 174 service = PW_AUTHENTICATE_ONLY;
168 175
@@ -171,24 +178,24 @@ main (int argc, char **argv)
171 my_rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) && 178 my_rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
172 my_rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0) 179 my_rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0)
173 )) 180 ))
174 die (STATE_UNKNOWN, _("Out of Memory?")); 181 die (STATE_UNKNOWN, _("Out of Memory?\n"));
175 182
176 if (nasid != NULL) { 183 if (nasid != NULL) {
177 if (!(my_rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0))) 184 if (!(my_rc_avpair_add (&data.send_pairs, PW_NAS_IDENTIFIER, nasid, 0)))
178 die (STATE_UNKNOWN, _("Invalid NAS-Identifier")); 185 die (STATE_UNKNOWN, _("Invalid NAS-Identifier\n"));
179 } 186 }
180 187
181 if (nasipaddress != NULL) { 188 if (nasipaddress != NULL) {
182 if (rc_good_ipaddr (nasipaddress)) 189 if (rc_good_ipaddr (nasipaddress))
183 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address")); 190 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
184 if ((client_id = rc_get_ipaddr(nasipaddress)) == 0) 191 if ((client_id = rc_get_ipaddr(nasipaddress)) == 0)
185 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address")); 192 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
186 } else { 193 } else {
187 if ((client_id = my_rc_own_ipaddress ()) == 0) 194 if ((client_id = my_rc_own_ipaddress ()) == 0)
188 die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address")); 195 die (STATE_UNKNOWN, _("Can't find local IP for NAS-IP-Address\n"));
189 } 196 }
190 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL) 197 if (my_rc_avpair_add (&(data.send_pairs), PW_NAS_IP_ADDRESS, &client_id, 0) == NULL)
191 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address")); 198 die (STATE_UNKNOWN, _("Invalid NAS-IP-Address\n"));
192 199
193 my_rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval, 200 my_rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
194 retries); 201 retries);
@@ -199,19 +206,19 @@ main (int argc, char **argv)
199 rc_avpair_free (data.receive_pairs); 206 rc_avpair_free (data.receive_pairs);
200 207
201 if (result == TIMEOUT_RC) 208 if (result == TIMEOUT_RC)
202 die (STATE_CRITICAL, _("Timeout")); 209 die (STATE_CRITICAL, _("Timeout\n"));
203 if (result == ERROR_RC) 210 if (result == ERROR_RC)
204 die (STATE_CRITICAL, _("Auth Error")); 211 die (STATE_CRITICAL, _("Auth Error\n"));
205 if (result == REJECT_RC) 212 if (result == REJECT_RC)
206 die (STATE_WARNING, _("Auth Failed")); 213 die (STATE_WARNING, _("Auth Failed\n"));
207 if (result == BADRESP_RC) 214 if (result == BADRESP_RC)
208 die (STATE_WARNING, _("Bad Response")); 215 die (STATE_WARNING, _("Bad Response\n"));
209 if (expect && !strstr (msg, expect)) 216 if (expect && !strstr (msg, expect))
210 die (STATE_WARNING, "%s", msg); 217 die (STATE_WARNING, "%s\n", msg);
211 if (result == OK_RC) 218 if (result == OK_RC)
212 die (STATE_OK, _("Auth OK")); 219 die (STATE_OK, _("Auth OK\n"));
213 (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result); 220 (void)snprintf(msg, sizeof(msg), _("Unexpected result code %d"), result);
214 die (STATE_UNKNOWN, "%s", msg); 221 die (STATE_UNKNOWN, "%s\n", msg);
215} 222}
216 223
217 224
@@ -361,7 +368,7 @@ print_help (void)
361 printf (" %s\n", "-r, --retries=INTEGER"); 368 printf (" %s\n", "-r, --retries=INTEGER");
362 printf (" %s\n", _("Number of times to retry a failed connection")); 369 printf (" %s\n", _("Number of times to retry a failed connection"));
363 370
364 printf (UT_TIMEOUT, timeout_interval); 371 printf (UT_CONN_TIMEOUT, timeout_interval);
365 372
366 printf ("\n"); 373 printf ("\n");
367 printf ("%s\n", _("This plugin tests a RADIUS server to see if it is accepting connections.")); 374 printf ("%s\n", _("This plugin tests a RADIUS server to see if it is accepting connections."));
@@ -370,8 +377,8 @@ print_help (void)
370 printf ("%s\n", _("the configuration file is described in the radiusclient library sources.")); 377 printf ("%s\n", _("the configuration file is described in the radiusclient library sources."));
371 printf ("%s\n", _("The password option presents a substantial security issue because the")); 378 printf ("%s\n", _("The password option presents a substantial security issue because the"));
372 printf ("%s\n", _("password can possibly be determined by careful watching of the command line")); 379 printf ("%s\n", _("password can possibly be determined by careful watching of the command line"));
373 printf ("%s\n", _("in a process listing. This risk is exacerbated because nagios will")); 380 printf ("%s\n", _("in a process listing. This risk is exacerbated because the plugin will"));
374 printf ("%s\n", _("run the plugin at regular predictable intervals. Please be sure that")); 381 printf ("%s\n", _("typically be executed at regular predictable intervals. Please be sure that"));
375 printf ("%s\n", _("the password used does not allow access to sensitive system resources.")); 382 printf ("%s\n", _("the password used does not allow access to sensitive system resources."));
376 383
377 printf (UT_SUPPORT); 384 printf (UT_SUPPORT);
@@ -392,7 +399,7 @@ print_usage (void)
392 399
393int my_rc_read_config(char * a) 400int my_rc_read_config(char * a)
394{ 401{
395#ifdef HAVE_LIBRADIUSCLIENT_NG 402#if defined(HAVE_LIBFREERADIUS_CLIENT) || defined(HAVE_LIBRADIUSCLIENT_NG)
396 rch = rc_read_config(a); 403 rch = rc_read_config(a);
397 return (rch == NULL) ? 1 : 0; 404 return (rch == NULL) ? 1 : 0;
398#else 405#else
diff --git a/plugins/check_real.c b/plugins/check_real.c
index 18240f30..36f64134 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_real plugin 3* Monitoring check_real plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_real"; 31const char *progname = "check_real";
32const char *copyright = "2000-2007"; 32const char *copyright = "2000-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "netutils.h" 36#include "netutils.h"
@@ -178,6 +178,7 @@ main (int argc, char **argv)
178 178
179 /* watch for the REAL connection string */ 179 /* watch for the REAL connection string */
180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0); 180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
181 buffer[result] = "\0"; /* null terminate recieved buffer */
181 182
182 /* return a CRITICAL status if we couldn't read any data */ 183 /* return a CRITICAL status if we couldn't read any data */
183 if (result == -1) { 184 if (result == -1) {
@@ -429,7 +430,7 @@ print_help (void)
429 430
430 printf (UT_WARN_CRIT); 431 printf (UT_WARN_CRIT);
431 432
432 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 433 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
433 434
434 printf (UT_VERBOSE); 435 printf (UT_VERBOSE);
435 436
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index d477a51e..24304534 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_smtp plugin 3* Monitoring check_smtp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_smtp"; 31const char *progname = "check_smtp";
32const char *copyright = "2000-2007"; 32const char *copyright = "2000-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "netutils.h" 36#include "netutils.h"
@@ -822,7 +822,7 @@ print_help (void)
822 822
823 printf (UT_WARN_CRIT); 823 printf (UT_WARN_CRIT);
824 824
825 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 825 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
826 826
827 printf (UT_VERBOSE); 827 printf (UT_VERBOSE);
828 828
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 52ad31ea..2c62a230 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_snmp plugin 3* Monitoring check_snmp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Nagios Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_snmp"; 31const char *progname = "check_snmp";
32const char *copyright = "1999-2007"; 32const char *copyright = "1999-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "runcmd.h" 36#include "runcmd.h"
@@ -459,7 +459,7 @@ main (int argc, char **argv)
459 /* Process this block for numeric comparisons */ 459 /* Process this block for numeric comparisons */
460 /* Make some special values,like Timeticks numeric only if a threshold is defined */ 460 /* Make some special values,like Timeticks numeric only if a threshold is defined */
461 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) { 461 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
462 ptr = strpbrk (show, "0123456789"); 462 ptr = strpbrk (show, "-0123456789");
463 if (ptr == NULL) 463 if (ptr == NULL)
464 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); 464 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
465 while (i >= response_size) { 465 while (i >= response_size) {
@@ -963,11 +963,16 @@ validate_arguments ()
963 if (seclevel == NULL) 963 if (seclevel == NULL)
964 xasprintf(&seclevel, "noAuthNoPriv"); 964 xasprintf(&seclevel, "noAuthNoPriv");
965 965
966 if (secname == NULL)
967 die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname");
968
966 if (strcmp(seclevel, "noAuthNoPriv") == 0) { 969 if (strcmp(seclevel, "noAuthNoPriv") == 0) {
967 numauthpriv = 2; 970 numauthpriv = 4;
968 authpriv = calloc (numauthpriv, sizeof (char *)); 971 authpriv = calloc (numauthpriv, sizeof (char *));
969 authpriv[0] = strdup ("-l"); 972 authpriv[0] = strdup ("-l");
970 authpriv[1] = strdup ("noAuthNoPriv"); 973 authpriv[1] = strdup ("noAuthNoPriv");
974 authpriv[2] = strdup ("-u");
975 authpriv[3] = strdup (secname);
971 } else { 976 } else {
972 if (! ( (strcmp(seclevel, "authNoPriv")==0) || (strcmp(seclevel, "authPriv")==0) ) ) { 977 if (! ( (strcmp(seclevel, "authNoPriv")==0) || (strcmp(seclevel, "authPriv")==0) ) ) {
973 usage2 (_("Invalid seclevel"), seclevel); 978 usage2 (_("Invalid seclevel"), seclevel);
@@ -976,9 +981,6 @@ validate_arguments ()
976 if (authproto == NULL ) 981 if (authproto == NULL )
977 xasprintf(&authproto, DEFAULT_AUTH_PROTOCOL); 982 xasprintf(&authproto, DEFAULT_AUTH_PROTOCOL);
978 983
979 if (secname == NULL)
980 die(STATE_UNKNOWN, _("Required parameter: %s\n"), "secname");
981
982 if (authpasswd == NULL) 984 if (authpasswd == NULL)
983 die(STATE_UNKNOWN, _("Required parameter: %s\n"), "authpasswd"); 985 die(STATE_UNKNOWN, _("Required parameter: %s\n"), "authpasswd");
984 986
@@ -1160,7 +1162,7 @@ print_help (void)
1160 printf (" %s\n", "-D, --output-delimiter=STRING"); 1162 printf (" %s\n", "-D, --output-delimiter=STRING");
1161 printf (" %s\n", _("Separates output on multiple OID requests")); 1163 printf (" %s\n", _("Separates output on multiple OID requests"));
1162 1164
1163 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1165 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1164 printf (" %s\n", "-e, --retries=INTEGER"); 1166 printf (" %s\n", "-e, --retries=INTEGER");
1165 printf (" %s\n", _("Number of retries to be used in the requests")); 1167 printf (" %s\n", _("Number of retries to be used in the requests"));
1166 1168
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 6842c4cf..b6187d61 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_ssh plugin 3* Monitoring check_ssh plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_ssh"; 31const char *progname = "check_ssh";
32const char *copyright = "2000-2007"; 32const char *copyright = "2000-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "netutils.h" 36#include "netutils.h"
@@ -304,7 +304,7 @@ print_help (void)
304 304
305 printf (UT_IPv46); 305 printf (UT_IPv46);
306 306
307 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 307 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
308 308
309 printf (" %s\n", "-r, --remote-version=STRING"); 309 printf (" %s\n", "-r, --remote-version=STRING");
310 printf (" %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)")); 310 printf (" %s\n", _("Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)"));
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 1b2a8dd5..88a2a2ad 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -1,14 +1,14 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_disk plugin 3* Monitoring check_disk plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) 6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
7* Copyright (c) 2000-2007 Nagios Plugins Development Team 7* Copyright (c) 2000-2007 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
11* This file contains the check_disk plugin 11* This file contains the check_swap plugin
12* 12*
13* 13*
14* This program is free software: you can redistribute it and/or modify 14* This program is free software: you can redistribute it and/or modify
@@ -29,7 +29,7 @@
29 29
30const char *progname = "check_swap"; 30const char *progname = "check_swap";
31const char *copyright = "2000-2007"; 31const char *copyright = "2000-2007";
32const char *email = "nagiosplug-devel@lists.sourceforge.net"; 32const char *email = "devel@monitoring-plugins.org";
33 33
34#include "common.h" 34#include "common.h"
35#include "popen.h" 35#include "popen.h"
@@ -60,9 +60,10 @@ void print_help (void);
60int warn_percent = 0; 60int warn_percent = 0;
61int crit_percent = 0; 61int crit_percent = 0;
62float warn_size_bytes = 0; 62float warn_size_bytes = 0;
63float crit_size_bytes= 0; 63float crit_size_bytes = 0;
64int verbose; 64int verbose;
65int allswaps; 65int allswaps;
66int no_swap_state = STATE_CRITICAL;
66 67
67int 68int
68main (int argc, char **argv) 69main (int argc, char **argv)
@@ -350,7 +351,7 @@ main (int argc, char **argv)
350 if(total_swap_mb) { 351 if(total_swap_mb) {
351 percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb); 352 percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb);
352 } else { 353 } else {
353 percent_used = 0; 354 percent_used = 100;
354 } 355 }
355 356
356 result = max_state (result, check_swap (percent_used, free_swap_mb)); 357 result = max_state (result, check_swap (percent_used, free_swap_mb));
@@ -372,6 +373,9 @@ main (int argc, char **argv)
372int 373int
373check_swap (int usp, float free_swap_mb) 374check_swap (int usp, float free_swap_mb)
374{ 375{
376
377 if (!free_swap_mb) return no_swap_state;
378
375 int result = STATE_UNKNOWN; 379 int result = STATE_UNKNOWN;
376 float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */ 380 float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */
377 if (usp >= 0 && crit_percent != 0 && usp >= (100.0 - crit_percent)) 381 if (usp >= 0 && crit_percent != 0 && usp >= (100.0 - crit_percent))
@@ -400,6 +404,7 @@ process_arguments (int argc, char **argv)
400 {"warning", required_argument, 0, 'w'}, 404 {"warning", required_argument, 0, 'w'},
401 {"critical", required_argument, 0, 'c'}, 405 {"critical", required_argument, 0, 'c'},
402 {"allswaps", no_argument, 0, 'a'}, 406 {"allswaps", no_argument, 0, 'a'},
407 {"no-swap", required_argument, 0, 'n'},
403 {"verbose", no_argument, 0, 'v'}, 408 {"verbose", no_argument, 0, 'v'},
404 {"version", no_argument, 0, 'V'}, 409 {"version", no_argument, 0, 'V'},
405 {"help", no_argument, 0, 'h'}, 410 {"help", no_argument, 0, 'h'},
@@ -410,7 +415,7 @@ process_arguments (int argc, char **argv)
410 return ERROR; 415 return ERROR;
411 416
412 while (1) { 417 while (1) {
413 c = getopt_long (argc, argv, "+?Vvhac:w:", longopts, &option); 418 c = getopt_long (argc, argv, "+?Vvhac:w:n:", longopts, &option);
414 419
415 if (c == -1 || c == EOF) 420 if (c == -1 || c == EOF)
416 break; 421 break;
@@ -455,6 +460,10 @@ process_arguments (int argc, char **argv)
455 case 'a': /* all swap */ 460 case 'a': /* all swap */
456 allswaps = TRUE; 461 allswaps = TRUE;
457 break; 462 break;
463 case 'n':
464 if ((no_swap_state = mp_translate_state(optarg)) == ERROR) {
465 usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
466 }
458 case 'v': /* verbose */ 467 case 'v': /* verbose */
459 verbose++; 468 verbose++;
460 break; 469 break;
@@ -538,13 +547,16 @@ print_help (void)
538 printf (" %s\n", "-c, --critical=INTEGER"); 547 printf (" %s\n", "-c, --critical=INTEGER");
539 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free")); 548 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free"));
540 printf (" %s\n", "-c, --critical=PERCENT%%"); 549 printf (" %s\n", "-c, --critical=PERCENT%%");
541 printf (" %s\n", _("Exit with CRITCAL status if less than PERCENT of swap space is free")); 550 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free"));
542 printf (" %s\n", "-a, --allswaps"); 551 printf (" %s\n", "-a, --allswaps");
543 printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one")); 552 printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one"));
553 printf (" %s\n", "-n, --no-swap=<ok|warning|critical|unknown>");
554 printf (" %s %s\n", _("Resulting state when there is no swap regardless of thresholds. Default:"), state_text(no_swap_state));
544 printf (UT_VERBOSE); 555 printf (UT_VERBOSE);
545 556
546 printf ("\n"); 557 printf ("\n");
547 printf ("%s\n", _("Notes:")); 558 printf ("%s\n", _("Notes:"));
559 printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked."));
548 printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.")); 560 printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."));
549 561
550 printf (UT_SUPPORT); 562 printf (UT_SUPPORT);
@@ -556,6 +568,6 @@ void
556print_usage (void) 568print_usage (void)
557{ 569{
558 printf ("%s\n", _("Usage:")); 570 printf ("%s\n", _("Usage:"));
559 printf ("%s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname); 571 printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
560 printf ("%s [-av] -w <bytes_free> -c <bytes_free>\n", progname); 572 printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n");
561} 573}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 6ab82616..ebdccd1b 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_tcp plugin 3* Monitoring check_tcp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2013 Nagios Plugins Development Team 6* Copyright (c) 1999-2013 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,15 +30,14 @@
30/* progname "check_tcp" changes depending on symlink called */ 30/* progname "check_tcp" changes depending on symlink called */
31char *progname; 31char *progname;
32const char *copyright = "1999-2008"; 32const char *copyright = "1999-2008";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34
35#include <ctype.h>
36 34
37#include "common.h" 35#include "common.h"
38#include "netutils.h" 36#include "netutils.h"
39#include "utils.h" 37#include "utils.h"
40#include "utils_tcp.h" 38#include "utils_tcp.h"
41 39
40#include <ctype.h>
42#include <sys/select.h> 41#include <sys/select.h>
43 42
44#ifdef HAVE_SSL 43#ifdef HAVE_SSL
@@ -670,7 +669,7 @@ print_help (void)
670 669
671 printf (UT_WARN_CRIT); 670 printf (UT_WARN_CRIT);
672 671
673 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 672 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
674 673
675 printf (UT_VERBOSE); 674 printf (UT_VERBOSE);
676 675
diff --git a/plugins/check_time.c b/plugins/check_time.c
index 7ee014e9..3943742a 100644
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_time plugin 3* Monitoring check_time plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Nagios Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -30,7 +30,7 @@
30 30
31const char *progname = "check_time"; 31const char *progname = "check_time";
32const char *copyright = "1999-2007"; 32const char *copyright = "1999-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "common.h"
36#include "netutils.h" 36#include "netutils.h"
@@ -358,7 +358,7 @@ print_help (void)
358 printf (" %s\n", "-C, --critical-connect=INTEGER"); 358 printf (" %s\n", "-C, --critical-connect=INTEGER");
359 printf (" %s\n", _("Response time (sec.) necessary to result in critical status")); 359 printf (" %s\n", _("Response time (sec.) necessary to result in critical status"));
360 360
361 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 361 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
362 362
363 printf (UT_SUPPORT); 363 printf (UT_SUPPORT);
364} 364}
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index 59dcc264..099881d0 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -1,16 +1,16 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_ups plugin 3* Monitoring check_ups plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000 Tom Shields 6* Copyright (c) 2000 Tom Shields
7* 2004 Alain Richard <alain.richard@equation.fr> 7* 2004 Alain Richard <alain.richard@equation.fr>
8* 2004 Arnaud Quette <arnaud.quette@mgeups.com> 8* 2004 Arnaud Quette <arnaud.quette@mgeups.com>
9* Copyright (c) 2002-2007 Nagios Plugins Development Team 9* Copyright (c) 2002-2007 Monitoring Plugins Development Team
10* 10*
11* Description: 11* Description:
12* 12*
13* This file contains Network UPS Tools plugin for Nagios 13* This file contains Network UPS Tools plugin for Monitoring
14* 14*
15* This plugin tests the UPS service on the specified host. Network UPS Tools 15* This plugin tests the UPS service on the specified host. Network UPS Tools
16* from www.networkupstools.org must be running for this plugin to work. 16* from www.networkupstools.org must be running for this plugin to work.
@@ -34,7 +34,7 @@
34 34
35const char *progname = "check_ups"; 35const char *progname = "check_ups";
36const char *copyright = "2000-2007"; 36const char *copyright = "2000-2007";
37const char *email = "nagiosplug-devel@lists.sourceforge.net"; 37const char *email = "devel@monitoring-plugins.org";
38 38
39#include "common.h" 39#include "common.h"
40#include "netutils.h" 40#include "netutils.h"
@@ -66,7 +66,7 @@ enum {
66#define UPSSTATUS_BOOST 512 66#define UPSSTATUS_BOOST 512
67#define UPSSTATUS_CHRG 1024 67#define UPSSTATUS_CHRG 1024
68#define UPSSTATUS_DISCHRG 2048 68#define UPSSTATUS_DISCHRG 2048
69#define UPSSTATUS_UNKOWN 4096 69#define UPSSTATUS_UNKNOWN 4096
70 70
71enum { NOSUCHVAR = ERROR-1 }; 71enum { NOSUCHVAR = ERROR-1 };
72 72
@@ -181,7 +181,7 @@ main (int argc, char **argv)
181 if (status & UPSSTATUS_DISCHRG) { 181 if (status & UPSSTATUS_DISCHRG) {
182 xasprintf (&ups_status, "%s%s", ups_status, _(", Discharging")); 182 xasprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
183 } 183 }
184 if (status & UPSSTATUS_UNKOWN) { 184 if (status & UPSSTATUS_UNKNOWN) {
185 xasprintf (&ups_status, "%s%s", ups_status, _(", Unknown")); 185 xasprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
186 } 186 }
187 } 187 }
@@ -379,7 +379,7 @@ determine_status (void)
379 else if (!strcmp (ptr, "DISCHRG")) 379 else if (!strcmp (ptr, "DISCHRG"))
380 status |= UPSSTATUS_DISCHRG; 380 status |= UPSSTATUS_DISCHRG;
381 else 381 else
382 status |= UPSSTATUS_UNKOWN; 382 status |= UPSSTATUS_UNKNOWN;
383 } 383 }
384 384
385 return OK; 385 return OK;
@@ -625,7 +625,7 @@ print_help (void)
625 625
626 printf (UT_WARN_CRIT); 626 printf (UT_WARN_CRIT);
627 627
628 printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 628 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
629 629
630/* TODO: -v clashing with -v/-variable. Commenting out help text since verbose 630/* TODO: -v clashing with -v/-variable. Commenting out help text since verbose
631 is unused up to now */ 631 is unused up to now */
diff --git a/plugins/check_users.c b/plugins/check_users.c
index ff2aedd2..a009f20b 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios check_users plugin 3* Monitoring check_users plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2012 Nagios Plugins Development Team 6* Copyright (c) 2000-2012 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -32,12 +32,17 @@
32 32
33const char *progname = "check_users"; 33const char *progname = "check_users";
34const char *copyright = "2000-2007"; 34const char *copyright = "2000-2007";
35const char *email = "nagiosplug-devel@lists.sourceforge.net"; 35const char *email = "devel@monitoring-plugins.org";
36 36
37#include "common.h" 37#include "common.h"
38#include "utils.h" 38#include "utils.h"
39 39
40#if HAVE_UTMPX_H 40#if HAVE_WTSAPI32_H
41# include <windows.h>
42# include <wtsapi32.h>
43# undef ERROR
44# define ERROR -1
45#elif HAVE_UTMPX_H
41# include <utmpx.h> 46# include <utmpx.h>
42#else 47#else
43# include "popen.h" 48# include "popen.h"
@@ -58,7 +63,11 @@ main (int argc, char **argv)
58 int users = -1; 63 int users = -1;
59 int result = STATE_UNKNOWN; 64 int result = STATE_UNKNOWN;
60 char *perf; 65 char *perf;
61#if HAVE_UTMPX_H 66#if HAVE_WTSAPI32_H
67 WTS_SESSION_INFO *wtsinfo;
68 DWORD wtscount;
69 DWORD index;
70#elif HAVE_UTMPX_H
62 struct utmpx *putmpx; 71 struct utmpx *putmpx;
63#else 72#else
64 char input_buffer[MAX_INPUT_BUFFER]; 73 char input_buffer[MAX_INPUT_BUFFER];
@@ -78,7 +87,36 @@ main (int argc, char **argv)
78 87
79 users = 0; 88 users = 0;
80 89
81#if HAVE_UTMPX_H 90#if HAVE_WTSAPI32_H
91 if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
92 0, 1, &wtsinfo, &wtscount)) {
93 printf(_("Could not enumerate RD sessions: %d\n"), GetLastError());
94 return STATE_UNKNOWN;
95 }
96
97 for (index = 0; index < wtscount; index++) {
98 LPTSTR username;
99 DWORD size;
100 int len;
101
102 if (!WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE,
103 wtsinfo[index].SessionId, WTSUserName, &username, &size))
104 continue;
105
106 len = lstrlen(username);
107
108 WTSFreeMemory(username);
109
110 if (len == 0)
111 continue;
112
113 if (wtsinfo[index].State == WTSActive ||
114 wtsinfo[index].State == WTSDisconnected)
115 users++;
116 }
117
118 WTSFreeMemory(wtsinfo);
119#elif HAVE_UTMPX_H
82 /* get currently logged users from utmpx */ 120 /* get currently logged users from utmpx */
83 setutxent (); 121 setutxent ();
84 122
diff --git a/plugins/common.h b/plugins/common.h
index f1358380..01003b3b 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -1,10 +1,10 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios plugins common include file 3* Monitoring Plugins common include file
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) 6* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
7* Copyright (c) 2003-2007 Nagios Plugins Development Team 7* Copyright (c) 2003-2007 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
diff --git a/plugins/negate.c b/plugins/negate.c
index ef7d4e03..beaed1ea 100644
--- a/plugins/negate.c
+++ b/plugins/negate.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios negate plugin 3* Monitoring negate plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2002-2008 Nagios Plugins Development Team 6* Copyright (c) 2002-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -31,21 +31,20 @@
31 31
32const char *progname = "negate"; 32const char *progname = "negate";
33const char *copyright = "2002-2008"; 33const char *copyright = "2002-2008";
34const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
35 35
36#define DEFAULT_TIMEOUT 11 36#define DEFAULT_TIMEOUT 11
37 37
38#include <ctype.h>
39
40#include "common.h" 38#include "common.h"
41#include "utils.h" 39#include "utils.h"
42#include "utils_cmd.h" 40#include "utils_cmd.h"
43 41
42#include <ctype.h>
43
44/* char *command_line; */ 44/* char *command_line; */
45 45
46static const char **process_arguments (int, char **); 46static const char **process_arguments (int, char **);
47int validate_arguments (char **); 47void validate_arguments (char **);
48int translate_state (char *);
49void print_help (void); 48void print_help (void);
50void print_usage (void); 49void print_usage (void);
51int subst_text = FALSE; 50int subst_text = FALSE;
@@ -99,8 +98,7 @@ main (int argc, char **argv)
99 die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n")); 98 die (max_state_alt (result, STATE_UNKNOWN), _("No data returned from command\n"));
100 99
101 for (i = 0; i < chld_out.lines; i++) { 100 for (i = 0; i < chld_out.lines; i++) {
102 if (subst_text && result != state[result] && 101 if (subst_text && result >= 0 && result <= 4 && result != state[result]) {
103 result >= 0 && result <= 4) {
104 /* Loop over each match found */ 102 /* Loop over each match found */
105 while ((sub = strstr (chld_out.line[i], state_text (result)))) { 103 while ((sub = strstr (chld_out.line[i], state_text (result)))) {
106 /* Terminate the first part and skip over the string we'll substitute */ 104 /* Terminate the first part and skip over the string we'll substitute */
@@ -166,27 +164,27 @@ process_arguments (int argc, char **argv)
166 timeout_interval = atoi (optarg); 164 timeout_interval = atoi (optarg);
167 break; 165 break;
168 case 'T': /* Result to return on timeouts */ 166 case 'T': /* Result to return on timeouts */
169 if ((timeout_state = translate_state(optarg)) == ERROR) 167 if ((timeout_state = mp_translate_state(optarg)) == ERROR)
170 usage4 (_("Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 168 usage4 (_("Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
171 break; 169 break;
172 case 'o': /* replacement for OK */ 170 case 'o': /* replacement for OK */
173 if ((state[STATE_OK] = translate_state(optarg)) == ERROR) 171 if ((state[STATE_OK] = mp_translate_state(optarg)) == ERROR)
174 usage4 (_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 172 usage4 (_("Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
175 permute = FALSE; 173 permute = FALSE;
176 break; 174 break;
177 175
178 case 'w': /* replacement for WARNING */ 176 case 'w': /* replacement for WARNING */
179 if ((state[STATE_WARNING] = translate_state(optarg)) == ERROR) 177 if ((state[STATE_WARNING] = mp_translate_state(optarg)) == ERROR)
180 usage4 (_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 178 usage4 (_("Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
181 permute = FALSE; 179 permute = FALSE;
182 break; 180 break;
183 case 'c': /* replacement for CRITICAL */ 181 case 'c': /* replacement for CRITICAL */
184 if ((state[STATE_CRITICAL] = translate_state(optarg)) == ERROR) 182 if ((state[STATE_CRITICAL] = mp_translate_state(optarg)) == ERROR)
185 usage4 (_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 183 usage4 (_("Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
186 permute = FALSE; 184 permute = FALSE;
187 break; 185 break;
188 case 'u': /* replacement for UNKNOWN */ 186 case 'u': /* replacement for UNKNOWN */
189 if ((state[STATE_UNKNOWN] = translate_state(optarg)) == ERROR) 187 if ((state[STATE_UNKNOWN] = mp_translate_state(optarg)) == ERROR)
190 usage4 (_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 188 usage4 (_("Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
191 permute = FALSE; 189 permute = FALSE;
192 break; 190 break;
@@ -207,7 +205,7 @@ process_arguments (int argc, char **argv)
207} 205}
208 206
209 207
210int 208void
211validate_arguments (char **command_line) 209validate_arguments (char **command_line)
212{ 210{
213 if (command_line[0] == NULL) 211 if (command_line[0] == NULL)
@@ -218,24 +216,6 @@ validate_arguments (char **command_line)
218} 216}
219 217
220 218
221int
222translate_state (char *state_text)
223{
224 char *temp_ptr;
225 for (temp_ptr = state_text; *temp_ptr; temp_ptr++) {
226 *temp_ptr = toupper(*temp_ptr);
227 }
228 if (!strcmp(state_text,"OK") || !strcmp(state_text,"0"))
229 return STATE_OK;
230 if (!strcmp(state_text,"WARNING") || !strcmp(state_text,"1"))
231 return STATE_WARNING;
232 if (!strcmp(state_text,"CRITICAL") || !strcmp(state_text,"2"))
233 return STATE_CRITICAL;
234 if (!strcmp(state_text,"UNKNOWN") || !strcmp(state_text,"3"))
235 return STATE_UNKNOWN;
236 return ERROR;
237}
238
239void 219void
240print_help (void) 220print_help (void)
241{ 221{
@@ -252,7 +232,7 @@ print_help (void)
252 232
253 printf (UT_HELP_VRSN); 233 printf (UT_HELP_VRSN);
254 234
255 printf (UT_TIMEOUT, timeout_interval); 235 printf (UT_PLUG_TIMEOUT, timeout_interval);
256 printf (" %s\n", _("Keep timeout longer than the plugin timeout to retain CRITICAL status.")); 236 printf (" %s\n", _("Keep timeout longer than the plugin timeout to retain CRITICAL status."));
257 printf (" -T, --timeout-result=STATUS\n"); 237 printf (" -T, --timeout-result=STATUS\n");
258 printf (" %s\n", _("Custom result on Negate timeouts; see below for STATUS definition\n")); 238 printf (" %s\n", _("Custom result on Negate timeouts; see below for STATUS definition\n"));
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 9f18723a..00440465 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -1,10 +1,10 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios plugins network utilities 3* Monitoring Plugins network utilities
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) 6* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
7* Copyright (c) 2003-2008 Nagios Plugins Development Team 7* Copyright (c) 2003-2008 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
diff --git a/plugins/netutils.h b/plugins/netutils.h
index 347509e2..c5aa18fc 100644
--- a/plugins/netutils.h
+++ b/plugins/netutils.h
@@ -1,10 +1,10 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios plugins net utilities include file 3* Monitoring Plugins net utilities include file
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) 6* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
7* Copyright (c) 2003-2007 Nagios Plugins Development Team 7* Copyright (c) 2003-2007 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
diff --git a/plugins/popen.c b/plugins/popen.c
index 716bd524..592263fd 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios plugins popen 3* Monitoring Plugins popen
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2005-2007 Nagios Plugins Development Team 6* Copyright (c) 2005-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index 8aba1e33..1a7c904f 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios run command utilities 3* Monitoring run command utilities
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2005-2006 Nagios Plugins Development Team 6* Copyright (c) 2005-2006 Monitoring Plugins Development Team
7* 7*
8* Description : 8* Description :
9* 9*
@@ -261,7 +261,7 @@ runcmd_timeout_alarm_handler (int signo)
261 size_t i; 261 size_t i;
262 262
263 if (signo == SIGALRM) 263 if (signo == SIGALRM)
264 puts(_("CRITICAL - Plugin timed out while executing system call\n")); 264 puts(_("CRITICAL - Plugin timed out while executing system call"));
265 265
266 if(np_pids) for(i = 0; i < maxfd; i++) { 266 if(np_pids) for(i = 0; i < maxfd; i++) {
267 if(np_pids[i] != 0) kill(np_pids[i], SIGKILL); 267 if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
diff --git a/plugins/runcmd.h b/plugins/runcmd.h
index fe660673..2dcdadf0 100644
--- a/plugins/runcmd.h
+++ b/plugins/runcmd.h
@@ -1,7 +1,7 @@
1/**************************************************************************** 1/****************************************************************************
2* 2*
3* License: GPL 3* License: GPL
4* Copyright (c) 2005 Nagios Plugins Development Team 4* Copyright (c) 2005 Monitoring Plugins Development Team
5* Author: Andreas Ericsson <ae@op5.se> 5* Author: Andreas Ericsson <ae@op5.se>
6* 6*
7* 7*
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 2ec91904..687bffb7 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -1,9 +1,9 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios plugins SSL utilities 3* Monitoring Plugins SSL utilities
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2005-2010 Nagios Plugins Development Team 6* Copyright (c) 2005-2010 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -86,10 +86,12 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
86 if (cert && privkey) { 86 if (cert && privkey) {
87 SSL_CTX_use_certificate_file(c, cert, SSL_FILETYPE_PEM); 87 SSL_CTX_use_certificate_file(c, cert, SSL_FILETYPE_PEM);
88 SSL_CTX_use_PrivateKey_file(c, privkey, SSL_FILETYPE_PEM); 88 SSL_CTX_use_PrivateKey_file(c, privkey, SSL_FILETYPE_PEM);
89#ifdef USE_OPENSSL
89 if (!SSL_CTX_check_private_key(c)) { 90 if (!SSL_CTX_check_private_key(c)) {
90 printf ("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n")); 91 printf ("%s\n", _("CRITICAL - Private key does not seem to match certificate!\n"));
91 return STATE_CRITICAL; 92 return STATE_CRITICAL;
92 } 93 }
94#endif
93 } 95 }
94#ifdef SSL_OP_NO_TICKET 96#ifdef SSL_OP_NO_TICKET
95 SSL_CTX_set_options(c, SSL_OP_NO_TICKET); 97 SSL_CTX_set_options(c, SSL_OP_NO_TICKET);
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis
new file mode 100644
index 00000000..c1007deb
--- /dev/null
+++ b/plugins/t/NPTest.cache.travis
@@ -0,0 +1,54 @@
1{
2 'MYSQL_LOGIN_DETAILS' => '-u root -d test',
3 'NP_ALLOW_SUDO' => 'yes',
4 'NP_DNS_SERVER' => '8.8.8.8',
5 'NP_GOOD_NTP_SERVICE' => '',
6 'NP_HOSTNAME_INVALID' => 'nosuchhost',
7 'NP_HOSTNAME_VALID' => 'monitoringplugins.org',
8 'NP_HOSTNAME_VALID_IP' => '130.133.8.40',
9 'NP_HOSTNAME_VALID_REVERSE' => 'orwell.monitoring-plugins.org.',
10 'NP_HOST_DHCP_RESPONSIVE' => '',
11 'NP_HOST_NONRESPONSIVE' => '10.0.0.1',
12 'NP_HOST_RESPONSIVE' => 'localhost',
13 'NP_HOST_SMB' => '',
14 'NP_HOST_SNMP' => '',
15 'NP_HOST_TCP_FTP' => '',
16 'NP_HOST_TCP_HPJD' => '',
17 'NP_HOST_TCP_HTTP' => 'localhost',
18 'NP_HOST_TCP_HTTP2' => 'labs.consol.de',
19 'NP_HOST_TCP_IMAP' => 'imap.web.de',
20 'NP_HOST_TCP_POP' => 'pop.web.de',
21 'NP_HOST_TCP_SMTP' => 'localhost',
22 'NP_HOST_TCP_SMTP_NOTLS' => '',
23 'NP_HOST_TCP_SMTP_TLS' => '',
24 'NP_INTERNET_ACCESS' => 'yes',
25 'NP_MOUNTPOINT2_VALID' => '',
26 'NP_MOUNTPOINT_VALID' => '/',
27 'NP_MYSQL_SERVER' => 'localhost',
28 'NP_HOST_UDP_TIME' => 'localhost',
29 'NP_MYSQL_SOCKET' => '/var/run/mysqld/mysqld.sock',
30 'NP_MYSQL_WITH_SLAVE' => '',
31 'NP_MYSQL_WITH_SLAVE_LOGIN' => '',
32 'NP_NO_NTP_SERVICE' => 'localhost',
33 'NP_SMB_SHARE' => '',
34 'NP_SMB_SHARE_DENY' => '',
35 'NP_SMB_SHARE_SPC' => '',
36 'NP_SMB_VALID_USER' => '',
37 'NP_SMB_VALID_USER_PASS' => '',
38 'NP_SNMP_COMMUNITY' => '',
39 'NP_SSH_CONFIGFILE' => '~/.ssh/config',
40 'NP_SSH_HOST' => 'localhost',
41 'NP_SSH_IDENTITY' => '~/.ssh/id_dsa',
42 'NP_HOST_TCP_JABBER' => 'jabber.org',
43 'host_nonresponsive' => '10.0.0.1',
44 'host_responsive' => 'localhost',
45 'host_snmp' => '',
46 'host_tcp_ftp' => '',
47 'host_tcp_http' => 'localhost',
48 'host_tcp_imap' => 'imap.nierlein.de',
49 'host_tcp_smtp' => 'localhost',
50 'hostname_invalid' => 'nosuchhost',
51 'snmp_community' => '',
52 'user_snmp' => '',
53 'host_udp_time' => 'none',
54}
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index 39b4ca9f..7e0f74b7 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -4,7 +4,7 @@
4# 4#
5# 5#
6 6
7# TODO: Add in tests for perf data. Need to beef up Nagios::Plugin::Performance to cater for max, min, etc 7# TODO: Add in tests for perf data. Need to beef up Monitoring::Plugin::Performance to cater for max, min, etc
8 8
9use strict; 9use strict;
10use Test::More; 10use Test::More;
@@ -37,7 +37,7 @@ cmp_ok( $c, '==', 2, "Got two mountpoints in output");
37 37
38 38
39# Get perf data 39# Get perf data
40# Should use Nagios::Plugin 40# Should use Monitoring::Plugin
41my @perf_data = sort(split(/ /, $result->perf_output)); 41my @perf_data = sort(split(/ /, $result->perf_output));
42 42
43 43
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index 64aaf0ce..4ff553f7 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,14 +10,14 @@ use NPTest;
10 10
11plan skip_all => "check_dns not compiled" unless (-x "check_dns"); 11plan skip_all => "check_dns not compiled" unless (-x "check_dns");
12 12
13plan tests => 13; 13plan tests => 14;
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 "monitoring-plugins.org"
21 ); 21 );
22 22
23my $hostname_valid_ip = getTestParameter( 23my $hostname_valid_ip = getTestParameter(
@@ -54,6 +54,7 @@ cmp_ok( $res->return_code, '==', 2, "Critical threshold passed");
54 54
55$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5"); 55$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5");
56cmp_ok( $res->return_code, '==', 1, "Warning threshold passed"); 56cmp_ok( $res->return_code, '==', 1, "Warning threshold passed");
57like( $res->output, "/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/", "Output performance data OK" );
57 58
58$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1"); 59$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1");
59cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid"); 60cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid");
diff --git a/plugins/t/check_fping.t b/plugins/t/check_fping.t
index 45a9be8a..08692e46 100644
--- a/plugins/t/check_fping.t
+++ b/plugins/t/check_fping.t
@@ -27,16 +27,18 @@ my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_IN
27 27
28my $t; 28my $t;
29 29
30if ( -x "./check_fping" ) 30my $fping = qx(which fping 2> /dev/null);
31{ 31chomp($fping);
32if( ! -x "./check_fping") {
33 $t += skipMissingCmd( "./check_fping", $tests );
34}
35elsif ( $> != 0 && (!$fping || ! -u $fping)) {
36 $t += skipMsg( "./check_fping", $tests );
37} else {
32 $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput ); 38 $t += checkCmd( "./check_fping $host_responsive", 0, $successOutput );
33 $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] ); 39 $t += checkCmd( "./check_fping $host_nonresponsive", [ 1, 2 ] );
34 $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] ); 40 $t += checkCmd( "./check_fping $hostname_invalid", [ 1, 2 ] );
35} 41}
36else
37{
38 $t += skipMissingCmd( "./check_fping", $tests );
39}
40 42
41exit(0) if defined($Test::Harness::VERSION); 43exit(0) if defined($Test::Harness::VERSION);
42exit($tests - $t); 44exit($tests - $t);
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index 29086737..2539a289 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -31,8 +31,8 @@ my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
31 "yes"); 31 "yes");
32 32
33my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", 33my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
34 "A host providing an index page containing the string 'nagios'", 34 "A host providing an index page containing the string 'monitoring'",
35 "nagios.org" ); 35 "test.monitoring-plugins.org" );
36 36
37 37
38$res = NPTest->testCmd( 38$res = NPTest->testCmd(
@@ -62,27 +62,27 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
62like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); 62like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
63 63
64SKIP: { 64SKIP: {
65 skip "No host serving nagios in index file", 7 unless $host_tcp_http2; 65 skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
66 66
67 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios'" ); 67 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring'" );
68 cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'"); 68 cmp_ok( $res->return_code, "==", 0, "Got a reference to 'monitoring'");
69 69
70 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nAGiOs'" ); 70 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing'" );
71 cmp_ok( $res->return_code, "==", 2, "Not got 'nAGiOs'"); 71 cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'");
72 like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); 72 like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
73 73
74 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'nAGiOs'" ); 74 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'mONiTORing'" );
75 cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'nAGiOs'"); 75 cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'");
76 76
77 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios' --invert-regex" ); 77 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'monitoring' --invert-regex" );
78 cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); 78 cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
79 like ( $res->output, "/pattern found/", "Error message says 'pattern found'"); 79 like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
80 80
81 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nAGiOs' --invert-regex" ); 81 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" );
82 cmp_ok( $res->return_code, "==", 0, "And also when not found"); 82 cmp_ok( $res->return_code, "==", 0, "And also when not found");
83} 83}
84SKIP: { 84SKIP: {
85 skip "No internet access", 11 if $internet_access eq "no"; 85 skip "No internet access", 16 if $internet_access eq "no";
86 86
87 $res = NPTest->testCmd( 87 $res = NPTest->testCmd(
88 "./check_http --ssl www.verisign.com" 88 "./check_http --ssl www.verisign.com"
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t
index d9716458..28cd4cd0 100644
--- a/plugins/t/check_mysql.t
+++ b/plugins/t/check_mysql.t
@@ -21,27 +21,29 @@ plan skip_all => "check_mysql not compiled" unless (-x "check_mysql");
21plan tests => 15; 21plan tests => 15;
22 22
23my $bad_login_output = '/Access denied for user /'; 23my $bad_login_output = '/Access denied for user /';
24my $mysqlserver = getTestParameter( 24my $mysqlserver = getTestParameter(
25 "NP_MYSQL_SERVER", 25 "NP_MYSQL_SERVER",
26 "A MySQL Server hostname or IP with no slaves setup" 26 "A MySQL Server hostname or IP with no slaves setup"
27 ); 27 );
28my $mysqlsocket = getTestParameter( 28my $mysqlsocket = getTestParameter(
29 "NP_MYSQL_SOCKET", 29 "NP_MYSQL_SOCKET",
30 "A MySQL Server socket with no slaves setup" 30 "Full path to a MySQL Server socket with no slaves setup"
31 ); 31 );
32my $mysql_login_details = getTestParameter( 32my $mysql_login_details = getTestParameter(
33 "MYSQL_LOGIN_DETAILS", 33 "MYSQL_LOGIN_DETAILS",
34 "Command line parameters to specify login access", 34 "Command line parameters to specify login access (requires " .
35 "-u user -ppw -d db", 35 "REPLICATION CLIENT privleges)",
36 "-u test -ptest",
36 ); 37 );
37my $with_slave = getTestParameter( 38my $with_slave = getTestParameter(
38 "NP_MYSQL_WITH_SLAVE", 39 "NP_MYSQL_WITH_SLAVE",
39 "MySQL server with slaves setup" 40 "MySQL server with slaves setup"
40 ); 41 );
41my $with_slave_login = getTestParameter( 42my $with_slave_login = getTestParameter(
42 "NP_MYSQL_WITH_SLAVE_LOGIN", 43 "NP_MYSQL_WITH_SLAVE_LOGIN",
43 "Login details for server with slave", 44 "Login details for server with slave (requires REPLICATION CLIENT " .
44 "-uroot -ppw" 45 "privleges)",
46 $mysql_login_details || "-u test -ptest"
45 ); 47 );
46 48
47my $result; 49my $result;
diff --git a/plugins/t/check_ntp.t b/plugins/t/check_ntp.t
index 3eee6e17..74d890fa 100644
--- a/plugins/t/check_ntp.t
+++ b/plugins/t/check_ntp.t
@@ -23,12 +23,12 @@ my $no_ntp_service = getTestParameter( "NP_NO_NTP_SERVICE",
23 "A host NOT providing the NTP service", 23 "A host NOT providing the NTP service",
24 "localhost" ); 24 "localhost" );
25 25
26my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", 26my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
27 "The hostname of system not responsive to network requests", 27 "The hostname of system not responsive to network requests",
28 "10.0.0.1" ); 28 "10.0.0.1" );
29 29
30my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID", 30my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
31 "An invalid (not known to DNS) hostname", 31 "An invalid (not known to DNS) hostname",
32 "nosuchhost"); 32 "nosuchhost");
33 33
34my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/'; 34my $ntp_okmatch1 = '/^NTP\sOK:\sOffset\s-?[0-9]+(\.[0-9]+)?(e-[0-9]{2})?\ssecs/';
@@ -43,7 +43,7 @@ my $ntp_nosuchhost = '/^check_ntp.*: Invalid hostname/address - ' . $hostname_in
43 43
44foreach my $plugin (@PLUGINS1) { 44foreach my $plugin (@PLUGINS1) {
45 SKIP: { 45 SKIP: {
46 skip "No NTP server defined", 1 unless $ntp_service; 46 skip "No NTP server defined", 6 unless $ntp_service;
47 $res = NPTest->testCmd( 47 $res = NPTest->testCmd(
48 "./$plugin -H $ntp_service -w 1000 -c 2000" 48 "./$plugin -H $ntp_service -w 1000 -c 2000"
49 ); 49 );
@@ -88,7 +88,7 @@ foreach my $plugin (@PLUGINS1) {
88 88
89foreach my $plugin (@PLUGINS2) { 89foreach my $plugin (@PLUGINS2) {
90 SKIP: { 90 SKIP: {
91 skip "No NTP server defined", 1 unless $ntp_service; 91 skip "No NTP server defined", 6 unless $ntp_service;
92 $res = NPTest->testCmd( 92 $res = NPTest->testCmd(
93 "./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:" 93 "./$plugin -H $ntp_service -w 1000 -c 2000 -W 20 -C 21 -j 100000 -k 200000 -m 1: -n 0:"
94 ); 94 );
diff --git a/plugins/t/check_procs.t b/plugins/t/check_procs.t
index 1dea5643..ca4acdd7 100644
--- a/plugins/t/check_procs.t
+++ b/plugins/t/check_procs.t
@@ -13,7 +13,7 @@ my $t;
13if (`uname -s` eq "SunOS\n" && ! -x "/usr/local/nagios/libexec/pst3") { 13if (`uname -s` eq "SunOS\n" && ! -x "/usr/local/nagios/libexec/pst3") {
14 plan skip_all => "Ignoring tests on solaris because of pst3"; 14 plan skip_all => "Ignoring tests on solaris because of pst3";
15} else { 15} else {
16 plan tests => 12; 16 plan tests => 14;
17} 17}
18 18
19my $result; 19my $result;
@@ -26,6 +26,11 @@ $result = NPTest->testCmd( "./check_procs -w 100000 -c 100000 -s Z" );
26is( $result->return_code, 0, "Checking less than 100000 zombie processes" ); 26is( $result->return_code, 0, "Checking less than 100000 zombie processes" );
27like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" ); 27like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" );
28 28
29if(fork() == 0) { exec("sleep 7"); } # fork a test process
30$result = NPTest->testCmd( "./check_procs -a 'sleep 7'" );
31is( $result->return_code, 0, "Parent process is ignored" );
32like( $result->output, '/^PROCS OK: 1 process?/', "Output correct" );
33
29$result = NPTest->testCmd( "./check_procs -w 0 -c 100000" ); 34$result = NPTest->testCmd( "./check_procs -w 0 -c 100000" );
30is( $result->return_code, 1, "Checking warning if processes > 0" ); 35is( $result->return_code, 1, "Checking warning if processes > 0" );
31like( $result->output, '/^PROCS WARNING: [0-9]+ process(es)? | procs=[0-9]+;0;100000;0;$/', "Output correct" ); 36like( $result->output, '/^PROCS WARNING: [0-9]+ process(es)? | procs=[0-9]+;0;100000;0;$/', "Output correct" );
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index 6de5f299..2d6c44a7 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -10,7 +10,7 @@ use NPTest;
10 10
11BEGIN { 11BEGIN {
12 plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp"; 12 plan skip_all => 'check_snmp is not compiled' unless -x "./check_snmp";
13 plan tests => 60; 13 plan tests => 61;
14} 14}
15 15
16my $res; 16my $res;
@@ -26,6 +26,7 @@ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRES
26 26
27my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", 27my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
28 "An invalid (not known to DNS) hostname" ); 28 "An invalid (not known to DNS) hostname" );
29my $user_snmp = getTestParameter( "user_snmp", "NP_SNMP_USER", "auth_md5", "An SNMP user");
29 30
30$res = NPTest->testCmd( "./check_snmp -t 1" ); 31$res = NPTest->testCmd( "./check_snmp -t 1" );
31is( $res->return_code, 3, "No host name" ); 32is( $res->return_code, 3, "No host name" );
@@ -35,7 +36,7 @@ $res = NPTest->testCmd( "./check_snmp -H fakehostname" );
35is( $res->return_code, 3, "No OIDs specified" ); 36is( $res->return_code, 3, "No OIDs specified" );
36is( $res->output, "No OIDs specified" ); 37is( $res->output, "No OIDs specified" );
37 38
38$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 --seclevel=rubbish" ); 39$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 -U not_a_user --seclevel=rubbish" );
39is( $res->return_code, 3, "Invalid seclevel" ); 40is( $res->return_code, 3, "Invalid seclevel" );
40like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" ); 41like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" );
41 42
@@ -44,7 +45,7 @@ is( $res->return_code, 3, "Invalid protocol" );
44like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); 45like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
45 46
46SKIP: { 47SKIP: {
47 skip "no snmp host defined", 38 if ( ! $host_snmp ); 48 skip "no snmp host defined", 48 if ( ! $host_snmp );
48 49
49 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); 50 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
50 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); 51 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" );
@@ -154,6 +155,12 @@ SKIP: {
154 like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed"); 155 like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed");
155} 156}
156 157
158SKIP: {
159 skip "no SNMP user defined", 1 if ( ! $user_snmp );
160 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv");
161 like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" );
162}
163
157# These checks need a complete command line. An invalid community is used so 164# These checks need a complete command line. An invalid community is used so
158# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway 165# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway
159SKIP: { 166SKIP: {
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t
index abb16aec..f996685d 100644
--- a/plugins/t/check_tcp.t
+++ b/plugins/t/check_tcp.t
@@ -12,7 +12,6 @@ BEGIN {
12 use NPTest; 12 use NPTest;
13 $has_ipv6 = NPTest::has_ipv6(); 13 $has_ipv6 = NPTest::has_ipv6();
14 $tests = $has_ipv6 ? 14 : 11; 14 $tests = $has_ipv6 ? 14 : 11;
15 plan tests => $tests;
16} 15}
17 16
18 17
@@ -25,20 +24,29 @@ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRES
25my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", 24my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
26 "An invalid (not known to DNS) hostname" ); 25 "An invalid (not known to DNS) hostname" );
27 26
27my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
28 "Is this system directly connected to the internet?",
29 "yes");
30
28my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/'; 31my $successOutput = '/^TCP OK\s-\s+[0-9]?\.?[0-9]+ second response time on port [0-9]+/';
29 32
30my $failedExpect = '/^TCP WARNING\s-\sUnexpected response from host/socket on port [0-9]+/'; 33my $failedExpect = '/^TCP WARNING\s-\sUnexpected response from host/socket on port [0-9]+/';
31 34
32my $t; 35my $t;
33 36
37$tests = $tests - 4 if $internet_access eq "no";
38plan tests => $tests;
39
34$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput ); 40$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput );
35$t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test 41$t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test
36$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); 42$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 );
37$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); 43$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 );
38$t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 ); 44if($internet_access ne "no") {
39$t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 ); 45 $t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0 );
40$t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); 46 $t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 );
41$t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); 47 $t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 );
48 $t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 );
49}
42 50
43# Need the \r\n to make it more standards compliant with web servers. Need the various quotes 51# Need the \r\n to make it more standards compliant with web servers. Need the various quotes
44# so that perl doesn't interpret the \r\n and is passed onto command line correctly 52# so that perl doesn't interpret the \r\n and is passed onto command line correctly
diff --git a/plugins/t/check_udp.t b/plugins/t/check_udp.t
index 619cadfb..1f6fee70 100644
--- a/plugins/t/check_udp.t
+++ b/plugins/t/check_udp.t
@@ -62,7 +62,7 @@ SKIP: {
62 cmp_ok( $res->return_code, '==', '2', "Hung waiting for response"); 62 cmp_ok( $res->return_code, '==', '2', "Hung waiting for response");
63 like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message"); 63 like ( $res->output, '/Socket timeout after 5 seconds/', "Timeout message");
64 like ( $duration, '/^[56]$/', "Timeout after 5 (possibly 6) seconds"); 64 like ( $duration, '/^[56]$/', "Timeout after 5 (possibly 6) seconds");
65 my $read_nc = <NC>; 65 my $read_nc = <NC> || '';
66 close NC; 66 close NC;
67 cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" ); 67 cmp_ok( $read_nc, 'eq', "foofoo", "Data received correctly" );
68} 68}
diff --git a/plugins/t/negate.t b/plugins/t/negate.t
index 0afe3ae6..f18acc39 100644
--- a/plugins/t/negate.t
+++ b/plugins/t/negate.t
@@ -78,7 +78,7 @@ foreach my $current_state (keys(%state)) {
78 } 78 }
79} 79}
80 80
81# Same as aboce with substitute 81# Same as above with substitute
82foreach my $current_state (keys(%state)) { 82foreach my $current_state (keys(%state)) {
83 foreach my $new_state (keys(%state)) { 83 foreach my $new_state (keys(%state)) {
84 $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); 84 $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" );
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index c3085e13..225b449f 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -7,7 +7,7 @@
7# Country Name (2 letter code) [AU]:UK 7# Country Name (2 letter code) [AU]:UK
8# State or Province Name (full name) [Some-State]:Derbyshire 8# State or Province Name (full name) [Some-State]:Derbyshire
9# Locality Name (eg, city) []:Belper 9# Locality Name (eg, city) []:Belper
10# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Nagios Plugins 10# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins
11# Organizational Unit Name (eg, section) []: 11# Organizational Unit Name (eg, section) []:
12# Common Name (eg, YOUR name) []:Ton Voon 12# Common Name (eg, YOUR name) []:Ton Voon
13# Email Address []:tonvoon@mac.com 13# Email Address []:tonvoon@mac.com
@@ -20,8 +20,9 @@ use FindBin qw($Bin);
20my $common_tests = 70; 20my $common_tests = 70;
21my $ssl_only_tests = 8; 21my $ssl_only_tests = 8;
22# Check that all dependent modules are available 22# Check that all dependent modules are available
23eval "use HTTP::Daemon 6.01;";
24plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@;
23eval { 25eval {
24 require HTTP::Daemon;
25 require HTTP::Status; 26 require HTTP::Status;
26 require HTTP::Response; 27 require HTTP::Response;
27}; 28};
@@ -392,27 +393,21 @@ sub run_common_tests {
392 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); 393 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL});
393 $cmd = "$command -f follow -u /redir_external -t 5"; 394 $cmd = "$command -f follow -u /redir_external -t 5";
394 eval { 395 eval {
395 local $SIG{ALRM} = sub { die "alarm\n" }; 396 $result = NPTest->testCmd( $cmd, 2 );
396 alarm(2); 397 };
397 $result = NPTest->testCmd( $cmd ); 398 like( $@, "/timeout in command: $cmd/", $cmd );
398 alarm(0); };
399 is( $@, "alarm\n", $cmd );
400 } 399 }
401 400
402 $cmd = "$command -u /timeout -t 5"; 401 $cmd = "$command -u /timeout -t 5";
403 eval { 402 eval {
404 local $SIG{ALRM} = sub { die "alarm\n" }; 403 $result = NPTest->testCmd( $cmd, 2 );
405 alarm(2); 404 };
406 $result = NPTest->testCmd( $cmd ); 405 like( $@, "/timeout in command: $cmd/", $cmd );
407 alarm(0); };
408 is( $@, "alarm\n", $cmd );
409 406
410 $cmd = "$command -f follow -u /redir_timeout -t 2"; 407 $cmd = "$command -f follow -u /redir_timeout -t 2";
411 eval { 408 eval {
412 local $SIG{ALRM} = sub { die "alarm\n" }; 409 $result = NPTest->testCmd( $cmd, 5 );
413 alarm(5); 410 };
414 $result = NPTest->testCmd( $cmd ); 411 is( $@, "", $cmd );
415 alarm(0); };
416 isnt( $@, "alarm\n", $cmd );
417 412
418} 413}
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index d71c83a2..54d43d9b 100644..100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -18,59 +18,68 @@ my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin";
18 18
19$result = NPTest->testCmd( "$command" ); 19$result = NPTest->testCmd( "$command" );
20is( $result->return_code, 0, "Run with no options" ); 20is( $result->return_code, 0, "Run with no options" );
21like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" ); 21is( $result->output, "PROCS OK: 95 processes | procs=95;;;0;", "Output correct" );
22 22
23$result = NPTest->testCmd( "$command -w 5" ); 23$result = NPTest->testCmd( "$command -w 5" );
24is( $result->return_code, 1, "Checking > 5 processes" ); 24is( $result->return_code, 1, "Checking > 5 processes" );
25like( $result->output, '/^PROCS WARNING: 95 processes$/', "Output correct" ); 25is( $result->output, "PROCS WARNING: 95 processes | procs=95;5;;0;", "Output correct" );
26 26
27$result = NPTest->testCmd( "$command -w 4 -c 44" ); 27$result = NPTest->testCmd( "$command -w 4 -c 44" );
28is( $result->return_code, 2, "Checking critical" ); 28is( $result->return_code, 2, "Checking critical" );
29like( $result->output, '/^PROCS CRITICAL: 95 processes$/', "Output correct" ); 29is( $result->output, "PROCS CRITICAL: 95 processes | procs=95;4;44;0;", "Output correct" );
30 30
31$result = NPTest->testCmd( "$command -w 100 -c 200" ); 31$result = NPTest->testCmd( "$command -w 100 -c 200" );
32is( $result->return_code, 0, "Checking no threshold breeched" ); 32is( $result->return_code, 0, "Checking no threshold breeched" );
33like( $result->output, '/^PROCS OK: 95 processes$/', "Output correct" ); 33is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" );
34 34
35$result = NPTest->testCmd( "$command -C launchd -c 5" ); 35$result = NPTest->testCmd( "$command -C launchd -c 5" );
36is( $result->return_code, 2, "Checking processes filtered by command name" ); 36is( $result->return_code, 2, "Checking processes filtered by command name" );
37like( $result->output, '/^PROCS CRITICAL: 6 processes with command name \'launchd\'$/', "Output correct" ); 37is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" );
38 38
39$result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" ); 39SKIP: {
40is( $result->return_code, 1, "Checking processes filtered by userid" ); 40 skip 'user with uid 501 required', 4 unless getpwuid(501);
41like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" );
42 41
43$result = NPTest->testCmd( "$command -C launchd -u 501" ); 42 $result = NPTest->testCmd( "$command -u 501 -w 39 -c 41" );
44is( $result->return_code, 0, "Checking processes filtered by command name and userid" ); 43 is( $result->return_code, 1, "Checking processes filtered by userid" );
45like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" ); 44 like( $result->output, '/^PROCS WARNING: 40 processes with UID = 501 (.*)$/', "Output correct" );
46 45
47$result = NPTest->testCmd( "$command -u -2 -w 2:2" ); 46 $result = NPTest->testCmd( "$command -C launchd -u 501" );
48is( $result->return_code, 1, "Checking processes with userid=-2" ); 47 is( $result->return_code, 0, "Checking processes filtered by command name and userid" );
49like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); 48 like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
49}
50
51SKIP: {
52 skip 'user with uid -2 required', 8 unless getpwuid(-2);
53 skip 'uid -2 must have name "nobody"', 8 unless getpwuid(-2) eq 'nobody';
50 54
51$result = NPTest->testCmd( "$command -u -2 -w 3:3" ); 55 $result = NPTest->testCmd( "$command -u -2 -w 2:2" );
52is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" ); 56 is( $result->return_code, 1, "Checking processes with userid=-2" );
53like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); 57 like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
54 58
55$result = NPTest->testCmd( "$command -u -2 -a usb" ); 59 $result = NPTest->testCmd( "$command -u -2 -w 3:3" );
56is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" ); 60 is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" );
57like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" ); 61 like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
58 62
59$result = NPTest->testCmd( "$command -u -2 -a UsB" ); 63 $result = NPTest->testCmd( "$command -u -2 -a usb" );
60is( $result->return_code, 0, "Checking case sensitivity of args" ); 64 is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" );
61like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); 65 like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" );
66
67 $result = NPTest->testCmd( "$command -u -2 -a UsB" );
68 is( $result->return_code, 0, "Checking case sensitivity of args" );
69 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
70};
62 71
63$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); 72$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
64is( $result->return_code, 0, "Checking regexp search of arguments" ); 73is( $result->return_code, 0, "Checking regexp search of arguments" );
65is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501'", "Output correct" ); 74is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
66 75
67$result = NPTest->testCmd( "$command --vsz 1000000" ); 76$result = NPTest->testCmd( "$command --vsz 1000000" );
68is( $result->return_code, 0, "Checking filter by VSZ" ); 77is( $result->return_code, 0, "Checking filter by VSZ" );
69like( $result->output, '/^PROCS OK: 24 processes with VSZ >= 1000000$/', "Output correct" ); 78is( $result->output, 'PROCS OK: 24 processes with VSZ >= 1000000 | procs=24;;;0;', "Output correct" );
70 79
71$result = NPTest->testCmd( "$command --rss 100000" ); 80$result = NPTest->testCmd( "$command --rss 100000" );
72is( $result->return_code, 0, "Checking filter by RSS" ); 81is( $result->return_code, 0, "Checking filter by RSS" );
73like( $result->output, '/^PROCS OK: 3 processes with RSS >= 100000$/', "Output correct" ); 82is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;', "Output correct" );
74 83
75$result = NPTest->testCmd( "$command -s S" ); 84$result = NPTest->testCmd( "$command -s S" );
76is( $result->return_code, 0, "Checking filter for sleeping processes" ); 85is( $result->return_code, 0, "Checking filter for sleeping processes" );
@@ -86,34 +95,38 @@ like( $result->output, '/^PROCS CRITICAL: 39 processes with PPID = 1/', "Output
86 95
87$result = NPTest->testCmd( "$command -P 0.71" ); 96$result = NPTest->testCmd( "$command -P 0.71" );
88is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" ); 97is( $result->return_code, 0, "Checking filter for percentage cpu > 0.71" );
89is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71', "Output correct" ); 98is( $result->output, 'PROCS OK: 7 processes with PCPU >= 0.71 | procs=7;;;0;', "Output correct" );
90 99
91$result = NPTest->testCmd( "$command -P 0.70" ); 100$result = NPTest->testCmd( "$command -P 0.70" );
92is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" ); 101is( $result->return_code, 0, "Checking filter for percentage cpu > 0.70" );
93is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70', "Output correct" ); 102is( $result->output, 'PROCS OK: 8 processes with PCPU >= 0.70 | procs=8;;;0;', "Output correct" );
94 103
95$result = NPTest->testCmd( "$command --metric=CPU -w 8" ); 104$result = NPTest->testCmd( "$command --metric=CPU -w 8" );
96is( $result->return_code, 1, "Checking against metric of CPU > 8" ); 105is( $result->return_code, 1, "Checking against metric of CPU > 8" );
97is( $result->output, 'CPU WARNING: 1 warn out of 95 processes', "Output correct" ); 106is( $result->output, 'CPU WARNING: 1 warn out of 95 processes | procs=95;;;0; procs_warn=1;;;0; procs_crit=0;;;0;', "Output correct" );
98 107
99# TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will. 108# TODO: Because of a conversion to int, if CPU is 1.45%, will not alert, but 2.01% will.
100$result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" ); 109SKIP: {
101is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" ); 110 skip 'user with uid 501 required', 2 unless getpwuid(501);
102is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" ); 111
112 $result = NPTest->testCmd( "$command --metric=CPU -w 1 -u 501 -v" );
113 is( $result->return_code, 1, "Checking against metric of CPU > 1 with uid=501 - TODO" );
114 is( $result->output, 'CPU WARNING: 2 warn out of 40 processes with UID = 501 (tonvoon) [Skype, PubSubAgent]', "Output correct" );
115};
103 116
104$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); 117$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
105is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); 118is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );
106is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" ); 119is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" );
107 120
108$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" ); 121$result = NPTest->testCmd( "$command --metric=VSZ -w 1200000 -v" );
109is( $result->return_code, 1, "Checking against VSZ > 1.2GB" ); 122is( $result->return_code, 1, "Checking against VSZ > 1.2GB" );
110is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype]', "Output correct" ); 123is( $result->output, 'VSZ WARNING: 4 warn out of 95 processes [WindowServer, Safari, Mail, Skype] | procs=95;;;0; procs_warn=4;;;0; procs_crit=0;;;0;', "Output correct" );
111 124
112$result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" ); 125$result = NPTest->testCmd( "$command --metric=RSS -c 70000 -v" );
113is( $result->return_code, 2, "Checking against RSS > 70MB" ); 126is( $result->return_code, 2, "Checking against RSS > 70MB" );
114is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari]', "Output correct" ); 127is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowServer, SystemUIServer, Safari, Mail, Safari] | procs=95;;;0; procs_warn=0;;;0; procs_crit=5;;;0;', "Output correct" );
115 128
116$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); 129$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
117is( $result->return_code, 0, "Checking no pipe symbol in output" ); 130is( $result->return_code, 0, "Checking no pipe symbol in output" );
118is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)'", "Output correct" ); 131is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" );
119 132
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index 1ef0b209..aace9bcc 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -8,7 +8,7 @@ use Test::More;
8use NPTest; 8use NPTest;
9use FindBin qw($Bin); 9use FindBin qw($Bin);
10 10
11my $tests = 53; 11my $tests = 67;
12# Check that all dependent modules are available 12# Check that all dependent modules are available
13eval { 13eval {
14 require NetSNMP::OID; 14 require NetSNMP::OID;
@@ -59,7 +59,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") {
59} 59}
60 60
61# We should merge that with $ENV{'NPTEST_CACHE'}, use one dir for all test data 61# We should merge that with $ENV{'NPTEST_CACHE'}, use one dir for all test data
62$ENV{'NAGIOS_PLUGIN_STATE_DIRECTORY'} ||= "/var/tmp"; 62$ENV{'MP_STATE_PATH'} ||= "/var/tmp";
63 63
64my $res; 64my $res;
65 65
@@ -79,7 +79,7 @@ Copyright (c) 1986-2004 by cisco Systems, Inc.
79$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1"); 79$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1");
80cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" ); 80cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" );
81like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); 81like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
82like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software Alice Kisco Outernetwork Oserating Gystem Totware | 82like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software ').'"?Alice"?'.quotemeta(' Kisco Outernetwork Oserating Gystem Totware |
83.1.3.6.1.4.1.8072.3.2.67.0: 83.1.3.6.1.4.1.8072.3.2.67.0:
84"Cisco Internetwork Operating System Software 84"Cisco Internetwork Operating System Software
85IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version 85IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version
@@ -109,7 +109,7 @@ like($res->output, '/'.quotemeta('SNMP OK - And now have fun with with this: \"C
109"And now have fun with with this: \"C:\\\\\" 109"And now have fun with with this: \"C:\\\\\"
110because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); 110because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3");
111 111
112system("rm -f ".$ENV{'NAGIOS_PLUGIN_STATE_DIRECTORY'}."/check_snmp/*"); 112system("rm -f ".$ENV{'MP_STATE_PATH'}."/check_snmp/*");
113$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); 113$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" );
114is($res->return_code, 0, "Returns OK"); 114is($res->return_code, 0, "Returns OK");
115is($res->output, "No previous data to calculate rate - assume okay"); 115is($res->output, "No previous data to calculate rate - assume okay");
@@ -214,3 +214,31 @@ $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1
214is($res->return_code, 0, "String check should check whole string, not a parsed number" ); 214is($res->return_code, 0, "String check should check whole string, not a parsed number" );
215is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string"); 215is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string");
216 216
217$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
218is($res->return_code, 0, "Negative integer check OK" );
219is($res->output, 'SNMP OK - -2 | iso.3.6.1.4.1.8072.3.2.67.16=-2 ', "Negative integer check OK output" );
220
221$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
222is($res->return_code, 1, "Negative integer check WARNING" );
223is($res->output, 'SNMP WARNING - *-3* | iso.3.6.1.4.1.8072.3.2.67.16=-3 ', "Negative integer check WARNING output" );
224
225$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
226is($res->return_code, 2, "Negative integer check CRITICAL" );
227is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.16=-4 ', "Negative integer check CRITICAL output" );
228
229$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -3: -c -6:" );
230is($res->return_code, 1, "Negative integer as string, WARNING" );
231is($res->output, 'SNMP WARNING - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, WARNING output" );
232
233$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.17 -w -2: -c -3:" );
234is($res->return_code, 2, "Negative integer as string, CRITICAL" );
235is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4 ', "Negative integer as string, CRITICAL output" );
236
237$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c ~:-6.5" );
238is($res->return_code, 0, "Negative float OK" );
239is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float OK output" );
240
241$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w ~:-6.65 -c ~:-6.55" );
242is($res->return_code, 1, "Negative float WARNING" );
243is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6 ', "Negative float WARNING output" );
244
diff --git a/plugins/tests/check_snmp_agent.pl b/plugins/tests/check_snmp_agent.pl
index 8cacd527..0e41d575 100644
--- a/plugins/tests/check_snmp_agent.pl
+++ b/plugins/tests/check_snmp_agent.pl
@@ -7,7 +7,7 @@
7use NetSNMP::OID qw(:all); 7use NetSNMP::OID qw(:all);
8use NetSNMP::agent; 8use NetSNMP::agent;
9use NetSNMP::ASN qw(ASN_OCTET_STR ASN_COUNTER ASN_COUNTER64 ASN_INTEGER ASN_INTEGER64 ASN_UNSIGNED ASN_UNSIGNED64); 9use NetSNMP::ASN qw(ASN_OCTET_STR ASN_COUNTER ASN_COUNTER64 ASN_INTEGER ASN_INTEGER64 ASN_UNSIGNED ASN_UNSIGNED64);
10#use Math::Int64 qw(uint64); # Skip that module whie we don't need it 10#use Math::Int64 qw(uint64); # Skip that module while we don't need it
11sub uint64 { return $_ } 11sub uint64 { return $_ }
12 12
13if (!$agent) { 13if (!$agent) {
@@ -16,8 +16,6 @@ if (!$agent) {
16} 16}
17 17
18my $baseoid = '.1.3.6.1.4.1.8072.3.2.67'; 18my $baseoid = '.1.3.6.1.4.1.8072.3.2.67';
19# Next are arrays of indexes (Type, initial value and increments)
20# Undef miltipliers are randomized
21my $multiline = 'Cisco Internetwork Operating System Software 19my $multiline = 'Cisco Internetwork Operating System Software
22IOS (tm) Catalyst 4000 "L3" Switch Software (cat4000-I9K91S-M), Version 20IOS (tm) Catalyst 4000 "L3" Switch Software (cat4000-I9K91S-M), Version
2312.2(20)EWA, RELEASE SOFTWARE (fc1) 2112.2(20)EWA, RELEASE SOFTWARE (fc1)
@@ -33,10 +31,12 @@ ends with with this: C:\\';
33my $multilin5 = 'And now have fun with with this: "C:\\" 31my $multilin5 = 'And now have fun with with this: "C:\\"
34because we\'re not done yet!'; 32because we\'re not done yet!';
35 33
36# 0..15 <---- please update comment when adding/removing fields 34# Next are arrays of indexes (Type, initial value and increments)
37my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR ); 35# 0..16 <---- please update comment when adding/removing fields
38my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345' ); 36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR );
39my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef ); 37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' );
38# undef increments are randomized
39my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef );
40 40
41# Number of elements in our OID 41# Number of elements in our OID
42my $oidelts; 42my $oidelts;
diff --git a/plugins/tests/var/ps_axwo.debian b/plugins/tests/var/ps_axwo.debian
index 0d7d7bce..37a2d35e 100644
--- a/plugins/tests/var/ps_axwo.debian
+++ b/plugins/tests/var/ps_axwo.debian
@@ -31,7 +31,7 @@ S 0 6907 1 2308 892 0.0 mysqld_safe /bin/sh /usr/bin/mysqld_
31S 103 6944 6907 123220 27724 0.0 mysqld /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock 31S 103 6944 6907 123220 27724 0.0 mysqld /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
32S 0 6945 6907 1488 420 0.0 logger logger -p daemon.err -t mysqld_safe -i -t mysqld 32S 0 6945 6907 1488 420 0.0 logger logger -p daemon.err -t mysqld_safe -i -t mysqld
33S 1001 17778 1 6436 1588 0.0 snmpd /usr/sbin/snmpd -u nagios -Lsd -Lf /dev/null -p/var/run/snmpd.pid 33S 1001 17778 1 6436 1588 0.0 snmpd /usr/sbin/snmpd -u nagios -Lsd -Lf /dev/null -p/var/run/snmpd.pid
34Ss 0 17789 1 9496 5556 0.0 snmptrapd /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/nagios/snmp/load -p /var/run/snmptrapd.pid 34Ss 0 17789 1 9496 5556 0.0 snmptrapd /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/monitoring/snmp/load -p /var/run/snmptrapd.pid
35Ss 0 847 2319 14452 1752 0.0 sshd sshd: tonvoon [priv] 35Ss 0 847 2319 14452 1752 0.0 sshd sshd: tonvoon [priv]
36S 1000 857 847 14616 1832 0.0 sshd sshd: tonvoon@pts/3 36S 1000 857 847 14616 1832 0.0 sshd sshd: tonvoon@pts/3
37Ss 1000 860 857 2984 1620 0.0 bash -bash 37Ss 1000 860 857 2984 1620 0.0 bash -bash
@@ -79,6 +79,6 @@ Ss 1001 23783 1 3220 764 0.0 ndo2db /usr/local/nagios/bin/nd
79Ss 1001 23784 1 6428 4948 0.0 import_ndologsd import_ndologsd 79Ss 1001 23784 1 6428 4948 0.0 import_ndologsd import_ndologsd
80S+ 1001 9803 18955 4132 1936 0.0 ssh ssh altinity@cube02.lei.altinity 80S+ 1001 9803 18955 4132 1936 0.0 ssh ssh altinity@cube02.lei.altinity
81S 1001 22505 22324 20256 1616 0.0 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg 81S 1001 22505 22324 20256 1616 0.0 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg
82S 1001 22506 22505 1676 608 0.0 check_ping /usr/local/nagios/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1 82S 1001 22506 22505 1676 608 0.0 check_ping /usr/local/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1
83S 1001 22507 22506 1660 492 0.0 ping /bin/ping -n -U -w 10 -c 1 192.168.10.23 83S 1001 22507 22506 1660 492 0.0 ping /bin/ping -n -U -w 10 -c 1 192.168.10.23
84R+ 1001 22508 23370 2308 680 0.0 ps ps axwo stat uid pid ppid vsz rss pcpu comm args 84R+ 1001 22508 23370 2308 680 0.0 ps ps axwo stat uid pid ppid vsz rss pcpu comm args
diff --git a/plugins/urlize.c b/plugins/urlize.c
index 30b2a353..6fda72d1 100644
--- a/plugins/urlize.c
+++ b/plugins/urlize.c
@@ -1,17 +1,16 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Nagios urlize plugin 3* Monitoring urlize plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Nagios Plugins Development Team 6* Copyright (c) 2000-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the urlize plugin 10* This file contains the urlize plugin
11* 11*
12* This plugin wraps the text output of another command (plugin) in HTML <A> 12* This plugin wraps the text output of another command (plugin) in HTML <A>
13* tags, thus displaying the child plugin's output as a clickable link in the 13* tags. This plugin returns the status of the invoked plugin.
14* Nagios status screen. This plugin returns the status of the invoked plugin.
15* 14*
16* 15*
17* This program is free software: you can redistribute it and/or modify 16* This program is free software: you can redistribute it and/or modify
@@ -32,7 +31,7 @@
32 31
33const char *progname = "urlize"; 32const char *progname = "urlize";
34const char *copyright = "2000-2006"; 33const char *copyright = "2000-2006";
35const char *email = "nagiosplug-devel@lists.sourceforge.net"; 34const char *email = "devel@monitoring-plugins.org";
36 35
37#include "common.h" 36#include "common.h"
38#include "utils.h" 37#include "utils.h"
@@ -166,9 +165,9 @@ print_help (void)
166 printf ("Copyright (c) 2000 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n"); 165 printf ("Copyright (c) 2000 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n");
167 printf (COPYRIGHT, copyright, email); 166 printf (COPYRIGHT, copyright, email);
168 167
169 printf ("%s\n", _("This plugin wraps the text output of another command (plugin)")); 168 printf ("%s\n", _("This plugin wraps the text output of another command (plugin) in HTML <A>"));
170 printf ("%s\n", _("in HTML <A> tags, thus displaying the child plugin's output as a clickable link in")); 169 printf ("%s\n", _("tags, thus displaying the child plugin's output as a clickable link in compatible"));
171 printf ("%s\n", _("the Nagios status screen. This plugin returns the status of the invoked plugin.")); 170 printf ("%s\n", _("monitoring status screen. This plugin returns the status of the invoked plugin."));
172 171
173 printf ("\n\n"); 172 printf ("\n\n");
174 173
diff --git a/plugins/utils.c b/plugins/utils.c
index b57d5e17..58b153d8 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -4,7 +4,7 @@
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000 Karl DeBisschop (karl@debisschop.net) 6* Copyright (c) 2000 Karl DeBisschop (karl@debisschop.net)
7* Copyright (c) 2002-2007 Nagios Plugin Development Team 7* Copyright (c) 2002-2007 Monitoring Plugins Development Team
8* 8*
9* This program is free software: you can redistribute it and/or modify 9* This program is free software: you can redistribute it and/or modify
10* it under the terms of the GNU General Public License as published by 10* it under the terms of the GNU General Public License as published by
diff --git a/plugins/utils.h b/plugins/utils.h
index 657d4bfa..4c4aaccc 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -1,6 +1,6 @@
1#ifndef NP_UTILS_H 1#ifndef NP_UTILS_H
2#define NP_UTILS_H 2#define NP_UTILS_H
3/* Header file for nagios plugins utils.c */ 3/* Header file for Monitoring Plugins utils.c */
4 4
5/* This file should be included in all plugins */ 5/* This file should be included in all plugins */
6 6
@@ -131,7 +131,7 @@ char *fperfdata (const char *,
131{"warning",required_argument,0,'w'},\ 131{"warning",required_argument,0,'w'},\
132{"hostname",required_argument,0,'H'} 132{"hostname",required_argument,0,'H'}
133 133
134#define COPYRIGHT "Copyright (c) %s Nagios Plugin Development Team\n\ 134#define COPYRIGHT "Copyright (c) %s Monitoring Plugins Development Team\n\
135\t<%s>\n\n" 135\t<%s>\n\n"
136 136
137#define UT_HLP_VRS _("\ 137#define UT_HLP_VRS _("\
@@ -159,7 +159,8 @@ char *fperfdata (const char *,
159 159
160#define UT_VERBOSE _("\ 160#define UT_VERBOSE _("\
161 -v, --verbose\n\ 161 -v, --verbose\n\
162 Show details for command-line debugging (Nagios may truncate output)\n") 162 Show details for command-line debugging (output may be truncated by\n\
163 the monitoring system)\n")
163 164
164#define UT_WARN_CRIT _("\ 165#define UT_WARN_CRIT _("\
165 -w, --warning=DOUBLE\n\ 166 -w, --warning=DOUBLE\n\
@@ -173,31 +174,36 @@ char *fperfdata (const char *,
173 -c, --critical=RANGE\n\ 174 -c, --critical=RANGE\n\
174 Critical range\n") 175 Critical range\n")
175 176
176#define UT_TIMEOUT _("\ 177#define UT_CONN_TIMEOUT _("\
177 -t, --timeout=INTEGER\n\ 178 -t, --timeout=INTEGER\n\
178 Seconds before connection times out (default: %d)\n") 179 Seconds before connection times out (default: %d)\n")
179 180
181#define UT_PLUG_TIMEOUT _("\
182 -t, --timeout=INTEGER\n\
183 Seconds before plugin times out (default: %d)\n")
184
180#ifdef NP_EXTRA_OPTS 185#ifdef NP_EXTRA_OPTS
181#define UT_EXTRA_OPTS _("\ 186#define UT_EXTRA_OPTS _("\
182 --extra-opts=[section][@file]\n\ 187 --extra-opts=[section][@file]\n\
183 Read options from an ini file. See http://nagiosplugins.org/extra-opts\n\ 188 Read options from an ini file. See\n\
189 https://www.monitoring-plugins.org/doc/extra-opts.html\n\
184 for usage and examples.\n") 190 for usage and examples.\n")
185#else 191#else
186#define UT_EXTRA_OPTS "" 192#define UT_EXTRA_OPTS " \b"
187#endif 193#endif
188 194
189#define UT_THRESHOLDS_NOTES _("\ 195#define UT_THRESHOLDS_NOTES _("\
190 See:\n\ 196 See:\n\
191 http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT\n\ 197 https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n\
192 for THRESHOLD format and examples.\n") 198 for THRESHOLD format and examples.\n")
193 199
194#define UT_SUPPORT _("\n\ 200#define UT_SUPPORT _("\n\
195Send email to nagios-users@lists.sourceforge.net if you have questions\n\ 201Send email to help@monitoring-plugins.org if you have questions regarding\n\
196regarding use of this software. To submit patches or suggest improvements,\n\ 202use of this software. To submit patches or suggest improvements, send email\n\
197send email to nagiosplug-devel@lists.sourceforge.net\n\n") 203to devel@monitoring-plugins.org\n\n")
198 204
199#define UT_NOWARRANTY _("\n\ 205#define UT_NOWARRANTY _("\n\
200The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n\ 206The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n\
201copies of the plugins under the terms of the GNU General Public License.\n\ 207copies of the plugins under the terms of the GNU General Public License.\n\
202For more information about these matters, see the file named COPYING.\n") 208For more information about these matters, see the file named COPYING.\n")
203 209