m-erhardt / check-container-stats

Icinga / Nagios plugins to check metrics of Docker / PodMan containers
GNU General Public License v3.0
9 stars 5 forks source link

Problem with perfdata check_container_stats_podman.py in net usage #1

Closed TheCry closed 2 years ago

TheCry commented 2 years ago

Hi, Your script is working fine, but i've a problem with the perdata of the net usage One container has not net usage and the out is like this

ID            NAME           CPU %       MEM USAGE / LIMIT  MEM %       NET IO      BLOCK IO           PIDS        CPU TIME    AVG CPU %
b5808b6f2ab5  test_container  1.05%       23.65MB / 10.26GB  0.23%       -- / --     46.24MB / 458.8kB  1           17.32594s   1.05%

I'd find out the problem in the code is here

container_stats['net_send'] = output.split(",")[4].split("/")[0].strip()
container_stats['net_send_byte'] = convert_to_bytes(output.split(",")[4].split("/")[0].strip())
container_stats['net_recv'] = output.split(",")[4].split("/")[1].strip()
container_stats['net_recv_byte'] = convert_to_bytes(output.split(",")[4].split("/")[1].strip())

Is it possible to extend the script, if "--/--" appears in the output, to set it to "0"? Or a new argument "no-usage" to set the variable to "0"? Regards Sascha

m-erhardt commented 2 years ago

Hi Sascha,

thanks for your feedback. I did not run into this particular edge-case on my systems yet. This should be an easy fix. Could you help me understand what causes the NET IO stats to show "--".

Is it

It would probably be helpful to know the output of the following commands on your system

Regards Mauno

TheCry commented 2 years ago

Hi Mauno, Here the infos you need podman stats test_container --no-stream --format "{{.Name}},{{.ID}},{{.CPUPerc}},{{.MemUsage}},{{.NetIO}},{{.BlockIO}},{{.PIDs}}" Output test_container,b5808b6f2ab5,1.06%,23.65MB / 10.26GB,-- / --,46.24MB / 458.8kB,1

It is a container running under podman. I'm responsible for the monitoring and my skill in podman are not the best :) But this container has no mapped ports

m-erhardt commented 2 years ago

I was able to replicate the problem on my systems.

Could you check/verify if the version at https://github.com/m-erhardt/check-container-stats/blob/fix-podman-empty-netio-stats/check_container_stats_podman.py works for you as well?

TheCry commented 2 years ago

Hi Mauno, thanks for the fix. It works perfect. Regards Sascha