Skip to content

Instantly share code, notes, and snippets.

@chrismay
Created April 5, 2011 15:30
Show Gist options
  • Save chrismay/903833 to your computer and use it in GitHub Desktop.
Save chrismay/903833 to your computer and use it in GitHub Desktop.
Crappy little perl script to extract perfdata from nagios and send it to graphite.
use Net::StatsD::Client;
use strict;
my $client = Net::StatsD::Client->new(host=>"your-statsd-host-here");
while(<>){
my ($host,$service,$perfdata) = split(/~/);
$host =~ s/\./-/g;
$service =~ s/ /_/g ;
my $prefix= "nagios." . $host . "." . $service;
my @perfdata_parts = split(";",$perfdata);
foreach (@perfdata_parts){
if (m/([a-z]*)=([0-9\.]*)/){
my $metric = $prefix . "." . $1 ;
$client->timing($metric,$2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment