Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 94 lines (76 sloc) 2.27 KB
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Net::FCP::Tiny;
=head1 NAME
freenet_gauge_ - Wildcard plugin to gauge a single value from Freenet's GetNode info
=head1 SYNOPSIS
This is a skeleton plugin that allows you to make a simple graph of
any value retrieved with FCP's C<GetNode> call.
=head1 SYNOPSIS
[freenet_gauge_threads]
env.title Freenet Java thread count
env.vlabel threads
env.info Number of threads
env.graph_info How many threads Freenet is using
env.label threads
env.what volatile.runningThreadCount
[freenet_gauge_avg_ping]
env.title Freenet average ping time
env.vlabel time
env.info Ping in milliseconds
env.graph_info How long it takes to ping our peer nodes in milliseconds on average
env.label milliseconds
env.what volatile.averagePingTime
[freenet_gauge_store_size]
env.title Freenet store size
env.vlabel bytes
env.info Store size in bytes
env.graph_info How big the local Freenet store is
env.label Store size
env.what volatile.storeSize
env.base 1024
env.draw AREA
=cut
my $title = $ENV{title} // die "give me a title=";
my $vlabel = $ENV{vlabel} // die "give me a vlabel=";
my $label = $ENV{label} // die "give me a label=";
my $info = $ENV{info} // die "give me a info=";
my $graph_info = $ENV{graph_info} // die "give me a graph_info=";
my $what = $ENV{what} // die "give me a what=, e.g. what=volatile.runningThreadCount";
my $base = $ENV{base} // 1000;
my $draw = $ENV{draw} // 'LINE';
given ($ARGV[0]) {
when ("config") {
print <<"END";
graph_title $title
graph_args --base $base --lower-limit 0
graph_vlabel $vlabel
graph_category freenet
graph_info $graph_info
count.label $label
count.type GAUGE
count.draw LINE
count.info $info
END
}
default {
my $fcp = Net::FCP::Tiny->new(
name => 'Freenet Munin Plugin',
host => $ENV{FREENET_HOST},
port => $ENV{FREENET_PORT},
);
my $value = 0;
if ($fcp) {
my $info = $fcp->array2hash($fcp->send_msg(<<'END'));
GetNode
WithPrivate=true
WithVolatile=true
EndMessage
END
$value = $info->{$what};
}
print "count.value $value\n";
}
}