diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | THANKS.in | 5 | ||||
-rw-r--r-- | configure.in | 91 | ||||
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 15 | ||||
-rwxr-xr-x | plugins-scripts/check_sensors.sh | 33 | ||||
-rw-r--r-- | plugins/Makefile.am | 95 | ||||
-rw-r--r-- | plugins/check_apt.c | 12 | ||||
-rw-r--r-- | plugins/check_dig.c | 2 | ||||
-rw-r--r-- | plugins/check_disk.c | 18 | ||||
-rw-r--r-- | plugins/check_dns.c | 2 | ||||
-rw-r--r-- | plugins/check_http.c | 4 | ||||
-rw-r--r-- | plugins/check_nagios.c | 16 | ||||
-rw-r--r-- | plugins/check_nt.c | 16 | ||||
-rw-r--r-- | plugins/check_ntp_peer.c | 32 | ||||
-rw-r--r-- | plugins/check_procs.c | 1 | ||||
-rw-r--r-- | plugins/check_smtp.c | 26 | ||||
-rw-r--r-- | plugins/runcmd.c | 2 | ||||
-rw-r--r-- | plugins/runcmd.h | 2 | ||||
-rw-r--r-- | plugins/t/check_http.t | 11 |
20 files changed, 208 insertions, 182 deletions
@@ -191,6 +191,7 @@ NP-VERSION-FILE | |||
191 | /plugins/.libs | 191 | /plugins/.libs |
192 | /plugins/Makefile | 192 | /plugins/Makefile |
193 | /plugins/Makefile.in | 193 | /plugins/Makefile.in |
194 | /plugins/libnpcommon.a | ||
194 | /plugins/negate | 195 | /plugins/negate |
195 | /plugins/stamp-h* | 196 | /plugins/stamp-h* |
196 | /plugins/urlize | 197 | /plugins/urlize |
@@ -4,8 +4,14 @@ This file documents the major additions and syntax changes between releases. | |||
4 | ENHANCEMENTS | 4 | ENHANCEMENTS |
5 | New check_dbi plugin for checking an (SQL) database using DBI | 5 | New check_dbi plugin for checking an (SQL) database using DBI |
6 | Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page) | 6 | Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page) |
7 | Add performance data to check_apt | ||
7 | Add performance data to check_procs | 8 | Add performance data to check_procs |
8 | Added -4/-6 options to check_dig (Ville Mattila) | 9 | Added -4/-6 options to check_dig (Ville Mattila) |
10 | New check_oracle --connect option to perform real login | ||
11 | New check_nagios -t option to override the default timeout | ||
12 | New check_disk -N/--include-type option to limit the filesystem types to check | ||
13 | Allow for building the plugins in parallel | ||
14 | Add --without-{dbi,ldap,radius} options to ./configure | ||
9 | 15 | ||
10 | FIXES | 16 | FIXES |
11 | Change the MAIL FROM command generated by check_smtp to be RFC compliant | 17 | Change the MAIL FROM command generated by check_smtp to be RFC compliant |
@@ -277,3 +277,8 @@ Jochen Bern | |||
277 | Anders Kaseorg | 277 | Anders Kaseorg |
278 | Robin Sonefors | 278 | Robin Sonefors |
279 | Alex Bradley | 279 | Alex Bradley |
280 | Brian De Wolf | ||
281 | Richard Leitner | ||
282 | Diego Elio Pettenò | ||
283 | Vaclav Ovsik | ||
284 | Roman Fiedler | ||
diff --git a/configure.in b/configure.in index 1d4ed00..25c0c9c 100644 --- a/configure.in +++ b/configure.in | |||
@@ -255,55 +255,66 @@ fi | |||
255 | LIBS="$_SAVEDLIBS" | 255 | LIBS="$_SAVEDLIBS" |
256 | CPPFLAGS="$_SAVEDCPPFLAGS" | 256 | CPPFLAGS="$_SAVEDCPPFLAGS" |
257 | 257 | ||
258 | AC_ARG_WITH([dbi], [AS_HELP_STRING([--without-dbi], [Skips the dbi plugin])]) | ||
258 | dnl Check for DBI libraries | 259 | dnl Check for DBI libraries |
259 | _SAVEDLIBS="$LIBS" | 260 | AS_IF([test "x$with_dbi" != "xno"], [ |
260 | AC_CHECK_LIB(dbi,dbi_initialize) | 261 | _SAVEDLIBS="$LIBS" |
261 | if test "$ac_cv_lib_dbi_dbi_initialize" = "yes"; then | 262 | AC_CHECK_LIB(dbi,dbi_initialize) |
262 | EXTRAS="$EXTRAS check_dbi" | 263 | if test "$ac_cv_lib_dbi_dbi_initialize" = "yes"; then |
263 | DBILIBS="-ldbi" | 264 | EXTRAS="$EXTRAS check_dbi" |
264 | AC_SUBST(DBILIBS) | 265 | DBILIBS="-ldbi" |
265 | else | 266 | AC_SUBST(DBILIBS) |
266 | AC_MSG_WARN([Skipping dbi plugin]) | 267 | else |
267 | AC_MSG_WARN([install DBI libs to compile this plugin (see REQUIREMENTS).]) | 268 | AC_MSG_WARN([Skipping dbi plugin]) |
268 | fi | 269 | AC_MSG_WARN([install DBI libs to compile this plugin (see REQUIREMENTS).]) |
269 | LIBS="$_SAVEDLIBS" | 270 | fi |
271 | LIBS="$_SAVEDLIBS" | ||
272 | ]) | ||
273 | |||
274 | AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plugin])]) | ||
270 | 275 | ||
271 | dnl Check for radius libraries | 276 | dnl Check for radius libraries |
272 | _SAVEDLIBS="$LIBS" | 277 | AS_IF([test "x$with_radius" != "xno"], [ |
273 | AC_CHECK_LIB(radiusclient,rc_read_config) | 278 | _SAVEDLIBS="$LIBS" |
274 | if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then | 279 | AC_CHECK_LIB(radiusclient,rc_read_config) |
275 | EXTRAS="$EXTRAS check_radius" | 280 | if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then |
276 | RADIUSLIBS="-lradiusclient" | ||
277 | AC_SUBST(RADIUSLIBS) | ||
278 | else | ||
279 | AC_CHECK_LIB(radiusclient-ng,rc_read_config) | ||
280 | if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then | ||
281 | EXTRAS="$EXTRAS check_radius" | 281 | EXTRAS="$EXTRAS check_radius" |
282 | RADIUSLIBS="-lradiusclient-ng" | 282 | RADIUSLIBS="-lradiusclient" |
283 | AC_SUBST(RADIUSLIBS) | 283 | AC_SUBST(RADIUSLIBS) |
284 | else | 284 | else |
285 | AC_MSG_WARN([Skipping radius plugin]) | 285 | AC_CHECK_LIB(radiusclient-ng,rc_read_config) |
286 | AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).]) | 286 | if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then |
287 | EXTRAS="$EXTRAS check_radius" | ||
288 | RADIUSLIBS="-lradiusclient-ng" | ||
289 | AC_SUBST(RADIUSLIBS) | ||
290 | else | ||
291 | AC_MSG_WARN([Skipping radius plugin]) | ||
292 | AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).]) | ||
293 | fi | ||
287 | fi | 294 | fi |
288 | fi | 295 | LIBS="$_SAVEDLIBS" |
289 | LIBS="$_SAVEDLIBS" | 296 | ]) |
297 | |||
298 | AC_ARG_WITH([ldap], [AS_HELP_STRING([--without-ldap], [Skips the LDAP plugin])]) | ||
290 | 299 | ||
291 | dnl Check for LDAP libraries | 300 | dnl Check for LDAP libraries |
292 | _SAVEDLIBS="$LIBS" | 301 | AS_IF([test "x$with_ldap" != "xno"], [ |
293 | AC_CHECK_LIB(ldap,main,,,-llber) | 302 | _SAVEDLIBS="$LIBS" |
294 | if test "$ac_cv_lib_ldap_main" = "yes"; then | 303 | AC_CHECK_LIB(ldap,main,,,-llber) |
295 | LDAPLIBS="-lldap -llber"\ | 304 | if test "$ac_cv_lib_ldap_main" = "yes"; then |
296 | LDAPINCLUDE="-I/usr/include/ldap" | 305 | LDAPLIBS="-lldap -llber"\ |
297 | AC_SUBST(LDAPLIBS) | 306 | LDAPINCLUDE="-I/usr/include/ldap" |
298 | AC_SUBST(LDAPINCLUDE) | 307 | AC_SUBST(LDAPLIBS) |
299 | AC_CHECK_FUNCS(ldap_set_option) | 308 | AC_SUBST(LDAPINCLUDE) |
300 | EXTRAS="$EXTRAS check_ldap" | 309 | AC_CHECK_FUNCS(ldap_set_option) |
301 | AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s) | 310 | EXTRAS="$EXTRAS check_ldap" |
302 | else | 311 | AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s) |
303 | AC_MSG_WARN([Skipping LDAP plugin]) | 312 | else |
304 | AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).]) | 313 | AC_MSG_WARN([Skipping LDAP plugin]) |
305 | fi | 314 | AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).]) |
306 | LIBS="$_SAVEDLIBS" | 315 | fi |
316 | LIBS="$_SAVEDLIBS" | ||
317 | ]) | ||
307 | 318 | ||
308 | dnl Check for headers used by check_ide_smart | 319 | dnl Check for headers used by check_ide_smart |
309 | AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no) | 320 | AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no) |
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 664795e..2a8ab21 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -18,6 +18,7 @@ print_usage() { | |||
18 | echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>" | 18 | echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>" |
19 | echo " $PROGNAME --db <ORACLE_SID>" | 19 | echo " $PROGNAME --db <ORACLE_SID>" |
20 | echo " $PROGNAME --login <ORACLE_SID>" | 20 | echo " $PROGNAME --login <ORACLE_SID>" |
21 | echo " $PROGNAME --connect <ORACLE_SID>" | ||
21 | echo " $PROGNAME --cache <ORACLE_SID> <USER> <PASS> <CRITICAL> <WARNING>" | 22 | echo " $PROGNAME --cache <ORACLE_SID> <USER> <PASS> <CRITICAL> <WARNING>" |
22 | echo " $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING>" | 23 | echo " $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING>" |
23 | echo " $PROGNAME --oranames <Hostname>" | 24 | echo " $PROGNAME --oranames <Hostname>" |
@@ -39,6 +40,8 @@ print_help() { | |||
39 | echo " filesystem for sgadefORACLE_SID.dbf" | 40 | echo " filesystem for sgadefORACLE_SID.dbf" |
40 | echo "--login SID" | 41 | echo "--login SID" |
41 | echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password" | 42 | echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password" |
43 | echo "--connect SID" | ||
44 | echo " Attempt a login and alert if an ORA- error is returned" | ||
42 | echo "--cache" | 45 | echo "--cache" |
43 | echo " Check local database for library and buffer cache hit ratios" | 46 | echo " Check local database for library and buffer cache hit ratios" |
44 | echo " ---> Requires Oracle user/password and SID specified." | 47 | echo " ---> Requires Oracle user/password and SID specified." |
@@ -187,6 +190,18 @@ case "$cmd" in | |||
187 | exit $STATE_CRITICAL | 190 | exit $STATE_CRITICAL |
188 | fi | 191 | fi |
189 | ;; | 192 | ;; |
193 | --connect) | ||
194 | connectchk=`sqlplus $2 < /dev/null` | ||
195 | connectchk2=` echo $connectchk | grep -c ORA-` | ||
196 | if [ ${connectchk2} -eq 0 ] ; then | ||
197 | echo "OK - login successful" | ||
198 | exit $STATE_OK | ||
199 | else | ||
200 | connectchk3=` echo "$connectchk" | grep "ORA-" | head -1` | ||
201 | echo "CRITICAL - $connectchk3" | ||
202 | exit $STATE_CRITICAL | ||
203 | fi | ||
204 | ;; | ||
190 | --cache) | 205 | --cache) |
191 | if [ ${5} -gt ${6} ] ; then | 206 | if [ ${5} -gt ${6} ] ; then |
192 | echo "UNKNOWN - Warning level is less then Crit" | 207 | echo "UNKNOWN - Warning level is less then Crit" |
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index ffaa974..874e104 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh | |||
@@ -44,25 +44,28 @@ case "$1" in | |||
44 | *) | 44 | *) |
45 | sensordata=`sensors 2>&1` | 45 | sensordata=`sensors 2>&1` |
46 | status=$? | 46 | status=$? |
47 | if test "$1" = "-v" -o "$1" = "--verbose"; then | ||
48 | echo ${sensordata} | ||
49 | fi | ||
50 | if test ${status} -eq 127; then | 47 | if test ${status} -eq 127; then |
51 | echo "SENSORS UNKNOWN - command not found (did you install lmsensors?)" | 48 | text="SENSORS UNKNOWN - command not found (did you install lmsensors?)" |
52 | exit $STATE_UNKNOWN | 49 | exit=$STATE_UNKNOWN |
53 | elif test ${status} -ne 0; then | 50 | elif test ${status} -ne 0; then |
54 | echo "WARNING - sensors returned state $status" | 51 | text="WARNING - sensors returned state $status" |
55 | exit $STATE_WARNING | 52 | exit=$STATE_WARNING |
56 | fi | 53 | elif echo ${sensordata} | egrep ALARM > /dev/null; then |
57 | if echo ${sensordata} | egrep ALARM > /dev/null; then | 54 | text="SENSOR CRITICAL - Sensor alarm detected!" |
58 | echo SENSOR CRITICAL - Sensor alarm detected! | 55 | exit=$STATE_CRITICAL |
59 | exit $STATE_CRITICAL | ||
60 | elif echo ${sensordata} | egrep FAULT > /dev/null \ | 56 | elif echo ${sensordata} | egrep FAULT > /dev/null \ |
61 | && test "$1" != "-i" -a "$1" != "--ignore-fault"; then | 57 | && test "$1" != "-i" -a "$1" != "--ignore-fault"; then |
62 | echo SENSOR UNKNOWN - Sensor reported fault | 58 | text="SENSOR UNKNOWN - Sensor reported fault" |
63 | exit $STATE_UNKNOWN | 59 | exit=$STATE_UNKNOWN |
60 | else | ||
61 | text="SENSORS OK" | ||
62 | exit=$STATE_OK | ||
64 | fi | 63 | fi |
65 | echo sensor ok | 64 | |
66 | exit $STATE_OK | 65 | echo "$text" |
66 | if test "$1" = "-v" -o "$1" = "--verbose"; then | ||
67 | echo ${sensordata} | ||
68 | fi | ||
69 | exit $exit | ||
67 | ;; | 70 | ;; |
68 | esac | 71 | esac |
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 0eb0255..64969db 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am | |||
@@ -39,15 +39,19 @@ EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \ | |||
39 | check_nagios check_by_ssh check_dns check_nt check_ide_smart \ | 39 | check_nagios check_by_ssh check_dns check_nt check_ide_smart \ |
40 | check_procs check_mysql_query check_apt check_dbi | 40 | check_procs check_mysql_query check_apt check_dbi |
41 | 41 | ||
42 | EXTRA_DIST = t tests utils.c netutils.c sslutils.c popen.c utils.h netutils.h \ | 42 | EXTRA_DIST = t tests |
43 | popen.h common.h runcmd.c runcmd.h | ||
44 | 43 | ||
45 | PLUGINHDRS = common.h | 44 | PLUGINHDRS = common.h |
46 | 45 | ||
47 | BASEOBJS = utils.o ../lib/libnagiosplug.a ../gl/libgnu.a | 46 | noinst_LIBRARIES = libnpcommon.a |
48 | NETOBJS = netutils.o $(BASEOBJS) $(EXTRA_NETOBJS) | 47 | |
49 | SSLOBJS = sslutils.o | 48 | libnpcommon_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 | |||
51 | BASEOBJS = libnpcommon.a ../lib/libnagiosplug.a ../gl/libgnu.a | ||
52 | NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS) | ||
50 | NETLIBS = $(NETOBJS) $(SOCKETLIBS) | 53 | NETLIBS = $(NETOBJS) $(SOCKETLIBS) |
54 | SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) | ||
51 | 55 | ||
52 | TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir) | 56 | TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir) |
53 | 57 | ||
@@ -62,19 +66,19 @@ test-debug: | |||
62 | ############################################################################## | 66 | ############################################################################## |
63 | # the actual targets | 67 | # the actual targets |
64 | 68 | ||
65 | check_apt_LDADD = $(BASEOBJS) runcmd.o | 69 | check_apt_LDADD = $(BASEOBJS) |
66 | check_cluster_LDADD = $(BASEOBJS) | 70 | check_cluster_LDADD = $(BASEOBJS) |
67 | check_dbi_LDADD = $(NETLIBS) $(DBILIBS) | 71 | check_dbi_LDADD = $(NETLIBS) $(DBILIBS) |
68 | check_dig_LDADD = $(NETLIBS) runcmd.o | 72 | check_dig_LDADD = $(NETLIBS) |
69 | check_disk_LDADD = $(BASEOBJS) popen.o | 73 | check_disk_LDADD = $(BASEOBJS) |
70 | check_dns_LDADD = $(NETLIBS) runcmd.o | 74 | check_dns_LDADD = $(NETLIBS) |
71 | check_dummy_LDADD = $(BASEOBJS) | 75 | check_dummy_LDADD = $(BASEOBJS) |
72 | check_fping_LDADD = $(NETLIBS) popen.o | 76 | check_fping_LDADD = $(NETLIBS) |
73 | check_game_LDADD = $(BASEOBJS) runcmd.o | 77 | check_game_LDADD = $(BASEOBJS) |
74 | check_http_LDADD = $(SSLOBJS) $(NETLIBS) $(SSLLIBS) | 78 | check_http_LDADD = $(SSLOBJS) |
75 | check_hpjd_LDADD = $(NETLIBS) popen.o | 79 | check_hpjd_LDADD = $(NETLIBS) |
76 | check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS) | 80 | check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS) |
77 | check_load_LDADD = $(BASEOBJS) popen.o | 81 | check_load_LDADD = $(BASEOBJS) |
78 | check_mrtg_LDADD = $(BASEOBJS) | 82 | check_mrtg_LDADD = $(BASEOBJS) |
79 | check_mrtgtraf_LDADD = $(BASEOBJS) | 83 | check_mrtgtraf_LDADD = $(BASEOBJS) |
80 | check_mysql_CFLAGS = $(MYSQLCFLAGS) -DNP_VERSION='"$(NP_VERSION)"' | 84 | check_mysql_CFLAGS = $(MYSQLCFLAGS) -DNP_VERSION='"$(NP_VERSION)"' |
@@ -83,22 +87,22 @@ check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS) | |||
83 | check_mysql_query_CFLAGS = $(MYSQLCFLAGS) -DNP_VERSION='"$(NP_VERSION)"' | 87 | check_mysql_query_CFLAGS = $(MYSQLCFLAGS) -DNP_VERSION='"$(NP_VERSION)"' |
84 | check_mysql_query_CPPFLAGS = $(MYSQLINCLUDE) | 88 | check_mysql_query_CPPFLAGS = $(MYSQLINCLUDE) |
85 | check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS) | 89 | check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS) |
86 | check_nagios_LDADD = $(BASEOBJS) runcmd.o | 90 | check_nagios_LDADD = $(BASEOBJS) |
87 | check_nt_LDADD = $(NETLIBS) | 91 | check_nt_LDADD = $(NETLIBS) |
88 | check_ntp_LDADD = $(NETLIBS) $(MATHLIBS) | 92 | check_ntp_LDADD = $(NETLIBS) $(MATHLIBS) |
89 | check_ntp_peer_LDADD = $(NETLIBS) $(MATHLIBS) | 93 | check_ntp_peer_LDADD = $(NETLIBS) $(MATHLIBS) |
90 | check_nwstat_LDADD = $(NETLIBS) | 94 | check_nwstat_LDADD = $(NETLIBS) |
91 | check_overcr_LDADD = $(NETLIBS) | 95 | check_overcr_LDADD = $(NETLIBS) |
92 | check_pgsql_LDADD = $(NETLIBS) $(PGLIBS) | 96 | check_pgsql_LDADD = $(NETLIBS) $(PGLIBS) |
93 | check_ping_LDADD = $(NETLIBS) popen.o | 97 | check_ping_LDADD = $(NETLIBS) |
94 | check_procs_LDADD = $(BASEOBJS) | 98 | check_procs_LDADD = $(BASEOBJS) |
95 | check_radius_LDADD = $(NETLIBS) $(RADIUSLIBS) | 99 | check_radius_LDADD = $(NETLIBS) $(RADIUSLIBS) |
96 | check_real_LDADD = $(NETLIBS) | 100 | check_real_LDADD = $(NETLIBS) |
97 | check_snmp_LDADD = $(BASEOBJS) | 101 | check_snmp_LDADD = $(BASEOBJS) |
98 | check_smtp_LDADD = $(SSLOBJS) $(NETLIBS) $(SSLLIBS) | 102 | check_smtp_LDADD = $(SSLOBJS) |
99 | check_ssh_LDADD = $(NETLIBS) | 103 | check_ssh_LDADD = $(NETLIBS) |
100 | check_swap_LDADD = $(MATHLIBS) $(BASEOBJS) popen.o | 104 | check_swap_LDADD = $(MATHLIBS) $(BASEOBJS) |
101 | check_tcp_LDADD = $(SSLOBJS) $(NETLIBS) $(SSLLIBS) | 105 | check_tcp_LDADD = $(SSLOBJS) |
102 | check_time_LDADD = $(NETLIBS) | 106 | check_time_LDADD = $(NETLIBS) |
103 | check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS) | 107 | check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS) |
104 | check_ups_LDADD = $(NETLIBS) | 108 | check_ups_LDADD = $(NETLIBS) |
@@ -106,62 +110,11 @@ check_users_LDADD = $(BASEOBJS) | |||
106 | check_by_ssh_LDADD = $(NETLIBS) | 110 | check_by_ssh_LDADD = $(NETLIBS) |
107 | check_ide_smart_LDADD = $(BASEOBJS) | 111 | check_ide_smart_LDADD = $(BASEOBJS) |
108 | negate_LDADD = $(BASEOBJS) | 112 | negate_LDADD = $(BASEOBJS) |
109 | urlize_LDADD = $(BASEOBJS) popen.o | 113 | urlize_LDADD = $(BASEOBJS) |
110 | |||
111 | check_apt_DEPENDENCIES = check_apt.c $(BASEOBJS) runcmd.o $(DEPLIBS) | ||
112 | check_cluster_DEPENDENCIES = check_cluster.c $(BASEOBJS) $(DEPLIBS) | ||
113 | check_dbi_DEPENDENCIES = check_dbi.c $(NETOBJS) $(DEPLIBS) | ||
114 | check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) runcmd.o $(DEPLIBS) | ||
115 | check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) popen.o $(DEPLIBS) | ||
116 | check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) runcmd.o $(DEPLIBS) | ||
117 | check_dummy_DEPENDENCIES = check_dummy.c $(DEPLIBS) | ||
118 | check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) popen.o $(DEPLIBS) | ||
119 | check_game_DEPENDENCIES = check_game.c $(DEPLIBS) runcmd.o | ||
120 | check_http_DEPENDENCIES = check_http.c $(SSLOBJS) $(NETOBJS) $(DEPLIBS) | ||
121 | check_hpjd_DEPENDENCIES = check_hpjd.c $(NETOBJS) popen.o $(DEPLIBS) | ||
122 | check_ide_smart_DEPENDENCIES = check_ide_smart.c $(BASEOBJS) $(DEPLIBS) | ||
123 | check_ldap_DEPENDENCIES = check_ldap.c $(NETOBJS) $(DEPLIBS) | ||
124 | check_load_DEPENDENCIES = check_load.c $(BASEOBJS) popen.o $(DEPLIBS) | ||
125 | check_mrtg_DEPENDENCIES = check_mrtg.c $(DEPLIBS) | ||
126 | check_mrtgtraf_DEPENDENCIES = check_mrtgtraf.c $(DEPLIBS) | ||
127 | check_mysql_DEPENDENCIES = check_mysql.c $(NETOBJS) $(DEPLIBS) | ||
128 | check_mysql_query_DEPENDENCIES = check_mysql_query.c $(NETOBJS) $(DEPLIBS) | ||
129 | check_nagios_DEPENDENCIES = check_nagios.c $(BASEOBJS) runcmd.o $(DEPLIBS) | ||
130 | check_nt_DEPENDENCIES = check_nt.c $(NETOBJS) $(DEPLIBS) | ||
131 | check_ntp_DEPENDENCIES = check_ntp.c $(NETOBJS) $(DEPLIBS) | ||
132 | check_ntp_peer_DEPENDENCIES = check_ntp_peer.c $(NETOBJS) $(DEPLIBS) | ||
133 | check_nwstat_DEPENDENCIES = check_nwstat.c $(NETOBJS) $(DEPLIBS) | ||
134 | check_overcr_DEPENDENCIES = check_overcr.c $(NETOBJS) $(DEPLIBS) | ||
135 | check_pgsql_DEPENDENCIES = check_pgsql.c $(NETOBJS) $(DEPLIBS) | ||
136 | check_ping_DEPENDENCIES = check_ping.c $(NETOBJS) popen.o $(DEPLIBS) | ||
137 | check_procs_DEPENDENCIES = check_procs.c $(BASEOBJS) popen.o $(DEPLIBS) | ||
138 | check_radius_DEPENDENCIES = check_radius.c $(NETOBJS) $(DEPLIBS) | ||
139 | check_real_DEPENDENCIES = check_real.c $(NETOBJS) $(DEPLIBS) | ||
140 | check_snmp_DEPENDENCIES = check_snmp.c $(BASEOBJS) $(DEPLIBS) | ||
141 | check_smtp_DEPENDENCIES = check_smtp.c $(SSLOBJS) $(NETOBJS) $(DEPLIBS) | ||
142 | check_ssh_DEPENDENCIES = check_ssh.c $(NETOBJS) $(DEPLIBS) | ||
143 | check_swap_DEPENDENCIES = check_swap.c $(BASEOBJS) popen.o $(DEPLIBS) | ||
144 | check_tcp_DEPENDENCIES = check_tcp.c $(SSLOBJS) $(NETOBJS) $(DEPLIBS) | ||
145 | check_time_DEPENDENCIES = check_time.c $(NETOBJS) $(DEPLIBS) | ||
146 | check_ntp_time_DEPENDENCIES = check_ntp_time.c $(NETOBJS) $(DEPLIBS) | ||
147 | check_ups_DEPENDENCIES = check_ups.c $(NETOBJS) $(DEPLIBS) | ||
148 | check_users_DEPENDENCIES = check_users.c $(BASEOBJS) popen.o $(DEPLIBS) | ||
149 | check_by_ssh_DEPENDENCIES = check_by_ssh.c $(NETOBJS) $(DEPLIBS) | ||
150 | negate_DEPENDENCIES = negate.c $(BASEOBJS) $(DEPLIBS) | ||
151 | urlize_DEPENDENCIES = urlize.c $(BASEOBJS) popen.o $(DEPLIBS) | ||
152 | 114 | ||
153 | ############################################################################## | 115 | ############################################################################## |
154 | # secondary dependencies | 116 | # secondary dependencies |
155 | 117 | ||
156 | popen.o: popen.c popen.h $(PLUGINHDRS) | ||
157 | |||
158 | runcmd.o: runcmd.c runcmd.h $(PLUGINHDRS) | ||
159 | |||
160 | utils.o: utils.c utils.h $(PLUGINHDRS) | ||
161 | |||
162 | netutils.o: netutils.c netutils.h $(PLUGINHDRS) | ||
163 | sslutils.o: sslutils.c netutils.h $(PLUGINHDRS) | ||
164 | |||
165 | all-local: $(check_tcp_programs) | 118 | all-local: $(check_tcp_programs) |
166 | 119 | ||
167 | $(check_tcp_programs): check_tcp | 120 | $(check_tcp_programs): check_tcp |
diff --git a/plugins/check_apt.c b/plugins/check_apt.c index cf18661..daeb757 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c | |||
@@ -112,11 +112,11 @@ int main (int argc, char **argv) { | |||
112 | result = max_state(result, STATE_CRITICAL); | 112 | result = max_state(result, STATE_CRITICAL); |
113 | } else if(packages_available > 0){ | 113 | } else if(packages_available > 0){ |
114 | result = max_state(result, STATE_WARNING); | 114 | result = max_state(result, STATE_WARNING); |
115 | } else { | 115 | } else if(result > STATE_UNKNOWN){ |
116 | result = max_state(result, STATE_OK); | 116 | result = STATE_UNKNOWN; |
117 | } | 117 | } |
118 | 118 | ||
119 | printf(_("APT %s: %d packages available for %s (%d critical updates). %s%s%s%s\n"), | 119 | printf(_("APT %s: %d packages available for %s (%d critical updates). %s%s%s%s|available_upgrades=%d;;;0 critical_updates=%d;;;0\n"), |
120 | state_text(result), | 120 | state_text(result), |
121 | packages_available, | 121 | packages_available, |
122 | (upgrade==DIST_UPGRADE)?"dist-upgrade":"upgrade", | 122 | (upgrade==DIST_UPGRADE)?"dist-upgrade":"upgrade", |
@@ -124,7 +124,9 @@ 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)?". run with -v for information.":"", |
128 | packages_available, | ||
129 | sec_count | ||
128 | ); | 130 | ); |
129 | 131 | ||
130 | return result; | 132 | return result; |
@@ -444,7 +446,7 @@ print_help (void) | |||
444 | printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); | 446 | printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); |
445 | printf (" %s\n", "-i, --include=REGEXP"); | 447 | printf (" %s\n", "-i, --include=REGEXP"); |
446 | printf (" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times")); | 448 | printf (" %s\n", _("Include only packages matching REGEXP. Can be specified multiple times")); |
447 | printf (" %s\n", _("the values will be combined together. Any patches matching this list")); | 449 | printf (" %s\n", _("the values will be combined together. Any packages matching this list")); |
448 | printf (" %s\n", _("cause the plugin to return WARNING status. Others will be ignored.")); | 450 | printf (" %s\n", _("cause the plugin to return WARNING status. Others will be ignored.")); |
449 | printf (" %s\n", _("Default is to include all packages.")); | 451 | printf (" %s\n", _("Default is to include all packages.")); |
450 | printf (" %s\n", "-e, --exclude=REGEXP"); | 452 | printf (" %s\n", "-e, --exclude=REGEXP"); |
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index 3c80cb7..c113d87 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
@@ -78,7 +78,7 @@ main (int argc, char **argv) | |||
78 | textdomain (PACKAGE); | 78 | textdomain (PACKAGE); |
79 | 79 | ||
80 | /* Set signal handling and alarm */ | 80 | /* Set signal handling and alarm */ |
81 | if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) | 81 | if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) |
82 | usage_va(_("Cannot catch SIGALRM")); | 82 | usage_va(_("Cannot catch SIGALRM")); |
83 | 83 | ||
84 | /* Parse extra opts if any */ | 84 | /* Parse extra opts if any */ |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 6ba7bdf..4ea0393 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -91,9 +91,12 @@ static int stat_remote_fs = 0; | |||
91 | 91 | ||
92 | /* Linked list of filesystem types to omit. | 92 | /* Linked list of filesystem types to omit. |
93 | If the list is empty, don't exclude any types. */ | 93 | If the list is empty, don't exclude any types. */ |
94 | |||
95 | static struct name_list *fs_exclude_list; | 94 | static struct name_list *fs_exclude_list; |
96 | 95 | ||
96 | /* Linked list of filesystem types to check. | ||
97 | If the list is empty, include all types. */ | ||
98 | static struct name_list *fs_include_list; | ||
99 | |||
97 | static struct name_list *dp_exclude_list; | 100 | static struct name_list *dp_exclude_list; |
98 | 101 | ||
99 | static struct parameter_list *path_select_list = NULL; | 102 | static struct parameter_list *path_select_list = NULL; |
@@ -255,6 +258,9 @@ main (int argc, char **argv) | |||
255 | (np_find_name (dp_exclude_list, me->me_devname) || | 258 | (np_find_name (dp_exclude_list, me->me_devname) || |
256 | np_find_name (dp_exclude_list, me->me_mountdir))) { | 259 | np_find_name (dp_exclude_list, me->me_mountdir))) { |
257 | continue; | 260 | continue; |
261 | /* Skip not included fstypes */ | ||
262 | } else if (fs_include_list && !np_find_name (fs_include_list, me->me_type)) { | ||
263 | continue; | ||
258 | } | 264 | } |
259 | 265 | ||
260 | stat_path(path); | 266 | stat_path(path); |
@@ -419,6 +425,7 @@ process_arguments (int argc, char **argv) | |||
419 | {"partition", required_argument, 0, 'p'}, | 425 | {"partition", required_argument, 0, 'p'}, |
420 | {"exclude_device", required_argument, 0, 'x'}, | 426 | {"exclude_device", required_argument, 0, 'x'}, |
421 | {"exclude-type", required_argument, 0, 'X'}, | 427 | {"exclude-type", required_argument, 0, 'X'}, |
428 | {"include-type", required_argument, 0, 'N'}, | ||
422 | {"group", required_argument, 0, 'g'}, | 429 | {"group", required_argument, 0, 'g'}, |
423 | {"eregi-path", required_argument, 0, 'R'}, | 430 | {"eregi-path", required_argument, 0, 'R'}, |
424 | {"eregi-partition", required_argument, 0, 'R'}, | 431 | {"eregi-partition", required_argument, 0, 'R'}, |
@@ -452,7 +459,7 @@ process_arguments (int argc, char **argv) | |||
452 | strcpy (argv[c], "-t"); | 459 | strcpy (argv[c], "-t"); |
453 | 460 | ||
454 | while (1) { | 461 | while (1) { |
455 | c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklLg:R:r:i:I:MEA", longopts, &option); | 462 | c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:N:mklLg:R:r:i:I:MEA", longopts, &option); |
456 | 463 | ||
457 | if (c == -1 || c == EOF) | 464 | if (c == -1 || c == EOF) |
458 | break; | 465 | break; |
@@ -591,6 +598,9 @@ process_arguments (int argc, char **argv) | |||
591 | case 'X': /* exclude file system type */ | 598 | case 'X': /* exclude file system type */ |
592 | np_add_name(&fs_exclude_list, optarg); | 599 | np_add_name(&fs_exclude_list, optarg); |
593 | break; | 600 | break; |
601 | case 'N': /* include file system type */ | ||
602 | np_add_name(&fs_include_list, optarg); | ||
603 | break; | ||
594 | case 'v': /* verbose */ | 604 | case 'v': /* verbose */ |
595 | verbose++; | 605 | verbose++; |
596 | break; | 606 | break; |
@@ -900,6 +910,8 @@ print_help (void) | |||
900 | printf (UT_VERBOSE); | 910 | printf (UT_VERBOSE); |
901 | printf (" %s\n", "-X, --exclude-type=TYPE"); | 911 | printf (" %s\n", "-X, --exclude-type=TYPE"); |
902 | printf (" %s\n", _("Ignore all filesystems of indicated type (may be repeated)")); | 912 | printf (" %s\n", _("Ignore all filesystems of indicated type (may be repeated)")); |
913 | printf (" %s\n", "-N, --include-type=TYPE"); | ||
914 | printf (" %s\n", _("Check only filesystems of indicated type (may be repeated)")); | ||
903 | 915 | ||
904 | printf ("\n"); | 916 | printf ("\n"); |
905 | printf ("%s\n", _("Examples:")); | 917 | printf ("%s\n", _("Examples:")); |
@@ -922,7 +934,7 @@ print_usage (void) | |||
922 | printf ("%s\n", _("Usage:")); | 934 | printf ("%s\n", _("Usage:")); |
923 | printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname); | 935 | printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname); |
924 | printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); | 936 | printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); |
925 | printf ("[-t timeout] [-u unit] [-v] [-X type]\n"); | 937 | printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); |
926 | } | 938 | } |
927 | 939 | ||
928 | void | 940 | void |
diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 91af730..ac6cfc3 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c | |||
@@ -91,7 +91,7 @@ main (int argc, char **argv) | |||
91 | textdomain (PACKAGE); | 91 | textdomain (PACKAGE); |
92 | 92 | ||
93 | /* Set signal handling and alarm */ | 93 | /* Set signal handling and alarm */ |
94 | if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { | 94 | if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) { |
95 | usage_va(_("Cannot catch SIGALRM")); | 95 | usage_va(_("Cannot catch SIGALRM")); |
96 | } | 96 | } |
97 | 97 | ||
diff --git a/plugins/check_http.c b/plugins/check_http.c index 9231a55..110875d 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -43,7 +43,6 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
43 | #include "base64.h" | 43 | #include "base64.h" |
44 | #include <ctype.h> | 44 | #include <ctype.h> |
45 | 45 | ||
46 | #define INPUT_DELIMITER ";" | ||
47 | #define STICKY_NONE 0 | 46 | #define STICKY_NONE 0 |
48 | #define STICKY_HOST 1 | 47 | #define STICKY_HOST 1 |
49 | #define STICKY_PORT 2 | 48 | #define STICKY_PORT 2 |
@@ -854,8 +853,7 @@ check_http (void) | |||
854 | /* optionally send any other header tag */ | 853 | /* optionally send any other header tag */ |
855 | if (http_opt_headers_count) { | 854 | if (http_opt_headers_count) { |
856 | for (i = 0; i < http_opt_headers_count ; i++) { | 855 | for (i = 0; i < http_opt_headers_count ; i++) { |
857 | for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER))) | 856 | xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]); |
858 | xasprintf (&buf, "%s%s\r\n", buf, pos); | ||
859 | } | 857 | } |
860 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ | 858 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ |
861 | /* Covered in a testcase in tests/check_http.t */ | 859 | /* Covered in a testcase in tests/check_http.t */ |
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index c8cdbc0..4fd6342 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c | |||
@@ -205,6 +205,7 @@ process_arguments (int argc, char **argv) | |||
205 | {"filename", required_argument, 0, 'F'}, | 205 | {"filename", required_argument, 0, 'F'}, |
206 | {"expires", required_argument, 0, 'e'}, | 206 | {"expires", required_argument, 0, 'e'}, |
207 | {"command", required_argument, 0, 'C'}, | 207 | {"command", required_argument, 0, 'C'}, |
208 | {"timeout", optional_argument, 0, 't'}, | ||
208 | {"version", no_argument, 0, 'V'}, | 209 | {"version", no_argument, 0, 'V'}, |
209 | {"help", no_argument, 0, 'h'}, | 210 | {"help", no_argument, 0, 'h'}, |
210 | {"verbose", no_argument, 0, 'v'}, | 211 | {"verbose", no_argument, 0, 'v'}, |
@@ -226,7 +227,7 @@ process_arguments (int argc, char **argv) | |||
226 | } | 227 | } |
227 | 228 | ||
228 | while (1) { | 229 | while (1) { |
229 | c = getopt_long (argc, argv, "+hVvF:C:e:", longopts, &option); | 230 | c = getopt_long (argc, argv, "+hVvF:C:e:t:", longopts, &option); |
230 | 231 | ||
231 | if (c == -1 || c == EOF || c == 1) | 232 | if (c == -1 || c == EOF || c == 1) |
232 | break; | 233 | break; |
@@ -251,6 +252,13 @@ process_arguments (int argc, char **argv) | |||
251 | die (STATE_UNKNOWN, | 252 | die (STATE_UNKNOWN, |
252 | _("Expiration time must be an integer (seconds)\n")); | 253 | _("Expiration time must be an integer (seconds)\n")); |
253 | break; | 254 | break; |
255 | case 't': /* timeout */ | ||
256 | if (is_intnonneg (optarg)) | ||
257 | timeout_interval = atoi (optarg); | ||
258 | else | ||
259 | die (STATE_UNKNOWN, | ||
260 | _("Timeout must be an integer (seconds)\n")); | ||
261 | break; | ||
254 | case 'v': | 262 | case 'v': |
255 | verbose++; | 263 | verbose++; |
256 | break; | 264 | break; |
@@ -296,11 +304,13 @@ print_help (void) | |||
296 | printf (" %s\n", _("Minutes aging after which logfile is considered stale")); | 304 | printf (" %s\n", _("Minutes aging after which logfile is considered stale")); |
297 | printf (" %s\n", "-C, --command=STRING"); | 305 | printf (" %s\n", "-C, --command=STRING"); |
298 | printf (" %s\n", _("Substring to search for in process arguments")); | 306 | printf (" %s\n", _("Substring to search for in process arguments")); |
307 | printf (" %s\n", "-t, --timeout=INTEGER"); | ||
308 | printf (" %s\n", _("Timeout for the plugin in seconds")); | ||
299 | printf (UT_VERBOSE); | 309 | printf (UT_VERBOSE); |
300 | 310 | ||
301 | printf ("\n"); | 311 | printf ("\n"); |
302 | printf ("%s\n", _("Examples:")); | 312 | printf ("%s\n", _("Examples:")); |
303 | printf (" %s\n", "check_nagios -e 5 -F /usr/local/nagios/var/status.log -C /usr/local/nagios/bin/nagios"); | 313 | printf (" %s\n", "check_nagios -t 20 -e 5 -F /usr/local/nagios/var/status.log -C /usr/local/nagios/bin/nagios"); |
304 | 314 | ||
305 | printf (UT_SUPPORT); | 315 | printf (UT_SUPPORT); |
306 | } | 316 | } |
@@ -311,5 +321,5 @@ void | |||
311 | print_usage (void) | 321 | print_usage (void) |
312 | { | 322 | { |
313 | printf ("%s\n", _("Usage:")); | 323 | printf ("%s\n", _("Usage:")); |
314 | printf ("%s -F <status log file> -e <expire_minutes> -C <process_string>\n", progname); | 324 | printf ("%s -F <status log file> -t <timeout_seconds> -e <expire_minutes> -C <process_string>\n", progname); |
315 | } | 325 | } |
diff --git a/plugins/check_nt.c b/plugins/check_nt.c index 89c4d8d..52bbd1c 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c | |||
@@ -94,6 +94,7 @@ int main(int argc, char **argv){ | |||
94 | char *description=NULL,*counter_unit = NULL; | 94 | char *description=NULL,*counter_unit = NULL; |
95 | char *minval = NULL, *maxval = NULL, *errcvt = NULL; | 95 | char *minval = NULL, *maxval = NULL, *errcvt = NULL; |
96 | char *fds=NULL, *tds=NULL; | 96 | char *fds=NULL, *tds=NULL; |
97 | char *numstr; | ||
97 | 98 | ||
98 | double total_disk_space=0; | 99 | double total_disk_space=0; |
99 | double free_disk_space=0; | 100 | double free_disk_space=0; |
@@ -265,7 +266,10 @@ int main(int argc, char **argv){ | |||
265 | xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, | 266 | xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, |
266 | (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list); | 267 | (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list); |
267 | fetch_data (server_address, server_port, send_buffer); | 268 | fetch_data (server_address, server_port, send_buffer); |
268 | return_code=atoi(strtok(recv_buffer,"&")); | 269 | numstr = strtok(recv_buffer,"&"); |
270 | if (numstr == NULL) | ||
271 | die(STATE_UNKNOWN, _("could not fetch information from server\n")); | ||
272 | return_code=atoi(numstr); | ||
269 | temp_string=strtok(NULL,"&"); | 273 | temp_string=strtok(NULL,"&"); |
270 | output_message = strdup (temp_string); | 274 | output_message = strdup (temp_string); |
271 | } | 275 | } |
@@ -275,8 +279,14 @@ int main(int argc, char **argv){ | |||
275 | 279 | ||
276 | xasprintf(&send_buffer,"%s&7", req_password); | 280 | xasprintf(&send_buffer,"%s&7", req_password); |
277 | fetch_data (server_address, server_port, send_buffer); | 281 | fetch_data (server_address, server_port, send_buffer); |
278 | mem_commitLimit=atof(strtok(recv_buffer,"&")); | 282 | numstr = strtok(recv_buffer,"&"); |
279 | mem_commitByte=atof(strtok(NULL,"&")); | 283 | if (numstr == NULL) |
284 | die(STATE_UNKNOWN, _("could not fetch information from server\n")); | ||
285 | mem_commitLimit=atof(numstr); | ||
286 | numstr = strtok(NULL,"&"); | ||
287 | if (numstr == NULL) | ||
288 | die(STATE_UNKNOWN, _("could not fetch information from server\n")); | ||
289 | mem_commitByte=atof(numstr); | ||
280 | percent_used_space = (mem_commitByte / mem_commitLimit) * 100; | 290 | percent_used_space = (mem_commitByte / mem_commitLimit) * 100; |
281 | warning_used_space = ((float)warning_value / 100) * mem_commitLimit; | 291 | warning_used_space = ((float)warning_value / 100) * mem_commitLimit; |
282 | critical_used_space = ((float)critical_value / 100) * mem_commitLimit; | 292 | critical_used_space = ((float)critical_value / 100) * mem_commitLimit; |
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index b59c056..76152e1 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c | |||
@@ -241,15 +241,19 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji | |||
241 | DBG(printf("sending READSTAT request")); | 241 | DBG(printf("sending READSTAT request")); |
242 | write(conn, &req, SIZEOF_NTPCM(req)); | 242 | write(conn, &req, SIZEOF_NTPCM(req)); |
243 | DBG(print_ntp_control_message(&req)); | 243 | DBG(print_ntp_control_message(&req)); |
244 | /* Attempt to read the largest size packet possible */ | 244 | |
245 | req.count=htons(MAX_CM_SIZE); | 245 | do { |
246 | DBG(printf("recieving READSTAT response")) | 246 | /* Attempt to read the largest size packet possible */ |
247 | if(read(conn, &req, SIZEOF_NTPCM(req)) == -1) | 247 | req.count=htons(MAX_CM_SIZE); |
248 | die(STATE_CRITICAL, "NTP CRITICAL: No response from NTP server\n"); | 248 | DBG(printf("recieving READSTAT response")) |
249 | DBG(print_ntp_control_message(&req)); | 249 | if(read(conn, &req, SIZEOF_NTPCM(req)) == -1) |
250 | /* discard obviously invalid packets */ | 250 | die(STATE_CRITICAL, "NTP CRITICAL: No response from NTP server\n"); |
251 | if (ntohs(req.count) > MAX_CM_SIZE) | 251 | DBG(print_ntp_control_message(&req)); |
252 | die(STATE_CRITICAL, "NTP CRITICAL: Invalid packet received from NTP server\n"); | 252 | /* discard obviously invalid packets */ |
253 | if (ntohs(req.count) > MAX_CM_SIZE) | ||
254 | die(STATE_CRITICAL, "NTP CRITICAL: Invalid packet received from NTP server\n"); | ||
255 | } while (!(req.op&OP_READSTAT && ntohs(req.seq) == 1)); | ||
256 | |||
253 | if (LI(req.flags) == LI_ALARM) li_alarm = 1; | 257 | if (LI(req.flags) == LI_ALARM) li_alarm = 1; |
254 | /* Each peer identifier is 4 bytes in the data section, which | 258 | /* Each peer identifier is 4 bytes in the data section, which |
255 | * we represent as a ntp_assoc_status_pair datatype. | 259 | * we represent as a ntp_assoc_status_pair datatype. |
@@ -312,10 +316,12 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji | |||
312 | write(conn, &req, SIZEOF_NTPCM(req)); | 316 | write(conn, &req, SIZEOF_NTPCM(req)); |
313 | DBG(print_ntp_control_message(&req)); | 317 | DBG(print_ntp_control_message(&req)); |
314 | 318 | ||
315 | req.count = htons(MAX_CM_SIZE); | 319 | do { |
316 | DBG(printf("receiving READVAR response...\n")); | 320 | req.count = htons(MAX_CM_SIZE); |
317 | read(conn, &req, SIZEOF_NTPCM(req)); | 321 | DBG(printf("receiving READVAR response...\n")); |
318 | DBG(print_ntp_control_message(&req)); | 322 | read(conn, &req, SIZEOF_NTPCM(req)); |
323 | DBG(print_ntp_control_message(&req)); | ||
324 | } while (!(req.op&OP_READVAR && ntohs(req.seq) == 2)); | ||
319 | 325 | ||
320 | if(!(req.op&REM_ERROR)) | 326 | if(!(req.op&REM_ERROR)) |
321 | xasprintf(&data, "%s%s", data, req.data); | 327 | xasprintf(&data, "%s%s", data, req.data); |
diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 00b032a..6acedc7 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c | |||
@@ -332,6 +332,7 @@ process_arguments (int argc, char **argv) | |||
332 | {"timeout", required_argument, 0, 't'}, | 332 | {"timeout", required_argument, 0, 't'}, |
333 | {"status", required_argument, 0, 's'}, | 333 | {"status", required_argument, 0, 's'}, |
334 | {"ppid", required_argument, 0, 'p'}, | 334 | {"ppid", required_argument, 0, 'p'}, |
335 | {"user", required_argument, 0, 'u'}, | ||
335 | {"command", required_argument, 0, 'C'}, | 336 | {"command", required_argument, 0, 'C'}, |
336 | {"vsz", required_argument, 0, 'z'}, | 337 | {"vsz", required_argument, 0, 'z'}, |
337 | {"rss", required_argument, 0, 'r'}, | 338 | {"rss", required_argument, 0, 'r'}, |
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 79fa482..d477a51 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
@@ -99,9 +99,9 @@ char **responses = NULL; | |||
99 | char *authtype = NULL; | 99 | char *authtype = NULL; |
100 | char *authuser = NULL; | 100 | char *authuser = NULL; |
101 | char *authpass = NULL; | 101 | char *authpass = NULL; |
102 | int warning_time = 0; | 102 | double warning_time = 0; |
103 | int check_warning_time = FALSE; | 103 | int check_warning_time = FALSE; |
104 | int critical_time = 0; | 104 | double critical_time = 0; |
105 | int check_critical_time = FALSE; | 105 | int check_critical_time = FALSE; |
106 | int verbose = 0; | 106 | int verbose = 0; |
107 | int use_ssl = FALSE; | 107 | int use_ssl = FALSE; |
@@ -417,9 +417,9 @@ main (int argc, char **argv) | |||
417 | elapsed_time = (double)microsec / 1.0e6; | 417 | elapsed_time = (double)microsec / 1.0e6; |
418 | 418 | ||
419 | if (result == STATE_OK) { | 419 | if (result == STATE_OK) { |
420 | if (check_critical_time && elapsed_time > (double) critical_time) | 420 | if (check_critical_time && elapsed_time > critical_time) |
421 | result = STATE_CRITICAL; | 421 | result = STATE_CRITICAL; |
422 | else if (check_warning_time && elapsed_time > (double) warning_time) | 422 | else if (check_warning_time && elapsed_time > warning_time) |
423 | result = STATE_WARNING; | 423 | result = STATE_WARNING; |
424 | } | 424 | } |
425 | 425 | ||
@@ -552,21 +552,19 @@ process_arguments (int argc, char **argv) | |||
552 | nresponses++; | 552 | nresponses++; |
553 | break; | 553 | break; |
554 | case 'c': /* critical time threshold */ | 554 | case 'c': /* critical time threshold */ |
555 | if (is_intnonneg (optarg)) { | 555 | if (!is_nonnegative (optarg)) |
556 | critical_time = atoi (optarg); | 556 | usage4 (_("Critical time must be a positive")); |
557 | check_critical_time = TRUE; | ||
558 | } | ||
559 | else { | 557 | else { |
560 | usage4 (_("Critical time must be a positive integer")); | 558 | critical_time = strtod (optarg, NULL); |
559 | check_critical_time = TRUE; | ||
561 | } | 560 | } |
562 | break; | 561 | break; |
563 | case 'w': /* warning time threshold */ | 562 | case 'w': /* warning time threshold */ |
564 | if (is_intnonneg (optarg)) { | 563 | if (!is_nonnegative (optarg)) |
565 | warning_time = atoi (optarg); | 564 | usage4 (_("Warning time must be a positive")); |
566 | check_warning_time = TRUE; | ||
567 | } | ||
568 | else { | 565 | else { |
569 | usage4 (_("Warning time must be a positive integer")); | 566 | warning_time = strtod (optarg, NULL); |
567 | check_warning_time = TRUE; | ||
570 | } | 568 | } |
571 | break; | 569 | break; |
572 | case 'v': /* verbose */ | 570 | case 'v': /* verbose */ |
diff --git a/plugins/runcmd.c b/plugins/runcmd.c index 7574b12..8aba1e3 100644 --- a/plugins/runcmd.c +++ b/plugins/runcmd.c | |||
@@ -256,7 +256,7 @@ np_runcmd_close(int fd) | |||
256 | 256 | ||
257 | 257 | ||
258 | void | 258 | void |
259 | popen_timeout_alarm_handler (int signo) | 259 | runcmd_timeout_alarm_handler (int signo) |
260 | { | 260 | { |
261 | size_t i; | 261 | size_t i; |
262 | 262 | ||
diff --git a/plugins/runcmd.h b/plugins/runcmd.h index 211dee2..5957562 100644 --- a/plugins/runcmd.h +++ b/plugins/runcmd.h | |||
@@ -39,7 +39,7 @@ typedef struct output output; | |||
39 | 39 | ||
40 | /** prototypes **/ | 40 | /** prototypes **/ |
41 | int np_runcmd(const char *, output *, output *, int); | 41 | int np_runcmd(const char *, output *, output *, int); |
42 | void popen_timeout_alarm_handler(int) | 42 | void runcmd_timeout_alarm_handler(int) |
43 | __attribute__((__noreturn__)); | 43 | __attribute__((__noreturn__)); |
44 | 44 | ||
45 | /* only multi-threaded plugins need to bother with this */ | 45 | /* only multi-threaded plugins need to bother with this */ |
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 0a25c77..6299791 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
@@ -8,7 +8,7 @@ use strict; | |||
8 | use Test::More; | 8 | use Test::More; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | plan tests => 28; | 11 | plan tests => 27; |
12 | 12 | ||
13 | my $successOutput = '/OK.*HTTP.*second/'; | 13 | my $successOutput = '/OK.*HTTP.*second/'; |
14 | 14 | ||
@@ -45,14 +45,9 @@ cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); | |||
45 | like( $res->output, $successOutput, "Output OK" ); | 45 | like( $res->output, $successOutput, "Output OK" ); |
46 | 46 | ||
47 | $res = NPTest->testCmd( | 47 | $res = NPTest->testCmd( |
48 | "./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there;fred:here'" | 48 | "./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" |
49 | ); | 49 | ); |
50 | like( $res->output, '/bob:there\r\nfred:here\r\n/', "Got headers, delimited with ';'" ); | 50 | like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); |
51 | |||
52 | $res = NPTest->testCmd( | ||
53 | "./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there;fred:here' -k 'carl:frown'" | ||
54 | ); | ||
55 | like( $res->output, '/bob:there\r\nfred:here\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); | ||
56 | 51 | ||
57 | $res = NPTest->testCmd( | 52 | $res = NPTest->testCmd( |
58 | "./check_http $host_nonresponsive -wt 1 -ct 2" | 53 | "./check_http $host_nonresponsive -wt 1 -ct 2" |