Monit [How to] : Playing with Monit

Playing with Monit

How to auto start jvm server process if it die while i’m not in my laptop? how to know my server is overloaded? Monit can do that easily .

Here I will show you a little trick using monit.


  1. apt-get install monit OR wget
  2. tar xvfz monit-5.4-linux-x64.tar.gz
  3. cd monit-5.4/
  4. nano conf/monitrc
  5. Scroll to the bottom, then find this "include /etc/monit/conf.d/*", if it have a “#” in front of the code, remove it
  6. bin/monit -c conf/monitrc
  7. mkdir /etc/monit.d
  8. nano /etc/monit.d/localhost
  9. Insert the script, (look below)
  10. pkill monit (test if monit working, kill the monit process)
  11. bin/monit -c conf/monitrc
  12. If it says "Starting monit daemon with http interface at []" it means Monit is working.
  13. Open your browser (admin/monit)

The code

set daemon 20   # TIMEOUT 20 Seconds
set logfile syslog facility log_daemon  # LOGGING

set mailserver port 587
         username "" password "PASSWORD"
         using tlsv1
         with timeout 30 seconds

set httpd port 2812 and
         use address
         allow localhost
         allow admin2:monit2

check process redis_stream
         matching "Redis_stream.php"
         start = "/usr/bin/php /home/fajri/php_project/php_twitter_phirehose/Redis_stream.php"
         if does not exist then start


In my Monit script, I want to autostart twitter stream, sometime it stop, actually it kill by linux, because there’s no process, and linux guess it’s zombie process, so linux kill it. Whereas, it working fine, but no new tweet and process so low. And it’s working fine to me, when it stop, monit will starting it again.


This simple post is just to show how to use Monit. And in my opinion, it’s so helpfull for backend dev like me 😀


So, I want to start monit when my server reboot, here is the script .


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s