Skip to content

Ruby gem to measure internet connectivity up and downtime (sort of ... using dig and wget).

License

Notifications You must be signed in to change notification settings

ecovillage/downtime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Downtime

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.

Installation

Add this line to your application's Gemfile:

gem 'downtime'

And then execute:

$ bundle

Or install it yourself as:

$ gem install downtime

Usage

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.

Caveats

Its assumed you run in CET timezone.

License

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.

Contributing

  1. Contact me, either by creating an issue or sending me a mail - sometimes stuff is more easily done at two!
  2. Fork it ( https://github.com/[my-github-username]/downtime/fork )
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

About

Ruby gem to measure internet connectivity up and downtime (sort of ... using dig and wget).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages