downtime
checks your connection to a host (8.8.8.8
) and aggregates the up- or downtimes (connection or no connection) in a file in a human readable format. Connection is made via a call to dig +time=1 +tries=1 8.8.8.8
and wget -q -t 1 --timeout 1 --spider http://siebenlinden.de
, so your ruby process needs to be able to call that command - although it would be really easy to change which tool is used.
It was made to track e.g. outages of your ISP.
The implementation ignores all IOs beauty and treats file read and scan actions as free actions. Be warned.
Add this line to your application's Gemfile:
gem 'downtime'
And then execute:
$ bundle
Or install it yourself as:
$ gem install downtime
Call as downtime
.
It will create a downtime_wget.log
and a downtime_dig.log
file in the current working directory.
The files (downtime_*.log
) will look like this:
# This file was generated by the downtime ruby gem.
2015-01-01-10-22 up till 2015-01-02-08-10 (1000 minutes)
! went down after 1000 minutes of uptime.
2015-01-02-08-10 down till 2015-01-03-08-40 (30 minutes)
! went up after 30 minutes of downtime.
2015-01-02-08-40 up till 2015-01-03-08-45 (5 minutes)
Use as a cron-job (use [god]-gem if you like), e.g. with crontab -e
:
# m h dom mon dow command
*/5 * * * * cd /home/downtime-service/downtime && ~/.rvm/wrappers/default/downtime
(this assumes you use rvm
and the given path exists), will result in information put into /home/downtime-service/downtime/downtime.log
.
Its assumed you run in CET timezone.
Copyright 2015 Felix Wolfsteller, Siedlungsgenossenschaft Ökodorf e.G.
all code licensed under the GPL, version 3, which is included in the file gpl-3.0.txt
.
- Contact me, either by creating an issue or sending me a mail - sometimes stuff is more easily done at two!
- Fork it ( https://github.com/[my-github-username]/downtime/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request