Commit graph

1355 commits

Author SHA1 Message Date
Sven Nierlein
4ab4c8dd32 make testing check_proc not rely on bash
also grandparents make this test fail but is not a problem in real live.
NPTest->testCmd uses "sh -c" already, so there is no need to do that twice.
2013-11-20 21:42:25 +01:00
Anton Lofgren
77fc3548ae check_procs: ignore plugin parent process
This fixes an issue that appears when running check_procs over NRPE,
where the default shell is configured to (for example) dash, as is the
case on Debian.

dash (and tcsh, and mksh, and probably others), when invoked with -c forks an additional process
to execute the argument string. Contrast this with bash, which does not
do this, provided that the argument string simply can be exec()'d as-is.

To demonstrate:
$ bash -c pstree
init─┬ ..
    ...
	├─sshd─-─sshd───pstree

versus
$ dash -c pstree
init─┬ ..
    ...
	├─sshd─-─sshd───dash───pstree

The consequence of this fork is that the following invocation:
    /opt/plugins/check_procs -a init

will result in this output:

    PROCS OK: 2 processes with args 'init' | processes=2;;;0;

because the check_procs, in addition to finding the actual init process,
finds its parent shell as well.

This example is a bit contrived, but I think it illustrates the
point.

This wouldn't really be a problem, and normally isn't, if it weren't
for the fact that NRPE uses a call to popen() which does exactly the
above (executes '/bin/sh -c ...'), causing inconsistent behaviour
between distributions and much confusion for end users.

The argument may be made that the dash process spawned by NRPE is just a
process like any other, and should therefore be included in the process
count just like any other. However, this is not very intuitive, because
of the previously mentioned inconsistencies.

The argument might also well be made that we're _never_ interested in the
immediate ancestor of the plugin, and while it is unknown how many
installations have already made the necessary modifications to their
setups to make up for the fact that the plugin behaves the way it does,
it is not deemed worthwhile to entertain such workarounds.

Thus, this patch ignores the parent process.

See also these bug reports:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626913
http://sourceforge.net/p/nagiosplug/bugs/512/
https://github.com/nagios-plugins/nagios-plugins/issues/999
https://bugs.op5.com/view.php?id=4398
2013-11-19 23:57:27 +01:00
Holger Weiss
aac0980edb Change default host names for some tests
Testing "nagiosplugins.org" will currently not work.
2013-09-29 00:14:17 +02:00
awiddersheim
d4c5730464 Die on SSL initialization errors
Fixes issue where if an SSL initialization error occurs on a redirect
using -f follow the plugin still returns an OK state.

Closes #1159.
2013-09-26 17:01:28 +02:00
Holger Weiss
6f0366c8b8 check_pgsql: Don't exit UNKNOWN instead of OK
Since commit 912df3ef9b, check_pgsql
exited UNKNOWN instead of OK if the new --query option was *not*
specified.  This bug is fixed now.
2013-09-19 12:41:42 +02:00
Sven Nierlein
065905e900 check_disk: die with a reasonable error message if one mount point hits average value 2013-09-17 20:12:32 +02:00
Sven Nierlein
9090beb058 check_ssh: added test case 2013-09-17 12:13:51 +02:00
Sven Nierlein
b83904c528 check_by_ssh: tests expand key and config path
some systems do not expand the path automatically.
2013-09-17 11:34:06 +02:00
Sven Nierlein
ddff48fb25 check_udp: skip tests which rely on udp listen
solaris netcat does not listen in udp mode due to
http://sourceforge.net/p/netcat/bugs/27/
2013-09-17 11:23:12 +02:00
Sven Nierlein
982cbeea00 check_disk: get_fs_usage hasn't been run if using groups
the reason why it still worked sometimes was fsu_blocks beeing uninitialized
which resulted in a true test sometimes.
2013-09-16 15:30:56 +02:00
Sven Nierlein
adc9d71b4b check_procs: fix test with sleeping processes
at least on freebsd, there are a processes with state 'S', they always
use two character status.
2013-09-16 13:49:44 +02:00
Sven Nierlein
c001fb98ff check_http: tests use supplied value if possible 2013-09-16 13:49:44 +02:00
Sven Nierlein
cb8390aec9 check_tcp: use receive timeout for checks that expect response
if check_imap expects a string that never occurs, it currently waits forever
because thats how the imap protocoll works. Use a receive timeout in that case
so we can exit early with a proper error message.
2013-09-15 20:49:36 +02:00
Sven Nierlein
c900ee2772 check_ping: increase test timeout
freebsds ping takes a few seconds till it returns, so a 1 second timeout does
not work for the test.
2013-09-14 21:06:26 +02:00
Sven Nierlein
c7d6730255 check_load: add alternative uptime syntax
check_load parses load from the uptime command if no proc filesystem is available. Seems
like there are at least 2 different uptime outputs.

