Giter VIP home page Giter VIP logo

monit-docker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

monit-docker's Issues

cpu_percent monitoring throws KeyError: 'percpu_usage'

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

Issues running `monit-docker` in `monit` container

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!

Generate pidfile for a running container

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.

Examples does not work (wrong syntax)

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 '' ?

`monit-docker` listed as zombie process

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.

Error in documentation (pidfile)

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.