Commit graph

138 commits

Author SHA1 Message Date
RincewindsHat
d28bab4dbd More wrong printf formatting 2021-11-24 19:02:17 +01:00
RincewindsHat
e2f24a5af3 Fix CodeQL checks 2021-11-24 14:25:42 +01:00
Aksel Sjögren
3f9b22ab16 check_icmp: Fix pkt perfdata in check_host mode
Add missing "warn" threshold field in "pkt" perfdata output.
Perfdata should be interpreted as;

  'label'=value[UOM];[warn];[crit];[min];[max]

With one field missing, the hardcoded min value '0' ended up in the
"crit" field, making applications interpreting the perfdata thining that
critical threshold is always exceeded.

Signed-off-by: Aksel Sjögren <asjogren@itrsgroup.com>
2021-11-15 17:55:49 +01:00
Aksel Sjögren
39c162e594
Fix check_dhcp tests
* try to use "/usr/sbin/ip" before "ifconfig" since the latter is
  obsolete on Linux to figure out interface to listen for DHCP messages.
  But keeping ifconfig method just in case.
  Without this, tests fail on boxes without ifconfig AND the correct
  interface named ethX.

* amend possible failure responses, as check_dhcp might get a DHCPOFFER,
  but from an unexpected address - which happens if the box running
  tests are on a network with a DHCP server.
2021-04-30 11:14:10 +02:00
Aksel Sjögren
e712d5a6ef
Add test-debug for plugins-root
Fixes "No rule to make target 'test-debug'" when running "make
test-debug" in root dir.
2021-04-30 11:14:04 +02:00
Tim Gates
dbdd0f972a
docs: fix simple typo, conspicuosly -> conspicuously
There is a small typo in plugins-root/check_icmp.c.

Should read `conspicuously` rather than `conspicuosly`.
2020-12-19 17:14:23 +11:00
Vadim Zhukov
60ec4d2901 Use size_t instead of int when calling sysctl(3).
Otherwise, it writes sizeof(size_t) bytes to &oldlen, smashing the stack.
2020-01-21 20:40:30 +01:00
Jacob Hansen
4a4ef0d689 check_icmp: Do not overwrite -4,-6 on lookup
In case we needed to do a lookup, we previously overwrote the
address_family to IPv6, even if we supplied -4 as a cmd line argument.

This commit should ensure the cmd line argument is always followed.

Signed-off-by: Jacob Hansen <jhansen@op5.com>
2018-12-10 14:39:13 +00:00
Jacob Hansen
ca6efcd02b check_icmp: emit error if multiple protocol version
As we do not support checking both IPv4 and IPv6 hosts in one execution
we emit an error if multiple protocol versions are defined in the cmd
line args.

Signed-off-by: Jacob Hansen <jhansen@op5.com>
2018-12-10 14:39:13 +00:00
Jacob Hansen
7a660b3f01 check_icmp: move opts string into a variable
This commit moves the opts string into a variable as it is now used
twice.

Signed-off-by: Jacob Hansen <jhansen@op5.com>
2018-12-10 14:39:13 +00:00
Jacob Hansen
0882b4201b check_icmp: Correctly set address_family on lookup
If a hostname is supplied instead of an IP address, the automatic
address family detection would fail to correctly set the IP protocol
version (it would always be IPv6).

We now supply AF_UNSPEC to getaddrinfo, which should then return the
correct address family in the result.

Signed-off-by: Jacob Hansen <jhansen@op5.com>
2018-12-07 09:51:21 +00:00
Jacob Hansen
e5eccb663e check_icmp: removed outcommented code
Signed-off-by: Jacob Hansen <jhansen@op5.com>
2018-12-07 09:51:21 +00:00
Jacob Hansen
e3ade3374a check_icmp: process protocol version args first
Detection of protocol version is in the previous patch implemented in
the add_target() function, which is called when adding the -H command
line argument. That means that if a protocal version argument (-4, -6)
is added after the -H then the protocol version might be incorrectly
set.

This patch ensures that we first process the protocol version arguments,
and then we process the rest of the arguments.

