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.
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.'
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 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:
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
The following shows the complete /etc/monit.d/syncp-monit.conf sample file.
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:
- Stop the monit service.
#service monit stop
- Upgrade monit with the following command.
#yum update monit
- Check the monit configuration, start the monit service and verify run levels.
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