Commit graph

157 commits

Author SHA1 Message Date
Ken D
69fed9d083 Updated int state to human readable 2022-01-14 15:52:00 +01:00
Ken D
a1f3289000 Added option for null zero length string exit codes
When using a large distributed network with the same group of checks used against a large number of devices, occationally there are missing cards in a few devices that are present in other devices. Rather than having a large number of unknown results, disable active checking on those large number of result or having to create a unique check configuration for those devices.

This option allows you to select an OK, WARNING, CRITICAL or UNKNOWN status while still retaining the default behavior when not present. This also allows a for the check to immediately start checks as intended should the hardware be added that the check is looking for.
2022-01-14 15:52:00 +01:00
Lorenz Kästle
c46447af65 Fix option description authpassword -> authpasswd 2021-11-19 09:30:20 +01:00
Lorenz Kästle
cf9dccbec2 Revert "Fixed option description authpassword -> authpasswd + whitespaces"
This reverts commit b27e639725.
2021-11-19 09:30:20 +01:00
Lorenz Kästle
a1fe4df6a3 Fixed option description authpassword -> authpasswd + whitespaces 2021-11-19 09:30:20 +01:00
Sven Nierlein
024d268386 check_snmp: fix performance thresholds when using multiple oids
when using check_snmp with multiple oids it simply printed the unparsed content
from -w/-c into the thresholds for each oid. So each oid contained the hole -w
from all oids.

./check_snmp ... -o iso.3.6.1.2.1.25.1.3.0,iso.3.6.1.2.1.25.1.5.0 -w '1,2' -c '3,4'

before:
  SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1,2;3,4 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;1,2;3,4

after:
  SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1;3 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;2;4

This also applies to fixed thresholds since check_snmp translates negative infinities from: '~:-1' to '@-1:~'
2021-11-17 14:04:09 +01:00
Sven Nierlein
de7effdf06
Merge pull request #1465 from lausser/master
check_snmp: put the "c" (to mark a counter) after the perfdata value
2021-04-07 17:12:38 +02:00
Sven Nierlein
b7de6ec8bd
Update check_snmp.c
remove unnecessary brackets in help text
2018-01-19 17:05:46 +01:00
Michael Kraus
9fa449119c check_snmp: make calcualtion of timeout value in help output more clear 2018-01-19 15:13:12 +01:00
Gerhard Lausser
c85281d25b check_snmp: put the "c" (to mark a counter) after the perfdata value 2017-02-07 14:15:47 +01:00
Sven Nierlein
d9999194e6 Revert "check_snmp: fix push request 1173 for SNMP responses without datatype indicator"
This reverts commit 3178c8c0ff.
2016-11-08 00:23:28 +01:00
Thomas Kurschel
3178c8c0ff check_snmp: fix push request 1173 for SNMP responses without datatype indicator 2016-11-08 00:11:04 +01:00
abrist
7276ce77c7 check_snmp.c - Added IPv6 support
The "-6" optarg now prepends the server_address with "udp6:" for the
snmpget external command as per the net-snmp syntax at:
http://www.net-snmp.org/wiki/index.php/FAQ:Applications_28

Thanks to DrydenK (Roberto Greiner) for the heads up.
2016-11-07 22:13:07 +01:00
Holger Weiss
37928b52a5 Merge branch 'maint'
* maint:
  sslutils: Remove superfluous parenthesis for sslv3 function too
  sslutils: remove superfluous parenthesis
  check_snmp: modified tests
  check_snmp.c: switched DEFAULT_TIMEOUT to DEFAULT_SOCKET_TIMEOUT (provided by utils.h), already used by help description, see issue #1318
  install snmpd on travis tests
  enable libtab on travis builds
  add perl snmp to travis dependencies
  NEWS: Mention check_ups performance data fix
  Fix incorrect performance data thresholds
  check_dhcp: Fix option parsing
  Fixes segfaults when running via monitoring worker (off-by-one)
  travis: fix http test host
  sslutils: Check if OpenSSL supports SSLv3.

Conflicts:
	NEWS
	plugins/sslutils.c
2015-10-08 12:52:10 +02:00
Sven Nierlein
edca257e20 use unknown exit code for help/version in plugins
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2015-10-04 19:24:30 +02:00
Oliver Skibbe
6ba26122f4 check_snmp.c: switched DEFAULT_TIMEOUT to DEFAULT_SOCKET_TIMEOUT (provided by utils.h), already used by help description, see issue #1318 2015-10-04 13:20:32 +02:00
Jan Wagner
96932fd7b7 check_snmp: small improvement by anonymous submission
- response should not start with the delimiter
- OID response value taken into account

Closes issue #1029
Closes push request #1173
2015-10-02 12:57:25 +02:00
Johannes Engel
7a33e28e4e Introduce support for SNMPv3 context in check_snmp
snmpget already supports using SNMPv3 contexts using the option "-n".
Thus all we need to do is introduce a new argument to check_snmp and
pass the argument on to snmpget using snmpget's option "-n".
Since "-n" is already in use for check_snmp for a different purpose,
we use "-N" instead.
2014-11-28 13:05:16 +01:00
Andreas Seemueller
6623a1c787 check_snmp: Add thresholds to performance data 2014-11-28 12:56:07 +01: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
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
11cf54ca78 Merge branch 'rename' 2014-01-21 07:59:07 -05: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
Holger Weiss
c3e756a855 Capitalize "Monitoring" when it's the first word 2014-01-20 03:12:50 +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
Sven Nierlein
4933146e00 check_snmp: add timeout handler befor running snmpget 2013-09-12 23:39:32 +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
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
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
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
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
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
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
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
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
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
Holger Weiss
b93c8eebc7 Cosmetic change
Replace all occurrences of "strstr(s, "c") == s" with "s[0] == 'c'".
2012-02-24 12:31:20 +01:00
Holger Weiss
0e3fa54782 Accept multiple labels specified with "-l"
Fix the code which accepts a comma-separated list of labels specified
via the "-l" option.

(Spotted by Oskar Liljeblad in Debian bug report #647020, forwarded by
Jan Wagner.)
2012-02-24 12:29:00 +01:00
Thomas Guyot-Sionnest
5a2814a21b Revert "check_snmp now considers strings returned by SNMP that contain just"
This reverts commit 896962a1ad.

Conflicts:

	NEWS
	plugins/tests/check_snmp.t

Notes:
	Reverting because I rebased a patch that was doing the same thing, plus
	fixing more related regressions, and both didn't work together.
	I kept the tests intact except for one that wouldn't pass on 1.4.14
	either
2010-11-30 22:48:43 -05:00
Thomas Guyot-Sionnest
df88f95fca check_snmp: Remove that is_numeric madness
Original patch to make Timeticks works as in check_snmp v1.4.14, it turns
out is_numeric isn't so useful and treating all types as numeric works
best for backwards-compatibility. This is how it used to work in 1.4.14.

As a special case, I also make calculate_rate look up for numeric values
as it would otherwise return the last value instead.
2010-11-30 22:32:33 -05:00
nagios
896962a1ad check_snmp now considers strings returned by SNMP that contain just
numbers (according to strtod) to be a numeric value for threshold and
performance data
2010-11-15 15:43:41 +00:00
Thomas Guyot-Sionnest
2527bdd4b6 Fix --help output when MAX_OIDS is altered. 2010-07-09 19:39:09 -04:00
tonvoon
5c72d075de Corrected rate_multiplier calculation 2010-06-30 13:16:32 +00:00
tonvoon
3444519014 Removed suffix of "-rate" and let user decide label via --label 2010-06-30 09:37:10 +00:00