Intro
Monit is a tool we can use to monitor any number of things on the Linux installations in AWS — from CPU usage to Internet connectivity.
* Website: https://mmonit.com/monit/
* Lots of configuration help can be found here and google. https://mmonit.com/wiki/Monit/ConfigurationExamples
We’re going to use it to monitor solr. Solr is a search database `systemd` service that occasionally fails without warning, possibly rendering your application useless. Having at least a notification email sent out will help you proactively address an issue before users/customers notice it.
Setup
Setup is fairly straightforward.
1. Install monit
`sudo apt-get install monit`
2. Edit (with sudo) the `/etc/monit/monitrc` file. This file contains all the rules and configurations. Copy/paste the file below *(`/etc/monit/monitrc`), completely overwriting the existing one. Make these changes as needed
- Alert email format
- desired alert recipient list
- Desired action on service anomaly. The provided file has solr set up for passive mode, so a solr failure will simply be logged in /var/log/monit.log` and an email will be sent. Change the mode from passive to active, and monit will persistently try to restart the service on its own.
- Desired services to monitor. You can add add’l service besides solr, just following the example. Nginx, mongod, etc.
- Desired frequency (in seconds) of status checking
3. Once the `monitrc` file is edited, you must restart monit for changes to take effect. `sudo service monit restart`. If it complains, do `journalctl -xe` to see where the syntax error is, likely it’s due to a typo in the `monitrc` config file.
That’s it! Install monit, copy/paste the config making the needed format changes, and restart monit. You can test the notifications by stopping solr, waiting for the periodic polling to register the downed service, and checking the specified alert email address for an email.
***