linux:
 20:44:34 up 25 days,  2:07, 13 users,  load average: 0.13, 0.17, 0.22

freebsd 8:
 8:44PM  up  4:29, 1 user, load averages: 0.00, 0.00, 0.00
2013-09-14 20:44:54 +02:00
Sven Nierlein
6361247b4c check_udp: try nc.traditional too
nc.traditional is available on (at least) ubuntu systems and uses traditional nc syntax
2013-09-14 19:59:17 +02:00
Sven Nierlein
7b122f13db tests: move ipv6 detection into NPTest module 2013-09-14 19:36:20 +02:00
Sven Nierlein
32ec6265a4 unified nc syntax
older netcats do not understand -p, they expect host and port as additional argument.
This is backwards compatibel to newer clients. Also support netcat instead of nc.
2013-09-13 23:08:07 +02:00
Sven Nierlein
8b1c574298 fping: some fping versions set loss to 0% by mistake
fping v2.4b2 returns
10.99.0.1 : xmt/rcv/%loss = 0/0/0%
for a failed host, so we assume the host is down if xmt is zero
2013-09-13 17:14:33 +02:00
Sven Nierlein
4933146e00 check_snmp: add timeout handler befor running snmpget 2013-09-12 23:39:32 +02:00
Sven Nierlein
c0926c2b1e check_tcp: only test ipv6 if ping6 works 2013-09-12 23:39:31 +02:00
Holger Weiss
ffad261eab check_tcp: Fix checks without --expect string
Commit e8044713d4 broke check_tcp checks
without --expect string, this commit fixes that regression.
2013-09-12 22:36:35 +02:00
Holger Weiss
e8044713d4 check_tcp: Properly deal will partial recv(3)s
The np_expect_match() function now returns one of three possible states
instead of just TRUE or FALSE:

- NP_MATCH_SUCCESS
- NP_MATCH_FAILURE
- NP_MATCH_RETRY

The NP_MATCH_RETRY state indicates that matching might succeed if
np_expect_match() is called with a longer input string.  This allows
check_tcp to decide whether it makes sense to wait for additional data
from the server.
2013-09-12 21:37:20 +02:00
Holger Weiss
662997251d Improve interface of np_expect_match() function
Replace the three boolean parameters of lib/utils_tcp.c's
np_expect_match() function with a single "flags" parameter.
2013-09-12 17:42:10 +02:00
Holger Weiss
ca9ce71576 Don't mark SSL_METHOD variable as "const"
The SSL_CTX_new(3) function expects a non-"const" SSL_METHOD value.
2013-09-10 22:49:03 +02:00
Holger Weiss
5b0e00782d Move global variables from .h to .c files
Simplify things by moving the definition of global variables into .c
files, where they belong.
2013-09-10 22:45:45 +02:00
Holger Weiss
b48cb1f130 Fix GCC's -Wimplicit-function-declaration warnings
Fix the issues found by GCC when the -Wimplicit-function-declaration
flag is specified.
2013-09-10 22:29:46 +02:00
Holger Weiss
d4a781817c Fix GCC's -Wuninitialized warnings
Fix the issues found by GCC when the -Wuninitialized flag is specified.
2013-09-10 20:52:13 +02:00
juliopedreira
cfb50add53 check_tcp: Don't close connection too early
Closing the connection because the bytes received are less than the
buffer size assumes that all the bytes will be received in one go.  This
is not always true!
2013-09-10 12:16:46 +02:00
Holger Weiss
5bfca4b34d s/--proxy_authorization/--proxy-authorization/
The check_http option "--proxy_authorization" is now called
"--proxy-authorization" instead.  It was always documented this way, and
we don't usually use underscores in option names.
2013-09-10 00:46:06 +02:00
Holger Weiss
e8594f461d check_snmp: Initialize size_t value to 0, not NULL 2013-09-05 00:19:36 +02:00
Holger Weiss
92fdab87b2 Partially revert "check_snmp: Close potential for using uninitialized memory"
This reverts the changes to plugins/common.h applied by commit
a20611d435.

