Closed sanojsa closed 2 years ago
You are most likely running the script with Python2, the plugin requires at least python 3.x
I get the exact same error message when launching the plugin with python 2.7.5.
Yes, you are right. it works with python3
[root@podman plugins]# ./check_container_stats_podman.py usage: check_container_stats_podman.py [-h] -c CONTAINER_NAME [-t TIMEOUT] [--cpuwarn CPUWARN] [--cpucrit CPUCRIT] [--memwarn MEMWARN] [--memcrit MEMCRIT] [--pidwarn PIDWARN] [--pidcrit PIDCRIT] check_container_stats_podman.py: error: the following arguments are required: -c/--container [root@podman plugins]#
But running the script with container name getting unknown error as below.
[root@podman plugins]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 21cf78674785 registry.access.redhat.com/rhscl/mariadb-102-rhel7:latest run-mysqld 2 days ago Up 2 days ago 0.0.0.0:3306->3306/tcp recursing_moore ' [root@podman plugins]# ./check_container_stats_podman.py -c recursing_moore UNKNOWN - docker stats command returned error: b'Error: template: data:1:35: executing "data" at <.RunningFor>: can\'t evaluate field RunningFor in type shared.PsContainerOutput\n' [root@podman plugins]#
Ok, this error message indicates that the command syntax of the "podman"-binary you are working with is different from the versions I tested with.
Could you run the following commands on your system and provide the output?
podman --version
podman ps -a -f name=^your_container_name$ \
--format "{{.Names}},{{.Status}},{{.Size}},{{.RunningFor}}"
[root@podman ~]# podman --version podman version 1.6.4 [root@podman ~]#
[root@podman ~]# podman ps -a -f name=^recursing_moore$ --format "{{.Names}},{{.Status}},{{.Size}},{{.RunningFor}}" Error: template: data:1:35: executing "data" at <.RunningFor>: can't evaluate field RunningFor in type shared.PsContainerOutput [root@podman ~]#
[root@podman ~]# podman ps -a -f name=^happy_heisenberg$ --format "{{.Names}},{{.Status}},{{.Size}},{{.RunningFor}}" Error: template: data:1:35: executing "data" at <.RunningFor>: can't evaluate field RunningFor in type shared.PsContainerOutput [root@podman ~]#
Looking at the podman ps
documentation for 1.6.4 the .RunningFor
field which causes this problem is documented and should be working.
But there is a bug report for podman which matches your exact issue. This was fixed in a later release of podman.
So there is nothing I can do to fix this (as the root-cause for this issue is not within my plugin but the podman binary instead). My recommendation would be to update podman. Besides the functional aspect running outdated software could also be considered a security issue.
Getting below error while running the script.
===============================================================
File "check_container_stats_podman.py", line 79 result = subprocess.run((f'podman ps -a -f name=^{args.container_name}$ ' ^ SyntaxError: invalid syntax
=============================================================