check_docker
check_docker copied to clipboard
Checks fail with Podman
When using Podman the ckecks fail:
root@host:~# /usr/lib64/nagios/plugins/check_docker.py --cpu 80:90
Traceback (most recent call last):
File "/usr/lib64/nagios/plugins/check_docker.py", line 986, in main
[x.result() for x in futures.as_completed(threads)]
File "/usr/lib64/nagios/plugins/check_docker.py", line 986, in <listcomp>
[x.result() for x in futures.as_completed(threads)]
File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 425, in result
return self.__get_result()
File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib64/nagios/plugins/check_docker.py", line 413, in wrapper
func(container, *args, **kwargs)
File "/usr/lib64/nagios/plugins/check_docker.py", line 689, in check_cpu
usage = calculate_cpu_capacity_precentage(info=info, stats=stats)
File "/usr/lib64/nagios/plugins/check_docker.py", line 676, in calculate_cpu_capacity_precentage
system_delta = stats['cpu_stats']['system_cpu_usage'] - stats['precpu_stats']['system_cpu_usage']
KeyError: 'system_cpu_usage'
UNKNOWN: Exception raised during check': KeyError('system_cpu_usage',)
root@host:~# /usr/lib64/nagios/plugins/check_docker.py --memory 80:90:%
Traceback (most recent call last):
File "/usr/lib64/nagios/plugins/check_docker.py", line 986, in main
[x.result() for x in futures.as_completed(threads)]
File "/usr/lib64/nagios/plugins/check_docker.py", line 986, in <listcomp>
[x.result() for x in futures.as_completed(threads)]
File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 425, in result
return self.__get_result()
File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib64/nagios/plugins/check_docker.py", line 413, in wrapper
func(container, *args, **kwargs)
File "/usr/lib64/nagios/plugins/check_docker.py", line 523, in check_memory
adjusted_usage = inspection['memory_stats']['usage'] - inspection['memory_stats']['stats']['total_cache']
KeyError: 'stats'
UNKNOWN: Exception raised during check': KeyError('stats',)
I was able to workaround with this:
root@host:~# diff /usr/lib64/nagios/plugins/check_docker_old /usr/lib64/nagios/plugins/check_docker.py
522a523
> if "stats" not in inspection['memory_stats'].keys(): inspection['memory_stats']['stats'] = {'total_cache': 0};
675a677
> if "system_cpu_usage" not in stats['precpu_stats'].keys(): stats['precpu_stats']['system_cpu_usage'] = 0;
root@host:~#