Skip to content

dbellucci/pulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pulse

Pulse is a small framework for building network prober and collect response time. Right now there are two available prober: ICMP and HTTP but more are coming soon and little effort is required to build new one from scratch.

ICMP probe

ICMP.pulse(:target => ‘192.168.1.1’, :count =>5, :round_trip => 5, :delta => 0.5) do |probe| probe.on_fail do |echo| Pulse::STDERR.report echo end

probe.on_pulse do |echo| Pulse::STDOUT.report echo end end

options

  • :count stop after sending number pulse

  • :round_trip waiting time for next pulse

  • :delta discard pulse if latency differ by at most delta

HTTP probe

HTTP.pulse(:target => ‘localhost/’, :count =>5, :round_trip => 5) do |probe| probe.on_fail do |echo| Pulse::STDERR.report echo end

probe.on_pulse do |echo| Pulse::STDOUT.report echo end end

A real HTTP Prober should take care of HTTP Response as well. Let’say we want to say alive! if and only if strings ‘works’ is contained on HTTP response (body) message:

HTTP.pulse(:target => ‘localhost/’, :count =>5, :round_trip => 5) do |probe| probe.grep ‘works’

probe.on_fail do |echo| Pulse::STDERR.report echo end

probe.on_pulse do |echo| Pulse::STDOUT.report echo end end

DNS probe

DNS.pulse(:target => ‘8.8.8.8’, :host => ‘www.google.it’, :count =>5, :round_trip => 1) do |probe| probe.on_fail do |echo| Pulse::STDERR.report echo end

probe.on_pulse do |echo| [Pulse::STDOUT, Pulse::DB].each do |r| r.report echo end end end

SQLite3 as sample collector

To collect round-trip time values pulse provides a SQLite3 Mixin module called Pulse::DB:

Pulse::DB::open(‘HTTP_pulse.sqlite’)

HTTP.pulse(:target => ‘localhost/’, :count =>5, :round_trip => 5) do |probe| probe.grep ‘works’

probe.on_fail do |echo| Pulse::STDERR.report echo end

probe.on_pulse do |echo| [Pulse::STDOUT, Pulse::DB].each do |r| r.report echo end end end

Hit ctrl-c when you want to stop probeing. The consistency of the Database is guaranteed by an at_exit{ } charged to close DB.

pulse as CLI

As you can see there is a bin/pulse:

belch@graal:~/git/pulse# RUBYLIB=./lib bin/pulse -h

Usage: pulse [options] Options: -t, –target <target> target host -c, –count <number> stop after sending number pulse -r, –roundtrip <seconds> waiting time for next pulse -d, –delta <seconds> discard pulse if latency differ by at most delta -w, –write <filename> sqlite filename -p, –probe <name> one of icmp, http, https, dns -g, –grep <pattern> pattern to check in response DNS Probe Specific Options: -q, –query <hostname> hostname to resolve -h, –help Show this message

which works quite well as a swiss knife:

belch@graal:~/git/pulse# RUBYLIB=./lib bin/pulse -t ‘localhost’ -c 5 -w http -p http -g ‘works’ pulse from host:localhost id:0 rtt:0.001801 pulse from host:localhost id:1 rtt:0.003447 pulse from host:localhost id:2 rtt:0.003329 pulse from host:localhost id:3 rtt:0.003172 pulse from host:localhost id:4 rtt:0.002782 belch@graal:~/git/pulse#

;)

Requirements

  • net-ping

TODO

  • Handle multiple targets at once

  • put core inside a reactor with event-machine

  • TCP, SQL, X509 probe

  • Json sample collector

  • Rails web interface

About

A Ruby based framework to monitor health of services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages