In my latest frenzy, which was focused on HA more than performance, I installed some new servers, new services on those servers, and the general complexity of the entire setup for beeets.com doubled. I was trying to remember a utility that I saw a while back that would restart services if they failed. I checked my delicious account, praying that I had thought of my future self when I originally saw it. Luckily, I had saved it under my “linux” tag. Thanks, Andrew from the past.

The tool is called monit, and I’m surprised I ever lived without it. Not only does it monitor your services and keep them running, it can restart them if they fail, use too much memory/cpu, stop responding on a certain port, etc. Not only that, but it will email you every time something happens.

While perusing monit’s site, I saw M/Monit which allows you to monitor monit over web, essentially. The only thing I scratched my head about was that M/Monit uses port 8080 (which is fine) but NginX already uses port 8080, and I wasn’t about to change that, so I opened conf/server.xml and looked for 8080, replaced with 8082 (monit runs on 8081 =)). Then I reconfigured monit to communicate with M/Monit and vice versa, and now I have a kickass process monitor that alerts me when things go wrong, and also sends updates to a service that allows me to monitor the monitor.

I can’t look at things like queries/sec as I can with Cacti (which is awesome but a little clunky) but I can see which important services are running on each of my servers, and even restart them if I need to straight from M/Monit. The free download license allows to use M/Monit on one server, which is all I need anyway.

Great job monit team, you have gone above and beyond.

Trackback

OMGOSH 4 comments

  1. Although monit is free, I believe m/monit is only a free 30-day trial? Says my license is only good for another month under the “Admin” tab.

  2. Andrew Lyon said

    Rodney, I noticed the same a week or so after posting. m/monit doesn’t seem too complicated though, I might try to write my own when I’m not busy. Either way the real power is in monit.

  3. Hi,
    Correct me if I am wrong, I have installed mmonit-2.3.1 in debin lenny 5.07 version of 64bit.

    path is under /mmonit/mmonit-2.3.1/bin/mmonit file

    !/bin/sh
    DIR=$(dirname $0)

    export LD_LIBRARY_PATH=”$DIR/mmonit/mmonit-2.3.1/lib/:$LD_LIBRARY_PATH” export PATH=$/mmonit/mmonit-2.3.1/bin exec $DIR/mmonit-bin $@

    path under /mmonit/mmonit-2.3.1/bin/mmonit_init file

    !/bin/sh
    #

    Sample init script for M/Monit to be placed in /etc/init.d/ and linked to run levels
    # DESC=”mmonit” NAME=mmonit DAEMON=/mmonit/mmonit-2.3.1/bin/$NAME SCRIPTNAME=/etc/init.d/$mmonit_init PIDFILE=/var/run/mmonit.pid

    Gracefully exit if the package has been removed.
    test -x $DAEMON || exit 0 d_start() { $DAEMON -p /var/run/ || echo -en “\n already running” } d_stop() { kill -QUIT cat $PIDFILE || echo -en “\n not running” } d_reload() { kill -HUP cat $PIDFILE || echo -en “\n can’t reload” } case “$1″ in start) echo -n “Starting $DESC: $NAME” d_start echo “.” ;; stop) echo -n “Stopping $DESC: $NAME” d_stop echo “.” ;; reload) echo -n “Reloading $DESC configuration…” d_reload echo “.” ;; restart) echo -n “Restarting $DESC: $NAME” d_stop sleep 5 d_start echo “.” ;; *) echo “Usage: $SCRIPTNAME {start|stop|restart|reload}” >&2 exit 3 ;; esac exit 0 after

    when I execute the init file shows the output as:

    in2:/mmonit/mmonit-2.3.1/bin# sudo /etc/init.d/mmonit_init restart Restarting mmonit: mmonitcat: /var/run/mmonit.pid: No such file or directory kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec … or kill -l [sigspec]

    not running/mmonit/mmonit-2.3.1/bin/mmonit: line 7: /mmonit/mmonit-2.3.1/bin/mmonit-bin: No such file or directory /mmonit/mmonit-2.3.1/bin/mmonit: line 7: /mmonit/mmonit-2.3.1/bin/mmonit-bin: Success

    not sure, whether the init script is correct or not else I need to add some more in the script.

    Is there anybody can help me out.

    Thanks,
    Nagaraj

  4. Andrew Lyon said

    Nagaraj,

    Can you post the code in https://pastee.org/ and post the link? The formatting is all messed up when you post as a comment.

    Thanks,
    Andrew

Add your comment now