Commit graph

82 commits

Author SHA1 Message Date
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
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
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
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
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
dbb92c347e Spelling fixes suggested by lintian 2016-12-01 12:49:40 +01: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
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
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
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
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
Thomas Guyot-Sionnest
eaf3cb27f4 Add newline after "Usage:" in --help 2010-04-22 08:57:14 -04:00
Thomas Guyot-Sionnest
884aee0667 Standardize the extra-opts notes 2010-04-21 23:29:18 -04:00
Thomas Guyot-Sionnest
25d1ee331d Fix translations when extra-opts aren't enabled
Bug #2832884 reported problem with translations outputting pot file
headers. This is caused by "" matching the header of the translation
files.

This patch moves gettext macros inside utils macros and update some
french translations.
2010-04-14 08:33:06 -04:00
Thomas Guyot-Sionnest
9c1aa029c0 Set proper network byte order for icmp_id and icmp_seq in icmp packets 2009-10-15 22:12:32 -04:00
Thomas Guyot-Sionnest
c2d9c59dc9 Increment per-host sequence in check_icmp 2009-10-15 21:52:18 -04:00
Matthias Eble
5f67308451 Fixed error in rtt/rta calculation in case of system clock problems
Time differences are now set to 0 in case of backward timejumps so there are no wrap-around problems any more.
The RTA calculation hopefully gets a more accurate value in these cases also.
2009-06-14 23:31:29 +02:00
Holger Weiss
bc827c9083 Don't use the plain char type for data buffers
Buffers which are used for holding arbitrary data should be referenced
using pointers to void and accessed using pointers to unsigned char.

Signed-off-by: Holger Weiss <holger@zedat.fu-berlin.de>
2009-06-02 01:09:18 +02:00
Matthias Eble
0a5cd15e75 Fixed check_icmp compiler warnings by including float.h
Self defined DBL_MAX caused compiler warnings. Now float.h
which defines DBL_MAX is included.
2009-06-01 22:41:46 +02:00