PingMon: A stupid local-networking host 'ping' monitoring tool
One day at work I needed to periodically ping a host on our local network. Then I thought it would be great (well... just nice) that when the pings were unsuccessful I would get notified by email.
I was learning Ruby at that time and, instead of writing a simple shell script and set a cron job I thought... Maybe I could write a script in Ruby for this, Maybe I could practice writing some tests, I could even create a gem and learn how it's done, etc.
And this is the result:
A stupid monitoring tool which periodically pings a host and sends an email notification when it becomes unavailable.
It's been done merely for learning purposes so don't be too harsh on the code.
Installation & Usage
-
Install the gem as usual by entering: $ gem install pingmon
-
PingMon needs a YAML configuration file to operate, which is usually:
~/.pingmon.yml. To make PingMon create that file for you, type: $ pingmon build-config -
Edit
~/.pingmon.ymlto suit your needs. -
Finally, type
pingmonon your prompt and have fun! ;)
.pingmon.yml options
There are a number of options you can tweak in the .pingmon.yml config file. They
are pretty self-explanatory but I'll explain some of them here:
- host: specifies the host to 'ping' to.
-
mode: PingMon operation mode which should be one of
monitororping. Inpingmode, PingMon will ping the host specified one time only (for testing purposes). When inmonitormode, PingMon will ping the host specified periodically following themonitor_intervaloption. -
monitor_interval: when set to
monitormode it specifies the delay between pings to check the host status. ex: Setting it to15mwill ping thehostevery 15 minutes. -
notify_when_down:
trueorfalse. Tells PingMon to send an email notification when host can't be reached. -
notify_to: whom to notify (if more than one, comma separated). ex:
user@domain.com -
transport:
:sendmailor:smtp.:sendmailmay only work on unix/linux OS variants. -
smtp_options: when
transport:is set to:smtpyou should specify this options. They are passed as is toPony.mailmethod.
For more help, please take a look at the sample config file config/pingmon.yml or
at the one PingMon generates for you when you type pingmon build-config which is
usually located at: $HOME/.pingmon.yml.
External Dependencies
PingMon depends on the following gems:
- eventmachine ~> 0.12.10
- rufus-scheduler ~> 2.0.6
- pony ~> 1.0.1
Notes:
- eventmachine and rufus-scheduler are used when doing "pings" in monitor mode.
- Pony adds the mail sending logic
- This requirements are specified in the gemspec as well.
Coded by Estanislau Trepat, released under the MIT License: http://www.opensource.org/licenses/mit-license.php