naparuba / check-linux-by-ssh

Shinken checks designed to be run without installing something on the distant linux (aside ssh keys of course!)
MIT License
43 stars 47 forks source link

check_cpu_stats_by_ssh.py fails when parsing mpstat output #55

Open francoismdj opened 7 years ago

francoismdj commented 7 years ago

CPU checks from linux-ssh pack pack fail on old servers:

/var/lib/shinken/libexec/check_cpu_stats_by_ssh.py -H $host -p 22  -u $user -i $key  -P "$pass"
Traceback (most recent call last):
  File "/var/lib/shinken/libexec/check_cpu_stats_by_ssh.py", line 139, in <module>
    stats = get_mpstat(client)
  File "/var/lib/shinken/libexec/check_cpu_stats_by_ssh.py", line 71, in get_mpstat
    pos[k] = elts.index(k)
ValueError: '%sys' is not in list

The reason is mpstat version 'sysstat version 5.0.5' (CentOs 4.6) use a column named '%system' instead of the expected '%sy' name and doesn't have a '%steal' column.

Here are my modifications (diff on check_cpu_stats_by_ssh.py):

75,78d74
<                     elif k == '%sys':
<                         pos[k] = elts.index('%system')
<                     elif k == '%steal':
<                         pass

Now the CPU check works fine. Shinken version : 2.4