Pulse!


Pulse is a small framework for quickly building network probes and collect response time. Pulse is not intended to monitor complex networks or to replace most advanced tools such as Cacti. It's just a use to monitor response time variances on small amount of time. Right now there are two available probes: ICMP and HTTP but more are coming soon and little effort is required to build new ones from scratch. Let'see some examples.


ICMP Probe:


require 'pulse'
include Pulse

ICMP.pulse(:target => '192.168.1.1', :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



HTTP Probe:


require 'pulse'
include Pulse

HTTP.pulse(:target => 'http://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
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:


require 'pulse'
include Pulse

HTTP.pulse(:target => 'http://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


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


require 'pulse'
include Pulse

Pulse::DB::open('HTTP_pulse.sqlite')
HTTP.pulse(:target => 'http://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, Pulse::DB].each do |r|
r.report echo
end
end
end


The consistency of the Database is guaranteed by an at_exit{ } charged to close DB which in turn will gracefully handle script termination.

Pulse @ github

4 commenti:

thesp0nge ha detto...

Simply amazing.

I'm starting contributing with some bug hunting and a SQL probe :-)

belch ha detto...

You're wellcome :)

belch ha detto...

I just modified code examples after my daily refactoring. Suggestions, ideas, bugs .. are still very welcome!

Anonimo ha detto...

Great job Belch!!!;-)
Andrea S.

Posta un commento