monit Usage Example


In debian the configuration is organized as followed.

/etc/monit# tree
├── conf.d
│   ├── cron -> ../monitrc.d/cron
│   ├── openssh-server -> ../monitrc.d/openssh-server
│   └── squid -> ../monitrc.d/squid
├── monitrc
├── monitrc.d
│   ├── cron
│   ├── openssh-server
│   └── squid
└── templates
    ├── rootbin
    ├── rootrc
    └── rootstrict

We put configuration files in monitrc.d and symlink it to conf.d to enable it.

monitoring squid3 memory usage

squid3 is a caching proxy that is memory hungry. It can control its memory consumption by itself in the configuration file, while it is demonstrative to have an example here.

# cat monitrc.d/squid
 check process squid3 with pidfile /run/
   start program = "/etc/init.d/squid3 start"
   stop  program = "/etc/init.d/squid3 stop"
   if totalmem > 30 MB then alert

And we can see the effect as

'squid3' total mem amount of 30848kB matches resource limit [total mem amount>30720kB]