Skip to content

ping: '10 received' contains '0 received' #860

@TQQEU

Description

@TQQEU

This issue respects the following points:

Which variant of the Monitoring Plugins do you use?

  • .rpm/.deb package from repo.linuxfabrik.ch
  • Compiled for Linux from download.linuxfabrik.ch
  • Compiled for Windows from download.linuxfabrik.ch
  • Source Code from GitHub

Bug description

We encountered a strange error in our production, which we examined closer:

We get a ping output like this: [IP changed]

Destination host unreachable. PING 192.168.188.42: 10 packets transmitted, 10 received, 0% packet loss, time 1855ms. rtt min/avg/max/mdev = 19.958/463.855/1171.020/376.417 ms, pipe 6

the plugin reports critical, hence all is (somewhat) fine.


I dug into the source code:

https://github.com/Linuxfabrik/monitoring-plugins/blob/main/check-plugins/ping/ping#L128

state = STATE_CRIT if '0 received' in stdout else STATE_OK

The error seems to be: 10 received contains 0 received (the same would happen with 20, 30,...)

Steps to reproduce - Plugin call

./ping --host 192.168.188.42

Steps to reproduce - Data

No response

Environment

Linux […] 4.18.0-553.40.1.el8_10.x86_64 […]

Plugin Version

v2023112901

Python version

Python 3.6.8

List of Python modules

No response

Additional Information

Possible Solution

I suggest using a regex here, as re (regular expression library) is already loaded and used in the plugin.
Testing using \b is efficient as \b matches for the beginning of a word, so all kinds of seperators are valid - while numbers are not.

With the following code in line 128 it should work correctly:
state = STATE_CRIT if re.search(r'\b0 received', stdout) else STATE_OK

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions