Commit graph

1620 commits

Author SHA1 Message Date
gcoxmoz
a3f0b96f32 Update check_tcp.c
Return the state asked for, if connection failed.
2014-05-17 00:55:40 -04:00
Gunnar Beutner
1b3890572e Make check_disk work on Windows. 2014-04-27 19:59:06 +02:00
Gunnar Beutner
5e03bd8e8c Make check_users work on Windows. 2014-04-27 19:59:06 +02:00
Gunnar Beutner
e0af39d7e9 Make check_ping work on Windows. 2014-04-27 19:59:06 +02:00
Anton Lofgren
4e0da0216d check_snmp: Handle SNMPv3 noAuthNoPriv properly
The SNMPv3 noAuthNoPriv security level, somewhat unintuitively, requires
a security name to be passed along together with the request. Check_snmp
previously did not do this, causing snmpget to throw an error:

"External command error: No log handling enabled - turning on stderr
logging
snmpget: No securityName specified"

This patch fixes the issue by always providing the security name when
noAuthNoPriv is specified.

See also:
https:://bugs.op5.com/view.php?id=8385.

Signed-off-by: Anton Lofgren <alofgren@op5.com>
2014-04-24 08:49:54 +02:00
Sam Kottler
c887890e9f Remove the suggestion to run check_apt with --verbose since it doesn't do anything 2014-04-04 16:55:59 +06:00
Jan Wagner
a271ad24f4 check_nt: add UPTIME to perfdata [sf#3434647] 2014-04-04 12:42:59 +06:00
awiddersheim
70314c62fc Fix check_mysql.c client options from file
If you don't specify a group or a file to read data from the plugin tries to read from several files that don't exist and no groups.
2014-04-03 23:41:37 +06:00
Holger Weiss
3f4419c07e check_pgsql: Add missing newline to --help output 2014-03-13 12:52:48 +01:00
Davide Madrisan
546e15a8e8 build - avoid deprecated INCLUDES
Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
2014-03-09 11:02:18 +01:00
Davide Madrisan
ac438ccfe5 check_swap: Fix the plugin name that appears in the comment
Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
2014-02-20 15:52:56 +01:00
Sven Nierlein
385340a4ef check_procs test fails if there is no user with uid 501
thats because check_procs verifys there is a user for a
given uid filter. So even we use sample data for this
test, we still need a real user.

Signed-off-by: Sven Nierlein <Sven.Nierlein@consol.de>
2014-02-18 16:20:11 +01:00
Jan Wagner
4f5e20187f check_ssh: Reverting a387120
This seems to result into more problems in the wild then before 'fixing' it

Closes Debian #739254
Reopen Debian #734811
2014-02-17 12:18:17 +01:00
Thomas Guyot-Sionnest
d2744118dc Merge pull request #1234 from skottler/plugin_makefile_whitespace
Remove unnecessary whitespace in Makefile.am
2014-02-07 09:18:06 -05:00
Sam Kottler
54bce08d52 Remove unnecessary whitespace in Makefile.am 2014-02-07 13:53:33 +01:00
Thomas Guyot-Sionnest
f3078c33f6 Add perfdata in check_proc output tests 2014-01-31 13:00:53 -05:00
Thomas Guyot-Sionnest
f45adede7d Fix snmpd tests 2014-01-31 12:30:11 -05:00
Thomas Guyot-Sionnest
1dd0e4c963 Enable tests in tests/ subdirs 2014-01-31 08:54:44 -05:00
Stephane Lapie
35811848da Handle negative values properly with check_snmp
check_snmp becomes capable of evaluating negative values properly,
but it might be returning CRITICALs where it used to return OK and was ignored,
if a negative value turns out to actually be a valid value.
If negative values are valid, this can be worked around,
by adding "~:" to the warning/critical threshold : 100 -> ~:100
2014-01-31 00:49:18 -05:00
Thomas Guyot-Sionnest
c4e3cd6efd Add tests for negative thresholds in check_snmp
Next commit will work on fixing these!
2014-01-31 00:48:49 -05:00
Holger Weiss
4a2a725465 check_dig: Declare variable at the top
C89 doesn't allow variable declarations to be intermingled with code.
2014-01-30 19:51:46 +01:00
Jan Wagner
e33ecc84c7 check_dig: stick with integer devision
This change saves us from having to link check_dig against "libm"
2014-01-30 11:28:19 +01:00
Jan Wagner
2aa6ce2844 check_dig: timeout_interval is a global variable
which is already set to 10 seconds
2014-01-30 11:28:09 +01:00
Jan Wagner
df53473d03 check_dig: patch to make dig honor -t option
When a timeout value is specified with the -t option, dig will sometimes
timeout before the timer is actually reached.

The problem occurs because the check_dig plugin does not pass the specified
timeout value to dig, leaving dig to timeout with it's default value which
seems to be around 10-15seconds.

To reproduce:
time ./check_dig -H 127.0.0.2 -l www.google.com -t 30

It will not run for 30secs, which is the expected behaviour.

The following will work, because the timeout is less than the default dig
timeout, so the plugin cancels the dig command:
time ./check_dig -H 127.0.0.2 -l www.google.com -t 2

This fix passes the timeout value to dig, and sets the number of retries which tends to vary from system to system by default.

Closes #1168
2014-01-30 11:07:22 +01:00
Thomas Guyot-Sionnest
813c02364f Update check_swap usage 2014-01-29 03:59:48 -05:00
Thomas Guyot-Sionnest
7afbca0b8c check_swap: add supports for a configurable state when there is no swap
Check_swap used to allow no swap when thresholds were only specified in
percent. This is no longer the case and the state now must be specified
explicitly. The default is to always return CRITICAL when the swap is
absent regardless of thresholds.
2014-01-29 03:40:11 -05:00
Thomas Guyot-Sionnest
8fc9e5ac4b Move negate' translate_state() to utils_base.h mp_translate_state()
Also use strcasecmp imported from gnulib for simplicity
2014-01-29 03:20:23 -05:00
Thomas Guyot-Sionnest
fc9fbe1e89 Typo 2014-01-29 02:16:47 -05:00
Thomas Guyot-Sionnest
6f2d545244 Fix check_swap returning OK on & thresholds and no swap
Return 0% free instead of 100% free when total swap is 0
2014-01-29 01:44:22 -05:00
Jan Wagner
cb99931e43 check_disk: precise the help output
Clarifying in the help output that we need either a device or mount point
listed by the mount(8) command.

(Closes: #1118)
(Closes: #1170)
2014-01-28 12:07:48 +01:00
Thomas Guyot-Sionnest
c30be5877c Clarify check_mysql test prompts
Also default to "-u test -ptest" which are default MySQL accounts only
missing the prescribed privileges.

The database is no longer specified as it is not used.
If wanted is should be its own parameter/tests.
2014-01-28 02:35:09 -05:00
Thomas Guyot-Sionnest
f34f51a005 Merge pull request #1200 from awiddersheim/add_file_options_mysql_query
Add ability to read from options file to check_mysql_query.c
2014-01-27 22:50:27 -08:00
Thomas Guyot-Sionnest
58e57b32bf check_dig: fix wrong IPv6 arguments order 2014-01-27 22:16:35 -05:00
Thomas Guyot-Sionnest
189e2aa344 Rename MP_STATE_DIRECTORY to MP_STATE_PATH 2014-01-27 08:35:23 -05:00
Thomas Guyot-Sionnest
4caf4ce4fe Rename ENV variable, keep backward compatibility
Rename NAGIOS_PLUGIN_STATE_DIRECTORY to MP_STATE_DIRECTORY
2014-01-25 03:35:46 -05:00
Jan Wagner
455fe96e7d check_ping: Fixing "time of day goes back"
by Geoff Oakham <goakham at oanda.com>

Patch of check_ping that allows it to gracefully handle when ping outputs
to stderr "Warning: time of day goes back (-XXXXus), taking countermeasures."

Closes: #809 and #1195
2014-01-24 18:33:37 +01:00
Jan Wagner
ccecba33a2 Fixing bug in average calculation (Submitted by Lars)
The more important change: A fix for a bug which caused the check_ntp_time
and check_ntp_time check to always take the first response from ntp and not
the avarage since "j" is not increased anywhere. "i" should be used there
instead.

Partly Closes #956 and Closes #1166
Closes: #1089
2014-01-24 18:20:08 +01:00
Jan Wagner
c5dc81cd28 Making AVG_NUM configurable by compiler define (Submitted by Lars)
A minor change which makes the AVG_NUM configurable by compiler define.
Partly Closed #956 and Closes #1166
2014-01-24 17:55:57 +01:00
Tilmann Bubeck
c4a99b023d fix smart attribute comparison
Each S.M.A.R.T. attribute is compared against a threshold. If it is LESSTHAN
that threshold an error is reported.  This patch fixes the problem, that
attribute values EQUAL to the threshold are reported as error, which is wrong.
Only LESSTHAN the threshold is an error.

For more information see: http://www.hdsentinel.com/smart/index.php

My SSD has some attributes which value and threshold are "0". Without the patch
this is reported as errornous.

ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
...
172 Unknown_Attribute 0x0032 000 000 000 Old_age Always - 0
174 Unknown_Attribute 0x0030 000 000 000 Old_age Offline - 13
177 Wear_Leveling_Count 0x0000 000 000 000 Old_age Offline - 0
...

See also:

* http://sourceforge.net/p/nagiosplug/patches/365/
* https://bugzilla.redhat.com/913085
2014-01-23 08:56:53 -05:00
Thomas Guyot-Sionnest
0fbee4deb2 Fix misleading option text
As soon as a device is specified without using -d, anything else on the
command line is ignored.
2014-01-23 03:19:06 -05:00
Thomas Guyot-Sionnest
d080c3ad97 Disable SMART test commands in check_ide_smart
check_ide_smart could disable offline auto tests but could not re-enable
them. For this reason all SMART command modes have been disabled

The disabled commands are -0/--auto-off, -1/--auto-on and
-i/--immediate
2014-01-23 03:17:55 -05:00
Thomas Guyot-Sionnest
fd20a72ad6 Remove accidental tabs inserted in macro 2014-01-23 03:06:21 -05:00
Thomas Guyot-Sionnest
b5cc2928e2 Make check_ide_smart default to nagios output
check_ide_smart was originally a smard control utility later converted
to a monitoring plugin. the -n option (Nagios check) should therefore be
the default.

This patch deprecates the -n and -q switches, and make the other
switches return nagios-compatible output (they are most likely used in
eventhandlers, but returning nagios-compatible output makes it clear and
easy to handle the return status)
2014-01-23 02:41:26 -05:00
Ricardo Maraschini
82033b35b1 plugins/utils.h: avoiding warnings on empty printf statements
while compiling i keep receiving an warning statement as follow:

warning: zero-length gnu_printf format string

using an unorthodox method to remove them

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
2014-01-22 16:11:57 +01:00
Holger Weiss
01e570f4a4 Capitalize "Monitoring Plugins"
"Monitoring Plugins" is a name.
2014-01-21 16:19:20 +01:00
Holger Weiss
7ee3525423 Merge branch 'maint'
* maint:
  check_ssh: Get rid of sshd: Read from socket failed: Connection reset by peer
  fixed tests when there is no direct internet connection
  NEWS: Mention fix for check_http's -S option
  Fix for SSL Versioning when multiple options are used.
  Fix #1217 spec file fails to build due to duplicate files and unused files
  check_http: Don't let "-N" expect an argument
  README: Change GitHub URL
  README: Clarify license notice
  Update URLs and mailing list addresses
  Just using the posix conform extended regular expression grep
  check_oracle: --db +ASM bad string matching check_oracle doesn't correctly check for pmon +ASM instance from at least Oracle 11 as the pmon proces was renamed from ora_pmon_.* to asm_pmon_.*. -- Just turning attached patch of github issue #1207 into a push request. (Closes #1207)
  Update web site URLs

Conflicts:
	FAQ
	NEWS
	README
	SUPPORT
	configure.in
	monitoring-plugins.spec.in
	pkg/solaris/pkginfo.in
	plugins-root/check_dhcp.c
	plugins-root/check_icmp.c
	plugins-scripts/check_ifoperstatus.pl
	plugins-scripts/check_mssql.pl
	plugins/check_apt.c
	plugins/check_by_ssh.c
	plugins/check_cluster.c
	plugins/check_dbi.c
	plugins/check_dig.c
	plugins/check_disk.c
	plugins/check_dns.c
	plugins/check_dummy.c
	plugins/check_fping.c
	plugins/check_game.c
	plugins/check_hpjd.c
	plugins/check_http.c
	plugins/check_ide_smart.c
	plugins/check_ldap.c
	plugins/check_load.c
	plugins/check_mrtg.c
	plugins/check_mrtgtraf.c
	plugins/check_mysql.c
	plugins/check_mysql_query.c
	plugins/check_nagios.c
	plugins/check_nt.c
	plugins/check_ntp.c
	plugins/check_ntp_peer.c
	plugins/check_ntp_time.c
	plugins/check_nwstat.c
	plugins/check_overcr.c
	plugins/check_pgsql.c
	plugins/check_ping.c
	plugins/check_procs.c
	plugins/check_radius.c
	plugins/check_real.c
	plugins/check_smtp.c
	plugins/check_snmp.c
	plugins/check_ssh.c
	plugins/check_swap.c
	plugins/check_tcp.c
	plugins/check_time.c
	plugins/check_ups.c
	plugins/check_users.c
	plugins/negate.c
	plugins/urlize.c
	plugins/utils.h
	po/Makevars
	po/de.po
	po/fr.po
	po/monitoring-plugins.pot
2014-01-21 16:07:38 +01:00
Thomas Guyot-Sionnest
11cf54ca78 Merge branch 'rename' 2014-01-21 07:59:07 -05:00
Holger Weiss
6141cfebf6 New default installation prefix: /usr/local
Install into /usr/local instead of /usr/local/nagios by default, in
order to comply with the Filesystem Hierarchy Standard (FHS) and
presumably the expectations of most users.
2014-01-21 13:17:36 +01:00
Spenser Reinhardt
66544851f7 plugins/*.c: Non-network timeout changes
Changes to non-network checks for clarity on timeout value. Adapted from pull request #1209 tracker from user awiddersheim. (Closes: #1209)
Files: check_apt.c, check_disk.c, check_procs.c, negate.c
2014-01-21 11:35:07 +01:00
Spenser Reinhardt
80e506a2f7 plugins/utils.h: Addition of plugin timeout msg.
Addition of timeout message for non-network plugins(UT_PLUG_TIMEOUT), and alteration of UT_TIMEOUT to UT_CONN_TIMEOUT for networked checks. Alteration of pull request #1209 tracker by user awiddersheim.
2014-01-21 11:34:33 +01:00
Spenser Reinhardt
212575b858 plugins/*.c: Alterations for timeout messages.
.c file changes for misleading timeout messages in help functions. Solution to pull request #1209 tracker by awiddersheim.

Files: plugins/check_apt.c, plugins/check_by_ssh.c, plugins/check_dbi.c, plugins/check_dig.c, plugins/check_disk.c, plugins/check_dns.c, plugins/check_game.c, plugins/check_http.c, plugins/check_ldap.c, plugins/check_ntp.c, plugins/check_ntp_peer.c, plugins/check_ntp_time.c, plugins/check_nwstat.c, plugins/check_overcr.c, plugins/check_pgsql.c, plugins/check_ping.c, plugins/check_procs.c, plugins/check_radius.c, plugins/check_real.c, plugins/check_smtp.c, plugins/check_snmp.c, plugins/check_ssh.c, plugins/check_tcp.c, plugins/check_time.c, plugins/check_ups.c, plugins/negate.c
2014-01-21 11:33:45 +01:00
Jan Wagner
96f45b6698 Revert renaming value
As suggested by sreinhardt in 045d38a6 over there in nagios-plugins
2014-01-21 11:08:07 +01:00
awiddersheim
fc01a54e93 Add performance data to check_mysql_query.c (Closes: #1202) 2014-01-21 11:03:14 +01:00
Holger Weiss
c3e756a855 Capitalize "Monitoring" when it's the first word 2014-01-20 03:12:50 +01:00
Holger Weiss
a8c9b696f4 Minor fixes to be amended into "rename" commit 2014-01-20 03:01:55 +01:00
Monitoring Plugins Development Team
63734f52ab Project rename initial commit.
This is an initial take at renaming the project to Monitoring Plugins.
It's not expected to be fully complete, and it is expected to break
things (The perl module for instance). More testing will be required
before this goes mainline.
2014-01-19 14:18:47 -05:00
Jan Wagner
a387120182 check_ssh: Get rid of sshd: Read from socket failed: Connection reset by peer
This fix was grabbed from FreeBSD downstream and provided by Dmitry Sivachenko.
Fixes Debian Bug #734811
2014-01-10 15:56:30 +01:00
Sven Nierlein
d8354ec15d fixed tests when there is no direct internet connection
- check http had wrong number of skipped tests
 - check tcp did not use the 'no internet' flag at all
2013-12-27 01:14:50 +01:00
Joseph Gooch
cadf0d7ba8 Fix for SSL Versioning when multiple options are used.
If you specify -S1 -C 30... The -C option will reset the ssl_version to 0.  This is not a good thing.

Instead we set the default to 0 and retain the version when later args are passed.
2013-12-20 17:30:14 +01:00
Holger Weiss
c91ff7539a check_http: Don't let "-N" expect an argument
Fix the problem that check_http's "-N" option expects an argument
although it shouldn't.  The corresponding long option ("--no-body")
wasn't affected.

This error was introduced in ee3c4014d5.
Thanks to Kerry Hughes for reporting it on the devel@ list.
2013-12-05 20:13:31 +01:00
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
3c90a370ea Update URLs and mailing list addresses
Now that we moved our infrastructure away from SourceForge, update the
URLs and mailing list addresses accordingly.
2013-10-28 23:58:36 +01:00
Holger Weiss
ef35403c26 Update web site URLs
The Nagios Plugin Development Guidelines and the Extra-Opts
documentation were moved to our new project server.
2013-10-08 16:09:42 +02:00
awiddersheim
be2324d7ab Add additional usage data for new options in check_mysql_query.c 2013-10-05 12:02:30 -04:00
awiddersheim
dccf53cf38 Add ability to read from options file to check_mysql_query.c
This is the same code that was added to check_mysql.c in 5ed7194.
2013-10-05 11:28:19 -04:00
Jan Wagner
97349ae13d check_ssh: check protocol
It would be useful to be able to detect the protocols supported by the remote
ssh server to locate any using the insecure ssh v1 protocol. This patch
attempts to match against the protocol string in the ssh response.

Example:

check_ssh -H my.host.com -P 2.0
--
Just turning attached patch of github issue #780 into a push request.
(Closes #780)
2013-10-01 14:50:04 +02: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
Holger Weiss
779b91e48f check_mysql: Use xasprintf instead of asprintf 2013-08-18 22:29:31 +02:00
Holger Weiss
584555098d check_mysql: Fix copy'n'pasted comments 2013-08-18 22:28:18 +02:00
Holger Weiss
14bc7af323 Merge branch 'master' of https://github.com/jonmilby/nagios-plugins
* 'master' of https://github.com/jonmilby/nagios-plugins:
  Updated check_mysql.c to take client options file and group parameters

Conflicts:
	plugins/check_mysql.c
2013-08-18 22:25:08 +02:00
Holger Weiss
6d6f090eaa Merge branch 'fping' of https://github.com/lairsdragon/nagios-plugins
* 'fping' of https://github.com/lairsdragon/nagios-plugins:
  check_fping error handling enhanced, generates UNKNOWN on fping parameter error (i.e. wrong interface, missing perms ..)

Closes #61.
2013-08-18 20:36:42 +02:00
Steve Weinreich
96ec686004 check_fping error handling enhanced, generates UNKNOWN on
fping parameter error (i.e. wrong interface, missing perms ..)
2013-08-18 19:43:39 +02:00
Holger Weiss
c7c1102fcb NEWS: Mention the new "check_snmp --offset" option
... and apply two small cosmetic changes to check_snmp.c.

Closes #59.
2013-08-18 19:38:57 +02:00
Simon Kainz
dc1d1c46d6 added --offset option to allow adjustment of sensor data 2013-08-18 19:35:18 +02:00
Holger Weiss
22519bced6 check_http: Use xasprintf instead of asprintf 2013-08-18 19:16:00 +02:00
Holger Weiss
ebb5572af3 check_http: s/--header_string/--header-string/
The name of the new option is "--header-string".
2013-08-18 19:14:22 +02:00
Holger Weiss
e6bcf11653 check_snmp: Allocate space for the new -Le option
Closes #41.
2013-08-18 19:08:04 +02:00
Mark Keisler
37cf5e3cd5 Add -Le option to snmpcmd to avoid error message of 'No Log Handling Enabled...' 2013-08-18 19:07:24 +02:00
Tim Laszlo
b2568b85af check_mysql: Connections should have been defined as a counter 2013-08-18 18:38:10 +02:00
Tim Laszlo
7bbd155a72 Counter increments were incorrect; remove the leading space from perfdata 2013-08-18 18:38:10 +02:00
Tim Laszlo
c8d8b58447 check_mysql: add perfromance metrics for all checks 2013-08-18 18:38:10 +02:00
Tim Laszlo
1627cdb46a check_mysql: when checking slave thread add performance data for seconds behind master 2013-08-18 18:38:10 +02:00
Holger Weiss
717b0e8d9c Fix the "check_http -d" tests 2013-08-18 18:31:59 +02:00
linkslice
2a8eab6b31 added ability to check regex against http headers. booyah! 2013-08-18 18:23:11 +02:00
Sebastian Schmidt
2f79329c41 check_procs: clarify debug message 2013-08-18 12:59:57 +02:00
Sebastian Schmidt
0efedfb77c check_procs: Assume we have stat()
stat() is in gnulib anyway, so we can safely depend on it.
2013-08-18 12:59:57 +02:00
Sebastian Schmidt
0f686d436e check_procs: Get rid of HAVE_PROC_PID_EXE
Don't check for /proc/pid/exe at compile time, it could be gone in a
build chroot or the like. Checking at runtime (once) is sufficient.
2013-08-18 12:59:57 +02:00
Sebastian Schmidt
d5677d9b42 check_procs: Ignore ENOENT when checking for myself
Previously, when a process exited between the call to /bin/ps and
stat("/proc/his/exe") was exiting it was not considered as possible
instance of check_procs. This commit makes check_procs ignore all
processes where /proc/pid/exe does not exist.
2013-08-18 12:59:57 +02:00
Sebastian Schmidt
274f3ddee2 check_procs: fix typo
Fix a typo in previous commit where st_ was missing in the mock
struct_stat_t, causing check_procs.c to not compile without sys/stat.h.
2013-08-18 12:59:57 +02:00
Sebastian Schmidt
ce7a99789d check_procs: filter out self by /proc/pid/exe
Make check_procs filter out itself in the process list by comparing the
file pointed to by /proc/pid/exe. On platforms where this is not
available or when check_procs is passed the -T flag, the old behaviour
(check whether PID equals getpid()) is retained.

This fixes some false alarms when e.g. Nagios has, for whatever reasons,
some backlog of checks to run and check_procs with -a is called more
than once in a short time, matching its sister process.
2013-08-18 12:59:57 +02:00
Holger Weiss
36c2e50837 check_mysql: Cosmetic changes to SSL support
Use (slightly) more intuitive option names etc.
2013-08-18 01:47:32 +02:00
Juan Carlos Fernandez
8e66a58d41 Added ssl support to check_myslq 2013-08-18 01:28:13 +02:00
Richard Leitner
3931bd9500 Fixed SF.net bug #3552839, check_procs: added -k option to ignore kernel threads
This commit fixes sourceforge.net bug #3552839.
It adds a -k|--no-kthreads option to ignore kernel thread processes.
Please note: currently this feature only works for GNU/Linux systems (due to the fact I have no other systems to test/develop on)
Sorry for that, but I'm sure this can be accomplished by somebody else ;-)
2013-08-18 00:55:34 +02:00
Holger Weiss
108baecaec check_fping: Use fping6(8) only if available
Let check_fping use IPv6 only if

- the operating system supports IPv6,
- the user didn't specify --without-ipv6, and
- the "configure" script found the fping6(8) binary.
2013-08-18 00:30:58 +02:00
Holger Weiss
e4ccd85c50 Merge remote-tracking branch 'github/villemattila/check_fping_ipv6'
* github/villemattila/check_fping_ipv6:
  check_fping: IPv6 support

Conflicts:
	plugins/check_fping.c
2013-08-18 00:02:32 +02:00
Holger Weiss
baa388e6fa check_fping: Remove unused printf(3) arguments 2013-08-17 23:18:57 +02:00
Steve Weinreich
c9169d1256 Added -S und -I parameter to match fping -S and -I parameters.
-S allows to specify the source ip for ICMP pakets
-I allows to specify a interface to bind to
2013-08-17 23:15:59 +02:00
Holger Weiss
b62f0fb444 check_pgsql: Add missing printf(3) argument 2013-08-17 23:06:16 +02:00
Holger Weiss
329f843ef6 check_pgsql: Remove -4/-6 flags from help output
The -4/-6 options are currently not supported.
2013-08-17 22:33:43 +02:00
Holger Weiss
e47a06f77d Merge remote-tracking branch 'github/tokkee/sh/check_pgsql'
* github/tokkee/sh/check_pgsql:
  check_pgsql: Determine connection time in µs-resolution.
  check_pgsql: Leave 'min' value in query perfdata empty.
  check_pgsql: Updated copyright.
  check_pgsql: Added support for the -o command line option.
  check_pgsql: Removed -4/-6 flags from help output.
  check_pgsql: Allow UNIX socket directories as hostname as well.
  check_pgsql: Use PQconnectdb() rather than PQsetdbLogin().
  check_pgsql: Fixed query perfdata output for empty warn/crit ranges.
  check_pgsql: Added support for executing queries.

Conflicts:
	plugins/check_pgsql.c
2013-08-17 22:28:38 +02:00
Holger Weiss
4a3901ec70 plugins/t/check_procs.t: Expect performance data
The check_procs plugin now emits performance data, fix the test(s)
accordingly.
2013-08-17 21:59:45 +02:00
Holger Weiss
29b2dfab4f plugins/t/check_apt.t: Expect performance data
The check_apt plugin now emits performance data, fix the test(s)
accordingly.
2013-08-17 21:52:50 +02:00
Sven Nierlein
ec537bc463 cleanup after check_http patch (fixes #50)
- cleanup whitespace
  - added test cases
  - print time_ssl only if ssl is in use
  - updated news and thanks file
2013-08-15 17:28:49 +02:00
Sebastian Nohn
ee3c4014d5 log more perfdata in check_http 2013-08-15 17:03:31 +02:00
Sven Nierlein
bb3bf05856 Merge pull request #54 from g0hl1n/check_apt_-_run_update_upgrade_return_fix
check_apt now correctly exits when apt-get return != 0
2013-08-15 02:26:08 -07:00
Sven Nierlein
2e6a0138de corrected http test
multiple headers have to be set by multiple -k switches. Seperating them
by semicolons is not longer supported as semicolons are valid characters in
http headers.
2013-08-15 11:10:04 +02:00
Sven Nierlein
5815864e6c Merge pull request #52 from g0hl1n/sf_3571331_check_http_-_removed_semicolon_delimiter_in_-k
Fixed SF.net bug #3571331, check_http converts semicolon to newline in -k
2013-08-15 01:57:11 -07:00
Jan Wagner
b6f0e755fd Fixed SF.net bug 2555775, threshold can be double for check_smtp
Thanks to Roman Fiedler for reporting the issue and providing a fix
2013-08-06 10:55:49 +02:00
Jan Wagner
bfe68d84f7 check_nt: Fixes NULL pointer dereference
Thanks to Vaclav Ovsik for reporting the issue and providing a fix
2013-07-08 18:52:50 +02:00
Holger Weiss
9dad98f33e check_ntp_peer: Verify type of response packets
The check_ntp_peer plugin now ignores response packets with an
unexpected "Operation Code" and/or "Sequence" number (cf. RFC 1305,
Appendix B).  This fixes an issue where the check_ntp_peer requests got
duplicated on their way to the server (due to some network switch bug),
and the server therefore sent multiple responses per request.

Thanks to Marc Haber for reporting the issue.
2013-06-30 16:05:48 +02:00
Jan Wagner
91b2514358 Fixed SF.net bug 1614553, Debian bug #708343, Adding performace data 2013-06-25 15:20:39 +02:00
Richard Leitner
9be408511c check_apt now correctly exits when apt-get return != 0
This commit fixes an issue with check_apt where check_apt doesn't exit
with the appropriate return code when apt-get returned a non-zero value.
2013-05-30 00:05:17 +02:00
Richard Leitner
14225eb464 Fixed SF.net bug #3571331, check_http converts semicolon to newline in -k
This commit fixes sourceforge.net bug id 3571331.
The semicolon was defined as input delimiter for multiple values in the -k arguments.
Due to the fact the semicolon is a valid character for HTTP header fields this input delimiter function was removed.
It is still possible to pass multiple header fields via multiple -k (like described in helptext).
2013-05-29 15:02:15 +02:00
Lionel Cons
2f92d0dab7 added support for client authentication via SSL 2013-05-17 15:00:09 +02:00
Diego Elio Petten
eeca6e0f05 build: fix building with parallel make.
By using a more automake-style handling of dependencies and a single
convenience library, it's tremendously easy to build in parallel.

Note that since the linking happens with the static archives, the
unused objects are discarded and provide no overhead whatsoever.
2013-05-12 14:15:13 +02:00
Diego Elio Petten
332c6ef2c7 plugins: rename runcmd's signal handler.
The previous name would collide with popen's. Even if the two are
never used together, it's still a good idea not to have the same
symbol in multiple object files.
2013-05-12 14:15:13 +02:00
Richard Leitner
10a4de3c4c Fixed SF.net bug 3560976, added --include-type/-N option 2013-03-25 23:47:12 +01:00
Richard Leitner
fe5fa2a480 Fixed SF.net bug 3602586, added timeout option for check_nagios 2013-03-25 23:35:13 +01:00
Richard Leitner
6b208a6f31 Fixed SF.net bug 3539317, typo in --help of check_apt 2013-03-25 23:26:29 +01:00
Joerg Linge
e0eb2ebca3 Update plugins/check_procs.c
added missing longopt --user
2013-02-27 23:18:14 +01:00
Sven Nierlein
5fce5ceaeb check_tcp: don't ignore trailing options
"./check_tcp -6 -p 80 host" leads to an error:
TCP CRITICAL - Invalid hostname, address or socket: 127.0.0.1
because 127.0.0.1 is the fallback host, the tailing hostname
was ignored.
2013-02-10 23:09:49 +01:00
Robin Sonefors
a20611d435 check_snmp: Close potential for using uninitialized memory
This was reported by clang, and in order for it to understand attributes
properly, I had to modify the macro that checks for non-gcc compilers.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
2013-01-29 15:30:04 +01:00
Robin Sonefors
d87395ec3d check_snmp: Dynamically grow all data structures
Before this patch, there was a constant, MAX_OIDS, that determined the
amount of slots most (but not all - see labels) array data structures
would have. It was set to 8.

Some users would like to use more than that, but rather than bumping the
constant, let's use the same type of logic we already use for labels -
grow the space 8 slots at a time. This will allow us to potentially
support an infinite amount of oids - or at least as many as the
packetsize on the SNMP server allows, which is usually significantly
smaller than infinity, yet often larger than 8.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
2013-01-29 15:30:02 +01:00
Daniël van Eeden
e396a54274 Apply my patch from:
http://sourceforge.net/tracker/index.php?func=detail&aid=3269273&group_id=29880&atid=397597
2013-01-24 08:56:19 +01:00
Sven Nierlein
307da669ee Merge pull request #20 from abradley/aptcritical
Fixes for check_apt handling of -i/-e/-c regexps and SECURITY_RE, plus tests
2013-01-23 11:43:26 -08:00
Sven Nierlein
596af9df57 updated check dig tests
nagios.com seems to have changed their ip address. Also added tests
about -4/-6 option.
2013-01-23 20:26:41 +01:00
Ville Mattila
261ad18670 check_dig: query transport selection support
Add command line options -4 and -6 (--use-ipv4 and
--use-ipv6) to check_dig.

Effectively this adds no new functionality, just a
shortcut for:
  check_dig -A "-4"
  check_dig -A "-6"

Needed for using check_dig with the check_v46 wrapper
(see e.g.
https://gitorious.org/nagios-monitoring-tools/nagios-monitoring-tools/blobs/master/check_v46)
which requires -4/-6 command line option support.
2013-01-23 20:04:04 +01:00
Robin Sonefors
77eba26361 check_snmp: Don't thrash memory when using multiple label/unit argument
The memory allocation mixed up number of bytes with number of pointers,
meaning as soon as we'd reach (on 64 bit systems) the second argument,
we'd start writing it outside of our allocated memory.

Normally, this isn't too visible, but as soon as you (again, on my 64
bit system) reach argument number 8, you get a segfault. It is easily
reproducible with:
check_snmp -o '' -l '' -o '' -l '' -o '' -l '' -o '' -l '' \
           -o '' -l '' -o '' -l '' -o '' -l '' -o '' -l ''

This patch allocates the proper amount of memory, to fix the issue.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
2013-01-23 19:52:24 +01:00
Jonathan Milby
5ed7194c7e Updated check_mysql.c to take client options file and group parameters 2012-12-28 12:40:23 -05:00
Ville Mattila
6515124a47 check_fping: IPv6 support
Add command line options -4 and -6 (--use-ipv4 and
--use-ipv6) to check_fping. IPv4 is used by default,
maintaining backwards compatibility with older
check_fping versions. IPv6 support requires the
fping6 program.

The implementation is really just an imitation of
check_ping IPv6 support: Plugin command line option
-4/-6 designates whether to run fping/fping6.

Please note that especially the changes to
configure.in might be all wrong - I don't know
what's the proper autoconf way, patching
configure.in just seemed to work for me.
2012-12-28 10:26:13 +02:00
Sven Nierlein
6fde27e478 check_ntp(_time): don't die on connect errors
connect errors may happen if clients check agains dual
stacked ipv4/6 ntp servers.
2012-11-28 13:51:16 +01:00
Sven Nierlein
24772e755e unified ipv4/6 usage and help text 2012-11-28 11:03:11 +01:00
Holger Weiss
92b937e49e check_procs: Remove superfluous newline character 2012-11-14 20:53:47 +01:00
Sebastian Harl
e683a8dce5 check_procs: Added performance data to plugin output. 2012-11-14 20:45:44 +01:00
Sebastian Harl
2bac48c027 check_procs: Use the range/threshold support functions from libnagiosplug.
This adds support for @<range> and makes stuff a bit simpler by removing code
duplications.

Note: Previously, the compatibility code for 'check_procs <warn> <max>'
accepted something like 'check_procs -w 10:-1 -c 10:-1 20 50' as well
(treating it as if '-w 10:20 -c 10:50' was specified). This is no longer the
case ... additional arguments are only used as warn/crit thresholds in case
-w/-c is not specified at all.
2012-11-14 20:45:44 +01:00
Andreas Ericsson
c537d71a3a plugins/check_snmp: Show snmp error when we fail to parse its output
Dying without a hint of what went wrong is just plain annoying. With
this patch we at least get a hint.

While at it, we fix the string offset so the output we're interested
in doesn't keep the equal sign that snmpget prints.

Signed-off-by: Andreas Ericsson <ae@op5.se>
2012-11-02 22:25:37 -04:00
Andreas Ericsson
bd78299056 Make check_snmp backwards compatible in how it parses thresholds
Once upon a time, check_snmp used to accept inverse ranges in the
format of '2:1' to mean "alert if value is inside this range".

Since commit 7cb3ae0933, ranges such
as those have instead triggered the error "Range format incorrect"
and resulted in an UNKNOWN warning state. This patch attempts to
fix the situation so that the old-style ranges continues to mean
exactly what the once did and people with lots of snmp checks can
avoid a bazillion false positives from their environments.

Signed-off-by: Andreas Ericsson <ae@op5.se>
2012-11-02 22:25:37 -04:00
chl
a6ff5d4489 check_disk: option to ignore reserved space
This commit add a runtime option to ignore the root-reserved space
when calculating perfdata.

Before / after:
./check_disk -w 2% -c 1% /home
./check_disk -w 2% -c 1% -f /home
DISK CRITICAL - free space: /home 272 MB (1% inode=83%);| /home=17551MB;18401;18589;0;18777
DISK CRITICAL - free space: /home 272 MB (1% inode=83%);| /home=17551MB;17466;17644;0;17823

Well, it doesn't really give me more space :) but the perfdata are a
little bit more coherent.

Note that there are still a rounding issue on the percent calculation
(cf calculate_percent() comments, taken from coreutils 'df' command).
272/17823 -> 1.526%

Since the warning/critical/min/max data are usually not saved in RRD DB,
you can activate the option without seeing landslides in the graphs.
2012-10-12 15:55:38 +02:00
Holger Weiss
b74543a612 Allow for configuring OpenSSL
Let OpenSSL load its configuration file.  See the OPENSSL_config(3) man
page for details.

(Suggested by Max Kosmach in Debian bug report #689960, forwarded by Jan
Wagner.)
2012-10-09 09:44:48 +02:00
Alex Bradley
13e85a0f4f Tests for check_apt
Add a hidden "--input-file" option to check_apt (modelled on
check_procs) so that it can take files with sample apt output as input.

Add tests for my SECURITY_RE fix (debian3) and for the include, exclude
and critical options.
2012-10-03 15:54:24 -07:00
Alex Bradley
09c25be0d1 Fix SourceForge bug 1904965 - check_apt: SECURITY_RE is not correct
For the default security upgrade detection regular expression, match
"Debian-Security" in package description when it's anywhere after the
first parenthesis (not just the second space-delimited word). For
example:

... (4.0.1-5.4 Debian:6.0.6/stable, Debian-Security:6.0/stable ...
2012-10-03 15:25:51 -07:00
Alex Bradley
7918f5868c Don't prepend "^Inst" or append a space to the "include", "exclude", or
"critical" regular expressions. Instead, check for lines beginning
with "Inst" using strncmp and apply the regular expressions only when
such lines are found.

Fixes Debian bug #522812, along the lines suggested by the bug
submitter, Justin T Pryzby.
2012-10-02 23:22:54 -07:00
Gianluca Varisco
2672e95bca Update plugins/check_disk.c
CRITCAL -> CRITICAL typo
2012-09-25 17:45:12 +03:00
Holger Weiss
4cdda35b6c check_http: Update description of -C option
Mention that the -C option now accepts two comma-separated values.
2012-08-10 13:07:44 +02:00
Holger Weiss
d3c9728ebf check_http: Add missing newline to --help output 2012-08-10 13:05:31 +02:00
William Leibzon
6b844aea9f fixing bug in certificate experiation patch checking for bad warning threshold data 2012-08-10 13:03:00 +02:00
Holger Weiss
66003414af tests/check_http.t: Fix whitespace issues
In tests/check_http.t, tabs are used for indentation.

While at it, apply another few cosmetic changes.
2012-08-10 12:49:30 +02:00
Holger Weiss
3f944a50b7 tests/check_http.t: Update the number of SSL tests 2012-08-10 12:41:41 +02:00
Holger Weiss
62d01df1fd tests/check_http.t: Fix test case
Fix the test case which is meant to make sure that

	check_http -C <n>,<m> [...]

returns a CRITICAL state if <m> is large enough.
2012-08-10 12:35:16 +02:00
Holger Weiss
cc04d9f188 check_ntp_peer: Fix --help output for -m and -n
Fix the threshold specifications in the example for checking the number
of truechimers.

Reported by Marc Haber on the "nagios-users" mailing list (Message-ID:
<20120722142840.GA6931@torres.zugschlus.de>).
2012-08-06 21:03:06 +02:00
Holger Weiss
48b83c45af check_ntp_peer: Fix --help output for -W and -C
Mention that the check_ntp_peer plugin checks the stratum of the
synchronization peer, not the stratum of the monitored server itself.

Thanks to Marc Haber for bringing this up on the "nagios-users" mailing
list (Message-ID: <20120722142840.GA6931@torres.zugschlus.de>).
2012-08-06 20:37:43 +02:00
Holger Weiss
3c10d84ea2 check_http: Fix whitespace issues
In check_http.c, tabs aren't used for indentation.
2012-07-18 23:39:05 +02:00
Holger Weiss
ea595f1371 check_http: Fix compilation without SSL support
The "ssl_version" variable was undeclared when the plugins were compiled
--without-openssl and --without-gnutls.

Bug reported by Michael LaCorte on the "nagiosplug-help" mailing list
(Message-ID: <CCD30C91-A2A8-463A-82A9-F99B54F741D3@gmail.com>).
2012-07-18 23:31:17 +02:00
Sebastian Harl
c0bef3da51 check_pgsql: Determine connection time in µs-resolution.
… thus, treat "elapsed time" and the thresholds as floating point values.
2012-07-05 11:36:58 +02:00
Sebastian Harl
c56a22cbbf check_pgsql: Leave 'min' value in query perfdata empty.
There is no reasonable default value for that.
2012-07-05 11:36:58 +02:00
Sebastian Harl
034f6b3699 check_pgsql: Updated copyright. 2012-07-05 11:36:58 +02:00
Sebastian Harl
c3f97e6180 check_pgsql: Added support for the -o command line option.
This option may be used to specify further connection parameters to be passed
to PQconnectdb(). For example, this may be used to specify a service name in
pg_service.conf to be used for additional connection parameters: -o
'service=<name>' or to specify the SSL mode: -o 'sslmode=require'.

See the chapter "libpq - C Library" in the PostgreSQL manual for details.
2012-07-05 11:36:58 +02:00
Sebastian Harl
b3773ae7e5 check_pgsql: Removed -4/-6 flags from help output.
These options are not currently supported.
2012-07-05 11:36:58 +02:00
Sebastian Harl
a241ab0b9d check_pgsql: Allow UNIX socket directories as hostname as well.
PostgreSQL accepts the directory name of its UNIX socket as hostname as well,
e.g. /var/run/postgresql/.
2012-07-05 11:36:57 +02:00
Sebastian Harl
f3e2ebd974 check_pgsql: Use PQconnectdb() rather than PQsetdbLogin().
This is more flexible and the recommended way to connect to a PostgreSQL
database.

Also, the verbose output now includes detailed information about the
connection.
2012-07-05 11:36:57 +02:00
Sebastian Harl
58ef38e2bb check_pgsql: Fixed query perfdata output for empty warn/crit ranges.
Previously, "(null)" was printed (when using GNU's libc). This has been
changed to print the empty string instead.
2012-07-05 11:36:57 +02:00
Sebastian Harl
912df3ef9b check_pgsql: Added support for executing queries.
The query result (the double value of the first column in the first row, to be
precise) will be checked against threshold ranges specified using the -C and
-W options.

Note that this also allows to query PostgreSQL internal values using the
information available from the database daemon's "statistics collector" -- see
the chapter "Monitoring Database Activity" in the PostgreSQL manual for
details.
2012-07-05 11:36:57 +02:00
Holger Weiss
800a868713 Merge remote-tracking branch 'github/tokkee/sh/check_dbi' 2012-07-04 23:50:48 +02:00
Eric Stanley
49df5964eb Re-added missing variable declarations to check_smtp.c
A recent update removed the declarations for a couple variables in
check_smtp.c that are still being used, which caused a failure
in the compilation of check_smtp.c. This commit restores those variable
declarations so the check_smtp.c will again compile.
2012-07-04 12:48:07 -05:00
Holger Weiss
b57aeb1e5f check_smtp: Remove a comment regarding MAIL FROM
Earlier versions of check_smtp generated an (invalid) "MAIL FROM"
command without arguments by default.  These days, a "MAIL FROM" command
is only sent if the --from option is specified.

This commit removes a comment which explains the old behaviour, and it
updates a variable name accordingly.
2012-06-29 15:09:34 +02:00
Holger Weiss
973d147cef check_smtp: Fix help and usage output regarding -R 2012-06-29 14:25:40 +02:00
Anders Kaseorg
638b596992 check_smtp: Fix strcat overflows
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-06-29 13:39:11 +02:00
Anders Kaseorg
028d50d6f9 Die when asprintf fails
Fixes many instances of
warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-06-29 13:39:11 +02:00
Anders Kaseorg
9976876584 check_smtp: Strip angle brackets from -f argument, if provided
Apparently some people used -f '<nagios@example.com>' to work around
the bug I just fixed in the MAIL FROM: command generation.  Although
the resulting command wasn't RFC-compliant, it was working with some
MTAs, so let's continue to support this syntax now that we generate
RFC-compliant commands.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-06-29 13:39:11 +02:00
Anders Kaseorg
dd1e9eb5ea check_smtp: Change MAIL FROM: command to comply with the SMTP standard
Every version of the SMTP standard (from RFC 821 to the current RFC
5321) requires the address following MAIL FROM: to follow the colon
immediately (with no space) and to be surrounded by angle brackets.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-06-29 13:39:11 +02:00
Holger Weiss
cbc8a7f313 check_tcp: Print performance data even with -D
When using the 1.4.15 release of the Nagios Plugins, a command such as

  check_tcp -H pop.example.com -p 995 -D 14

usually produced two lines of output, e.g.:

  OK - Certificate will expire on 12/13/2014 23:59.
  TCP OK - 0.009 second response time on port 995|time=0.008849s;;;0.000000;10.000000

The second line was removed by 4d06603060.
However, as the old two-line output is a valid (though in this case
unintended) way to spit out performance data, removing the second line
might break current setups.  Therefore, we revert to the old behaviour,
at least for the moment.

The issue was reported by Jochen Bern on the "nagiosplug-devel" mailing
list (Message-ID: <4FEAE812.8030309@LINworks.de>).
2012-06-27 17:29:11 +02:00
Sven Nierlein
843f954056 check_snmp: use single quotes for perf data labels 2012-06-27 00:02:09 +02:00
Sven Nierlein
9c886d049d Fix performance data label containing spaces in check_snmp (Jochen Bern)
Add --perf-oids option for check_snmp to retain optional 1.4.14 compatibility
2012-06-26 20:53:13 +02:00
William Leibzon
181260d636 added test case for certificate checs with both warning and critical values 2012-06-25 12:54:15 +02:00
Sven Nierlein
24242f6ab7 check_http: added test for warning thresholds
fixed typo in sslutils
2012-06-25 12:53:47 +02:00
William Leibzon
fa3d2a4074 applied patch that adds both critical and warning thresholds to certificate expiration checks of check_tcp, check_http, check_smtp 2012-06-25 12:05:16 +02:00
Holger Weiss
88fdf3a8a8 check_ping: Add missing newline to die() calls
Our die() function expects the caller to append the trailing newline
character.
2012-06-25 01:58:17 +02:00
Holger Weiss
bf7c4f95ae Merge remote-tracking branch 'github/waja/master'
Conflicts:
	NEWS
2012-06-25 01:14:12 +02:00
Holger Weiss
991054fa6e check_ping: Ignore ping(1)'s exit status
Don't return a WARNING state if the number of lost packets is greater
than zero but below the specified warning threshold.  This happened
because the check_ping plugin used the exit status of the ping(1)
utility.  (#3535140 - Tobias Brox)
2012-06-24 15:51:56 +02:00
Holger Weiss
e6df238350 Fix check_by_ssh test for non-Bash login shells
In the C shell and in the Z shell, the "?" character must be quoted or
backslash-escaped in order to use it verbatim.  Therefore, a command
such as

	check_by_ssh -H test.example.com -l joe echo huh?

might fail, depending on joe's login shell on test.example.com.

Just to make sure, this commit removes most punctuation characters from
our test strings.
2012-06-22 17:11:18 +02:00
Holger Weiss
a80eafbf9c Improve parsing of ping6(1) output
The ping6(1) implementation provided by Debian's iputils-ping package
may produce output such as the following:

| 3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2009ms

There's a corresponding pattern in check_ping.c:458:

| "%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss"

Without this fix, the pattern in check_ping.c:456 matched first (as
sscanf(3) interprets "+3" as a match for "%d"):

| "%*d packets transmitted, %*d received, %d%% loss, time"

(#1894850 - Debian bug report #514588 - Matej Vela)
2012-06-11 23:40:04 +02:00
Holger Weiss
4e9eedc8de Fix whitespace and capitalization issues
Fix indentation and whitespace issues, and correct some capitalization
errors in error messages.  The behaviour is unchanged.
2012-06-11 23:34:15 +02:00
Holger Weiss
3fd1bd97ca Don't use SSLv2 when compiling against GnuTLS
GnuTLS doesn't support SSL version 2.
2012-06-11 23:23:40 +02:00
Sebastian Harl
e056cc9d82 t/check_dbi.t: Don't use 'INSERT … VALUES (a,b), (c,d)' with SQLite3.
Older versions of SQLite3 don't seem to support that.
2012-06-08 13:18:07 +02:00
Sebastian Harl
8455419650 Added a few test cases for the check_dbi plugin.
All tests use sqlite3. A temporary database is created for the purpose of the
tests.
2012-06-08 11:14:21 +02:00
Holger Weiss
094a6fa2f3 check_users: Whitespace fixes, etc. 2012-06-07 10:43:15 +02:00
M. Remy
3e622f3a47 check_users: improve performance
This patch use the utxent function family to collect the user data. It improve the check speed.
Need a system conforming to POSIX.1-2001.
2012-06-07 10:14:16 +02:00
Sebastian Harl
ce75adf287 check_dbi: Hint the user about cause when dbi init fails. 2012-06-06 15:06:44 +02:00
Sebastian Harl
022ba7ea3a check_dbi: Added simple regex example to help output. 2012-06-06 14:10:55 +02:00
Sebastian Harl
14fc0f741d check_dbi: Added SERVER_VERSION metric.
This metric compares the database engine server version with the specified
ranges. The version string [[[[A.]B.]C.]D.]E[.] is returned as E + D*100 +
C*10000 + B*1000000 + A*100000000 (see libdbi's dbi_conn_get_engine_version()
documentation).
2012-06-06 14:10:55 +02:00
Sebastian Harl
b7e661c4ae check_dbi: Added -r and -R options.
These options may be used to specify an extended POSIX regular expression that
is applied to the query result. When using -R, a case-insensitive match is
done.

The options may not be mixed with -w/-c/-e.
2012-06-06 14:10:55 +02:00
Sebastian Harl
aebde433fb check_dbi: Added -e option.
This option may be used to specify a string that is expected as the query
return value. The string is compared to the query result using strcmp().

The option may not be mixed with -w/-c.
2012-06-06 14:10:55 +02:00
Sebastian Harl
eda2fe7f40 check_dbi: Added some examples to the help output. 2012-06-06 14:10:55 +02:00
Sebastian Harl
4ad6e441b6 check_dbi: Added QUERY_TIME metric.
This metric checks the execution time of the specified query. In case the
query does not return any (parsable) data, this is not treated as an error
when using this metric.
2012-06-06 14:10:55 +02:00
Sebastian Harl
d7a1f2a7a0 check_dbi: Replaced -W/-C with -m.
The -m option may be used to specify a metric to check the thresholds against.
This is more flexible than --conntime-warning/--conntime-critical (-W/-C) as
it may be extended to support further metrics without introducing tons of
arguments. Also, it does not make much sense to check the conntime and query
result at the same time.

Currently, the metrics CONN_TIME and QUERY_RESULT are available.

A query is no longer required unless QUERY_RESULT (the default) is used.
2012-06-06 14:10:55 +02:00
Sebastian Harl
61506bd8d7 check_dbi: Fixed/improved perfdata output.
- do not use zero as 'min' value for the query result perfdata

 - added all semicolons
2012-06-06 14:10:55 +02:00
Sebastian Harl
0e02edec19 check_dbi: Check and report the time used by the query. 2012-06-06 14:10:55 +02:00
Sebastian Harl
e7dfcd4429 check_dbi: Added threshold ranges for the connection time.
The -W and -C options are used for that. The plugin return value is determined
by the worst check result.
2012-06-06 14:10:55 +02:00
Sebastian Harl
07768fa895 check_dbi: Include extra opts in help output. 2012-06-06 14:10:55 +02:00
Sebastian Harl
f9a942d2a1 Initial version of the 'check_dbi' plugin.
This plugin connects to an SQL database using libdbi, thus supporting all
database backends supported by libdbi. It will then issue the specified SQL
query and check the result (the numeric value of the first column of the first
row to be precise) against the specified warning/critical ranges.

The performance data includes the connection time (µs-resolution as provided
by gettimeofday()) and the query result.
2012-06-06 14:10:55 +02:00
Sebastian Harl
679a229606 sslutils: Check if OpenSSL supports SSLv2.
Recent versions/builds seem to disable that feature.
2012-06-06 13:48:52 +02:00
Holger Weiss
252ae618fc check_http: Fix -C/--certificate option handling
The support for specifying the desired SSL protocol version via an
optional -S/--ssl argument broke the -C/--certificate option.  This is
fixed now.
2012-05-29 12:59:16 +02:00