preload preload preload preload

Monitoring services using Mon

Monitoring services using Mon

mon is a general-purpose scheduler and alert management tool used for monitoring service availability and
triggering alerts upon failure detection.

Mon uses some Linux command and services such as ping command to check host connectivity and mail servers for sending mail, so you must install postfix and other packages so that mon should work smoothly.

Installing and configuring Mon in Ubuntu

Now we will see how we can install and configure mon in Ubuntu.

Install process

$ sudo apt-get install mon

Start mon 

$ sudo /etc/init.d/mon start

Configuring Mon 

For configuring mon edit the configuration file /etc/mon/mon.cf

hostgroup servers 192.168.1.6  #There must be a one line gape after hostgroup line.

watch servers
    service ping
        interval 1m
        monitor fping.monitor
        period wd {Mon-Fri} hr {7am-10pm}
            alert mail.alert user@example.com
            alertevery 3m
        period wd {Sat-Sun}
            alert mail.alert user@example.com

First we define the hosts that we want to monitor. Then we create the a “watch” section for this hosts with only one service to monitor, the “ping” service. The service will be monitored using the monitor “fping.monitor” that you can find in “/usr/lib/mon/mon.d/fping.monitor”. Then we define the periods in which we want to monitor the hosts and the alert we will use if the monitor detects a fail. In this case we use the “mail.alert” agent that you can find in “/usr/lib/mon/alert.d/mail.alert”. An email to “user@example.com” will be sent if a fail is detected in the monitor.

Sample example for configuring mon for monitoring a host connectivity, mysql, apache and a web page.

hostgroup ping_services 192.168.1.6

hostgroup webservers itswork.com

hostgroup mysql_server localhost

hostgroup apache_service 192.168.1.6

watch ping_services
service ping
    interval 1m
    monitor fping.monitor
    period wday {Mon-Sun} hour {0-23}
        alert mail.alert user@example.com
        alertevery 1m

watch webservers example.com
service site
        interval 1m
        monitor http.monitor -p 80 -u /index.php
        period wday{Mon-Sun} hr {0am-24pm}
            alert mail.alert user@example.com

watch apache_service 192.168.1.6
service apache
        interval 1m
        monitor http.monitor
        period wday{Mon-Sun} hr {0am-24pm}
            alert mail.alert user@example.com

watch mysql_server
    service mysql
        interval 1m
        monitor mysql.monitor --username=mon --password=mon --database=mon localhost
        period wday {Mon-Sun}
            alert mail.alert -S "Host 1 Mysql Server is down!!" user@example.com
            upalert mail.alert -S "Host1 MYSQL server is back up" user@example.com
            alertevery 60s
            alertafter 3

For more help click here

  • Share/Bookmark
  • Leave a Reply

    * Required
    ** Your Email is never shared