Syncplicity Support

Search our knowledgebase to get the help you need, today

Follow

monit utility

The monit utility is a simple lightweight monitoring Open Source tool for managing and monitoring processes, programs, files, directories and filesystems on a Unix system. Monit is controlled via an easy to configure control file based on a free-format, token-oriented syntax. Monit logs to syslog or to its own log file and notifies you about error conditions via customizable alert messages.

This article describes the monit utility and how to use it to monitor and automatically restart the Storage Connector service. You can also use the monit utility to send email alerts if you have an SMTP server in your environment.

Installation and Configuration

NOTE: You may have the monit utility already installed on your Storage Connector.

Make sure you have the root password then use SSH to log in to the Storage Connector. Get root privileges using the su command.

Install monit using the following command in the console window:

#yum install monit

You can configure monit to monitor and recover the Storage Connector. The default configuration file is located at /etc/monit.conf. By default, it includes all files under the /etc/monit.d/ directory as config files. You can create a new config file under the /etc/monit.d/ directory and it is included automatically in config.

Issue the following command to create and/or open /etc/monit.d/syncp-monit.conf with the vi editor.

#vi /etc/monit.d/syncp-monit.conf

Alternatively, you can specify the control file directly by using the -c command line switch to monit. For example:

#monit -c /etc/monit.d/syncp -monit.conf

Add the following configuration to the /etc/monit.d/syncp-monit.conf file. The monit utility checks if the syncp-storage service is running; if not, monit starts the service. If the service is started 5 times in last 7 cycles then monit no longer starts the service. The monit utility generates email alerts if the service is not running and when the service is started.'

check process syncp-storage with pidfile /var/run/syncp-storage/syncp-storage.pid
            start program = "/etc/init.d/syncp-storage start"
            stop program = "/etc/init.d/syncp-storage stop"
            if 5 restarts within 7 cycles then stop

Set email alert

For email alerts, monit requires that an SMTP server is set up in the config file. Add the following configuration to /etc/monit.d/syncp-monit.conf file. Change <username> and <password> with your email server account username and password.

#Configure email address alerts to be sent to
set alert storage_connector-alerts@example.com
#Configure email server. Change <username> and <password>
#with your email server account username and password. 
#Do not use quotes
set mailserver smtp.example.com
            username “<username>"
            password “<password>"
            with timeout 20 seconds
#Configure email message format
set mail-format {
            from: monit@example.com
            reply-to: support@example.com
            subject: $SERVICE $EVENT at $DATE
            message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
            }

Configure the event queue

If the mail server is not available, monit can queue events in the local file-system for retry until the mail server recovers. Add the following configuration to the /etc/monit.d/syncp-monit.conf file.

set eventqueue basedir /var/monit slots 50

Save changes and start the monit service

Before monit is started for the first time, you can test the control file for syntax errors:

#monit -t 
Control file syntax OK

Start the monit service using the following command.

#service monit start

To have the monit service run automatically at startup, issue the following command.

#chkconfig monit on

If the monit service is already running, restart the service:

#service monit restart

Configuration Sample

The following shows the complete /etc/monit.d/syncp-monit.conf sample file.

set daemon 30
set logfile /var/log/monit
check process syncp-storage with pidfile /var/run/syncp-storage/syncp-storage.pid
      start program = "/etc/init.d/syncp-storage start"
      stop program = "/etc/init.d/syncp-storage stop"
      if 5 restarts within 10 cycles then stop
set alert storage_conenctor-alerts@example.com
set mailserver smtp.example.com
            username “<username>"
            password “<password>”
            with timeout 20 seconds
set mail-format {
            from: monit@example.com
            reply-to: support@example.com
            subject: $SERVICE $EVENT at $DATE
            message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
            }
set eventqueue basedir /var/monit slots 50

Upgrade procedure

To check if there is a newer version of monit in the repository, log in to the console and get root privileges. Execute the following command:

#yum check-update | grep monit

If there is a newer version, perform the upgrade procedure as follows:

  1. Stop the monit service.
    #service monit stop
  2. Upgrade monit with the following command.
    #yum update monit
  3. Check the monit configuration, start the monit service and verify run levels.
    #monit -t
    Control file syntax OK
    # service monit start
    # chkconfig --list monit
    monit 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Powered by Zendesk