Welcome to the IPFire Wiki

This wiki is a community-maintained resource about everything there is to know about IPFire.

Please join in and help us improving it!

monit

Introduction

Monit is a utility for managing and monitoring processes, files, directories and filesystems on a Unix system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. E.g. Monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses too much resources. You may use Monit to monitor files, directories and filesystems for changes, such as timestamps changes, checksum changes or size changes.

Links:\
Monit manpage\
Monit slideshow\

Configuration

The monit addon comes with a default configuration file monitrc in /etc.

Examples

Monitor asterisk instance

check process asterisk with pidfile /var/run/asterisk/asterisk.pid
`      start   = "/etc/init.d/asterisk start"`
`      stop    = "/etc/init.d/asterisk stop"`
`      restart = "/etc/init.d/asterisk restart"`
`      if failed host secure.dus.net port 5061 type TCP then alert`

check host proxy.dus.net with address proxy.dus.net
`      if failed`
`              port 5060 type tcp protocol sip`
`              with target "proxy.dus.net:5060"`
`      then alert`

check host sipgate.de with address sipgate.de
`      if failed`
`              port 5060 type udp protocol sip`
`              with target "sipgate.de:5060"`
`      then alert`

check file asterisk-log with path /var/log/asterisk/messages
       if match ".*Wrong password.*" then alert
`     if match "Oh dear... we couldn't allocate a port for RTP instance" then alert`
       if match "Registration for '41.*timed out" then alert
       if match "Registration for '42.*timed out" then exec "/usr/sbin/asterisk -r -x 'core restart now'"

check file asterisk-security path /var/log/asterisk/security
`     if match "InvalidPassword" then alert`

Monitor VDR process

check file vdr-log with path /var/log/vdr
`      if match "ERROR: video data stream broken" then alert #exec "/etc/init.d/runvdr-server restart"`
`      if match "SATIP-ERROR: Connect failed" then alert #exec "/etc/init.d/runvdr-server restart"`

check process vdr-server with pidfile /var/run/runvdr-server.pid
`      start program = "/etc/init.d/runvdr-server start" with timeout 60 seconds`
`      stop  program = "/etc/init.d/runvdr-server stop"`
`      if memory usage > 25% for 5 cycles then alert`
`      if memory usage > 30% for 5 cycles then restart`
Edit Page ‐ Yes, you can edit!

Older Revisions • January 28 at 4:45 pm