- Clang defines __GNUC__.
- The new name of the __attribute__ parameter was misleading.
2013-08-27 18:32:38 +02:00
Holger Weiss
1cbc73bc8b check_snmp: Fix --help segfault 2013-08-27 16:08:49 +02:00
Holger Weiss
e9ede0f8e3 Merge branch 'master' of https://github.com/ozamosi/nagios-plugins
* 'master' of https://github.com/ozamosi/nagios-plugins:
  check_snmp: Close potential for using uninitialized memory
  check_snmp: Dynamically grow all data structures

Conflicts:
	plugins/check_snmp.c
2013-08-27 14:37:13 +02:00
Holger Weiss
efa9b0fc08 Merge branch 'master' of https://github.com/bugness-chl/nagios-plugins
* 'master' of https://github.com/bugness-chl/nagios-plugins:
  check_disk: option to ignore reserved space

Conflicts:
	plugins/check_disk.c
2013-08-26 23:23:55 +02:00
Sven Nierlein
817ea52cc0 fixed check_tcp test
A check with thresholds 9000,1 must exit with warning if the certificate expires in less
than 9000 but more than one day.
2013-08-21 17:48:14 +02:00
Sven Nierlein
d57941c4d2 check_snmp: added threshold tests 2013-08-21 15:59:56 +02:00
Holger Weiss
461cea4261 check_snmp: Fix support for inverse thresholds
Commit bd78299056 reintroduced support for
inverse threshold ranges such as "2:1", but it broke standard thresholds
such as "1:2" (by converting this range into "1") or "1:" (by converting
this range into "@:2").  This commit fixes those two bugs, plus an
off-by-one error while computing the number of bytes to allocate when
handling inverse thresholds (two additional bytes were allocated where
three were required to hold '@' and ':' and '\0').  While at it, we also
check whether malloc(3) succeeded.
2013-08-21 15:00:27 +02:00
Holger Weiss
f4b90cabc0 Set SSL_MODE_AUTO_RETRY flag
We use OpenSSL (or GnuTLS) with blocking semantics, and we don't want
SSL_read(3) or SSL_write(3) calls to return SSL_ERROR_WANT_READ or
SSL_ERROR_WANT_WRITE (see #3614716).
2013-08-20 23:17:23 +02:00
Holger Weiss
92849a1a87 check_users: Use utmpx(5) only if available
For systems that don't provide an utmpx(5) interface, restore the code
that was replaced in commit 3e622f3a47.
2013-08-20 21:13:25 +02:00
Sven Nierlein
4083622f86 added missing header to fix build on freebsd 2013-08-20 17:02:02 +02:00
Holger Weiss
8135f66739 check_ide_smart: "__linux__" instead of "linux"
C compilers in standards compliance mode will not define "linux", as it
doesn't begin with an underscore.
2013-08-20 00:55:43 +02:00
Holger Weiss
36a9b52cae check_ide_smart: Add support for NetBSD
Thanks to Emmanuel Dreyfus for providing the patch.
2013-08-20 00:41:16 +02:00
Holger Weiss
5f79e3e9f6 Clean up check for _SC_NPROCESSORS_ONLN
Closes #62.
2013-08-19 22:47:36 +02:00
Holger Weiss
a064001173 Merge branch 'master' of https://github.com/bbense/nagios-plugins
* 'master' of https://github.com/bbense/nagios-plugins:
  Bug fix for ncpus if hyperthreading turned off in linux
2013-08-19 22:47:00 +02:00
Booker C. Bense
f12edfd073 Bug fix for ncpus if hyperthreading turned off in linux 2013-08-19 11:14:05 -07:00
Holger Weiss
30aa7a63f1 check_http: Document the new -E option
Mention the -E/--extended-perfdata flag in the --help output.
2013-08-18 23:18:18 +02:00
Holger Weiss
64b4d1fb66 Abbreviate function name
Make a very long function name at least a little bit shorter.
2013-08-18 23:11:11 +02:00
Holger Weiss
8e444095e8 Merge branch 'master' of https://github.com/cern-mig/nagios-plugins
* 'master' of https://github.com/cern-mig/nagios-plugins:
  added support for client authentication via SSL

Conflicts:
	plugins/check_http.c
2013-08-18 23:10:31 +02:00
Holger Weiss
b5ac0d16b2 check_mysql: Don't accept new positional arguments
Do not also accept the new -f/--file and -g/--group options as
positional arguments (especially not prior to "db_pass" and "db", as
that would break backward compatibility).
2013-08-18 22:30:30 +02:00