Commit graph

159 commits

Author SHA1 Message Date
RincewindsHat
11487d161c Comment some endifs to make comprehension easier 2023-10-01 14:03:34 +02:00
RincewindsHat
1aaa238503 Use real booleans 2023-10-01 13:59:00 +02:00
RincewindsHat
0751063918 Homogenize whitespace usage 2023-10-01 13:55:22 +02:00
RincewindsHat
e695a81b13 Remove unnecessary type defines 2023-10-01 13:40:50 +02:00
waja
265a7c0ed8
Merge branch 'master' into compiler_warning_part_2 2023-06-28 16:39:27 +02:00
RincewindsHat
cb55797937 Refix spelling issues 2023-04-18 00:42:20 +02:00
RincewindsHat
ab62b2ce5d Fixes for -Wuninitialized 2023-04-18 00:20:28 +02:00
RincewindsHat
907b933a87 Fixes for -Wunused-parameters 2023-04-18 00:20:12 +02:00
RincewindsHat
6c78f0b5ea Fixes for -Wunused
* lib/utils_base.c
* plugins/check_curl.c
* plugins-root/check_dhcp.c
   Removed a line which theoretically can not do anything, but there was
   comment which indicated something else. Still trying this though.
2023-04-18 00:13:24 +02:00
Jan Wagner
0f3703e641 Fix a lot of typos reported by codespell 2023-04-14 18:35:00 +00:00
RincewindsHat
74b6984047 Merge branch 'master' into check_icmp_cleanup 2023-02-19 14:39:08 +01:00
RincewindsHat
423284edfa check_icmp: Fix compiler warning
This fixes a compiler warning which complains about an uninitialized
value for a variable which is then returned.
This had no real world impact, since the program would crash in the
branch where result is not set.
The variable is initialized to "-1" which would be the error for
inet_pton.
2023-02-19 14:34:29 +01:00
RincewindsHat
d3a4bad51d check_icmp: Fix compiler warning
This fixes a compiler warning with no real world impact.
The compiler complains about a missing return, which is correct, but
in that scenario the program would crash anyways, so this has no impact.
2023-02-19 14:31:21 +01:00
Lorenz Kästle
f79eb4f2ca Link plugins against libcrypto to make hashes available 2023-02-01 00:57:42 +01:00
Aksel Sjögren
e5db81bb29 check_icmp: fix parsing help/version long options
Fix parsing of the long options --help and --version. The special
handling must be done before calling getopt().
This fixes erroneous output like:

    ./check_icmp --version
    ./check_icmp: invalid option -- '-'
    ./check_icmp: invalid option -- 'e'
    ./check_icmp: invalid option -- 'r'
    ./check_icmp: invalid option -- '-'
    ./check_icmp: invalid option -- 'e'
    ./check_icmp: invalid option -- 'r'

Signed-off-by: Aksel Sjögren <asjogren@itrsgroup.com>
2022-11-29 16:38:33 +01:00
RincewindsHat
9a73a94258 Replace DBL_MAX with INFITY to check if value was set 2022-11-04 17:08:36 +01:00
RincewindsHat
7d074091db Remove hardcoded DBL_MAX definition 2022-11-04 16:53:57 +01:00
RincewindsHat
413af19555 Remove trailing whitespaces 2022-11-04 16:51:32 +01:00
eriksejr
ee50ddf698
Set msg_namelen to the size of the sockaddr struct for the appropriate address family and not sockaddr_storage (#1771)
Co-authored-by: Erik Sejr <eriks@ssimicro.com>
Co-authored-by: Lorenz <12514511+RincewindsHat@users.noreply.github.com>
2022-07-14 10:25:51 +02:00
Lorenz
6054055571
check_icmp: buffer offerflow (#1733)
* Fix different overflows

* Less includes

* Add testcases

* Remove unused variable

* Remove unused and commented includes
2022-03-15 22:00:55 +01:00
ghciv6
986b247946 - delay set_source_ip() until address_family is detected
- add a test to check '-s'
2022-01-29 12:19:23 +01:00
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