Signed-off-by: Jacob Hansen <jhansen@op5.com>
2018-12-07 09:51:21 +00:00
Jacob Hansen
8edac9421f check_icmp: Automatically detect IP protocol
This patch automatically detects whether the protocol version is IPv4 or
IPv6

All credits to: https://github.com/ghciv6

Signed-off-by: Jacob Hansen <jhansen@op5.com>
2018-12-07 09:51:21 +00:00
Lars Michelsen
248bebb037 Fixed parameter handling after 01efbb2183 2018-12-07 09:51:21 +00:00
Lars Michelsen
fd6dc66653 check_icmp: Add IPv6 support
This commit adds IPv6 capabilities to check_icmp. It is now possible to
specify the address family using the arguments -4 (default) or -6.

To make the change possible we had to move the argument parsing previous
to creating the socket to be able to create it with the correct address
family.

This commit also fixes some gcc 4.9.2 compiler warnings. It has been
tested with several current linux distributions (debian, ubuntu, rh,
sles).

This commit fixes monitoring-plugins/monitoring-plugins#1291
2018-12-07 09:51:21 +00:00
Holger Weiss
89d00d1c00 Apply another spelling fix 2017-01-10 21:34:58 +01:00
Jan Wagner
10fa79a97a Merge branch 'spell_fix' 2017-01-10 20:33:16 +01:00
Harald Koch
9dd09ec331 properly remove MSG_PEEK in check_dhcp.c. Fixes #1450. 2016-12-07 13:11:40 -05:00
Jan Wagner
dbb92c347e Spelling fixes suggested by lintian 2016-12-01 12:49:40 +01:00
Holger Weiss
8672529b37 check_dhcp: Make xid a bit more random
Don't just use the current time(2) to seed the PRNG that generates the
xid.  A DHCP server might be checked multiple times per second.
2016-09-16 09:43:04 +02:00
Holger Weiss
99f5be2992 check_dhcp: Don't peek before reading response
Omit a recvfrom(3) call which has the MSG_PEEK flag set and should have
no effect at all.  According to a comment in the code, this call was
meant to be a workaround to an opaque issue.  If anyone runs into that
issue, we should fix it properly instead.
2016-09-14 11:57:31 +02:00
Jan Wagner
25e6f5efaf Merge branch 'check_proc_1203'
(Closes #1371)
(Closes #1203)
2015-10-13 11:15:20 +02: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
abrist
d077d64e54 Fix for unclosed filehandle in pst3 on Solaris
On Solaris, check_procs uses pst3 instead of /bin/ps (see
http://monitoring-plugins.org/doc/faq/ps-on-solaris.html for background). There's
a small bug in pst3 which causes it to NOT report some processes that are at
the end of the process table, at least on very busy systems (we noticed this
on a CoolThreads T5240 with load averages up to 90).

The bug is that a filehandle is not properly closed.

Thanks to jwinkle01 for finding and patching the bug.

(Closes #1203)
2015-10-05 13:23:59 +02:00
Sven Nierlein
bebf1cd050 use unknown exit code for help/version in plugins-root as well
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2015-10-04 19:24:30 +02:00
Holger Weiss
466cb79e52 check_dhcp: Fix option parsing
The call_getopt() function didn't always return the correct number of
processed arguments.  However, since check_dhcp doesn't support
non-option arguments, the caller doesn't need this number anyway.

Closes #1345.
2015-10-02 12:18:13 +02:00
Jan Wagner
6a939fa1ba Fixes segfaults when running via monitoring worker
(off-by-one)

Grabed from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198318
2015-10-02 10:32:00 +02:00
Sven Nierlein
809508926f make use of MSG_CONFIRM optional
since MSG_CONFIRM is a linux thing and only available on linux kernels >= 2.3.15, see send(2)
2015-01-29 16:18:27 +01:00
Holger Weiss
ed9394880c check_icmp: Cast size_t values for printf(3)
Convert size_t values to unsigned long for printf(3) in order to
maximize portability.
2014-12-02 11:36:25 +01:00
Holger Weiss
9c289ec744 check_icmp: Fix a few type errors 2014-11-28 16:23:28 +01:00
Holger Weiss
8e5118e0cb Don't mix variable declarations and code
We still support pre-C99 compilers.
2014-11-28 16:23:28 +01:00
Matthieu Kermagoret
5265fabeb9 Use kernel reception time on ICMP packets to compute rtt.
This commit uses the SO_TIMESTAMP feature of setsockopt to fetch
kernel reception time of ICMP packets. This avoids invalid
computations of rtt on machines with heavy load and/or heavy
network traffic.
2014-11-28 16:23:27 +01:00
Jan Wagner
ba21e26443 check_icmp/check_dhcp: disable check, if we are root
As it is possible to use capabilities(7) on linux or solaris
privileges for example, it is not necessary in all cases to
have those binaries making use of setuid.
2014-07-06 13:29:24 +02:00
Spenser Reinhardt
e7e6edb2f8 plugins-root/check_dhcp.c - array out of bounds
Coverity 66488 - offer_packet->options has a max size of 312. It was being used in a loop verifying less than 311, but increasing by 2 per loop, causing a possible array index out of bounds. Changed to checking less than max length - 1. - SR
2014-06-28 18:22:04 +02:00
Holger Weiss
01e570f4a4 Capitalize "Monitoring Plugins"
"Monitoring Plugins" is a name.
2014-01-21 16:19:20 +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
6e9d16809e check_dhcp: fix mac address and interface number detection on solaris
newer (or x86) solaris implementations have interface names like e1000g0
which includes numbers. So we reverse the interface number detection to
get the last number, instead of the first number.
2013-09-17 19:56:55 +02:00
Sven Nierlein
08d554ada1 check_dhcp: fix tests interface detection 2013-09-17 13:13:26 +02:00
Sven Nierlein
2b23caf3d1 check_dhcp: fix tests for machines with default interace != eth0 2013-09-16 13:49:44 +02:00
Sven Nierlein
095e2e5db5 check_dhcp test: skip subtests if no variable is set 2013-09-16 08:51:04 +02:00
Sven Nierlein
5d58592cfe check_dhcp: add test file 2013-09-15 22:15:21 +02:00
Sven Nierlein
3c958ac738 check_icmp: tests do not require sudo if run by root 2013-09-15 21:57:27 +02:00
Sven Nierlein
a7f5e8a765 plugins-root: include t folder in release tarball 2013-09-15 21:33:29 +02:00
Holger Weiss
317d2896dc check_icmp: Minor whitespace/indentation fixes 2013-09-04 22:28:50 +02:00
Holger Weiss
a480681cb7 check_icmp: Support "--help" and "--version"
Let check_icmp provide "--help" and "--version" flags (in addition to
"-h" and "-V"), just as the other plugins do.
2013-09-04 22:20:26 +02:00
Holger Weiss
4d52762732 check_dhcp: Don't misinterpret the "siaddr" field
RFC 2131 (2.) says: "DHCP clarifies the interpretation of the 'siaddr'
field as the address of the server to use in the next step of the
client's bootstrap process."  So, we shouldn't interpret this field as
the DHCP server's own address.  (#3503921 - Jason Ellison)
2012-06-14 00:39:55 +02:00
Holger Weiss
f091d59e0f check_dhcp: Fix handling of "pad" options
Don't let "pad" options[*] terminate the parsing of DHCP options.  This
bug was triggered by using check_dhcp against Windows 2003 DHCP servers
(see #3503921).

[*] Cf. RFC 2132, 3.1.
2012-06-13 12:36:42 +02:00
Sebastian Harl
5ebe25fc24 check_host: Allocate a large-enough buffer for the host table.
When specifying a host-name on the command line, each of its IPs is added to
the host table (and each one is pinged). So, the buffer has to be large enough
to hold all of the respective host objects. (argc - 1) only fits hosts with a
single IP.

Thanks to Max Kosmach <max@tcen.ru> for reporting this in Debian bug #623702.
2011-04-28 20:42:53 -04:00