decryptus / monit-docker Goto Github PK
View Code? Open in Web Editor NEWMonitor docker containers resources usage and execute docker commands or inside containers
License: GNU General Public License v3.0
Monitor docker containers resources usage and execute docker commands or inside containers
License: GNU General Public License v3.0
Hi,
when I run monit-docker with podman I get:
# /usr/local/bin/monit-docker -s running --name my_container monit --rsc cpu_percent
ERROR:2023-01-05 07:41:34: 'percpu_usage'
Traceback (most recent call last):
File "/usr/local/bin/monit-docker", line 1237, in main
monit_docker()
File "/usr/local/bin/monit-docker", line 842, in __call__
r = self.run(container, data)
File "/usr/local/bin/monit-docker", line 1190, in run
raise MonitDockerExit(int(self._get_resource_info(rsc, data, container['stats'])))
File "/usr/local/bin/monit-docker", line 745, in _get_resource_info
return self._calc_cpu_percent(current['cpu_stats'],
File "/usr/local/bin/monit-docker", line 637, in _calc_cpu_percent
online_cpus = len(cur_stats['cpu_usage']['percpu_usage'])
KeyError: 'percpu_usage'
Seems like percpu_usage
is not available in cur_stats:
{'total_usage': 2341398947000, 'usage_in_kernelmode': 789813906, 'usage_in_usermode': 2340609133094}
Maybe you can improve error handling.
Best,
floek
Thanks for this project here!
I was very excited when I found it.
During setup I am facing some issues though (not sure if my approach is valid or completly bogus): I have installed monit-docker
via pip into a container running monit
.
My goal is to monitor other docker containers and report to m/monit
(with entries in the http
file of the monit
instance as shown in the README).
When invoking the pip installed monit-docker
from within the monit
container I see
/usr/bin/monit-docker --name $CONTAINER monit --rsc status
ERROR:2020-12-29 22:33:50: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Which leaves me puzzled since I don't know what might be the issue here.
Any help is appreciated!
Hello, this is a new feature request I think it can be very useful.
Basicallly the idea is to know when a container is restarted.
The main idea is to generate a pid file for a running container, so we can really monitor it with monit/mmonit.
The followin command returns the real pid of a running container:
docker inspect -f '{{.State.Pid}}' container_name
I would like an option like --piidfile in your monit-docker program. That way, to get an alert would be very easy:
check process my_pid_container with pidfile /var/run/my_pid_container.pid
if changed pid then alert
Do you think that is possible to make this feature ?
Thaks a lot for your time.
Heho. I really like this project, but I can't get the examples to work.
bash-5.1# monit-docker monit --name 'bar*' --cmd-if 'status in (pause,running) ? kill'
usage: monit-docker [-h] [-c CONFFILE] [--client CLIENT] [--client-from-env] [--ctn-group CTN_GRP] [--id ID] [--image IMAGE] [--label LABEL] [-s {running,created,paused,restarting,removing,exited,dead}]
[-l {critical,error,warning,info,debug}] [--logfile LOGFILE] [--runtimedir RUNTIMEDIR] [--name NAME]
{monit,stats} ...
monit-docker: error: no argument is allowed - use option --help to get an help screen
bash-5.1# monit-docker monit --name 'foo*' --cmd-if 'mem_percent > 60 ? restart' --cmd-if 'cpu_percent > 90 ? restart'
usage: monit-docker [-h] [-c CONFFILE] [--client CLIENT] [--client-from-env] [--ctn-group CTN_GRP] [--id ID] [--image IMAGE] [--label LABEL] [-s {running,created,paused,restarting,removing,exited,dead}]
[-l {critical,error,warning,info,debug}] [--logfile LOGFILE] [--runtimedir RUNTIMEDIR] [--name NAME]
{monit,stats} ...
monit-docker: error: no argument is allowed - use option --help to get an help screen
bash-5.1#
Could it be that the "monit" need to be after --name '' ?
ps axo stat,ppid,pid,comm | grep -w defunct
Zs 14452 14895 monit-docker <defunct>
Zs 14452 14896 monit-docker <defunct>
After killing the parent process (14452 here), monit-docker starts up again and is again listed as a zombie process by the system.
Is there a way to prevent this? This started occuring a few days ago - before, everything was fine.
Hello again,
I think that the documentation is not correct related to pidifle, it is written "check program" :
check program docker.foo_php_fpm.pid with pidfile /run/monit-docker/foo_php_fpm.pid
group monit-docker
if changed pid then alert
And It sholud be "check process":
check process docker.foo_php_fpm.pid with pidfile /run/monit-docker/foo_php_fpm.pid
group monit-docker
if changed pid then alert
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.