Pulse: Data Visualization with gruff



I spent yesterday night looking for a way to display the data collected by Pulse. After hard googling the web i found a beautifull gem called gruff. Plotting data with gruff is simply amazing and results in great quality graphs as you can see:



You can find my plot script inside Pulse@github. Have a look!

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

Thinking Functionally In Ruby


What functional programming is ?
Why it's a "pretty neat idea" ?
How to adopt functional programming principles in Ruby ?