Created
April 5, 2011 15:30
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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