forked from avar/munin-plugin-freenet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
freenet_gauge_
executable file
·96 lines (79 loc) · 2.37 KB
/
freenet_gauge_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/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 CONFIGURATION
[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 seconds
env.graph_info How long it takes to ping our peer nodes in seconds on average
env.label seconds
env.what volatile.averagePingTime
env.cdef count,1000,/
[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 $cdef = $ENV{cdef};
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
print qq{count.cdef $cdef\n} if (defined $cdef);
}
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";
}
}