forked from avar/munin-plugin-freenet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreenet_connections
executable file
·84 lines (68 loc) · 1.77 KB
/
freenet_connections
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
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Net::FCP::Tiny;
=head1 NAME
freenet_connections - Graph Freenet's connected peers
=head1 CONFIGURATION
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
given ($ARGV[0]) {
when ('config') {
print << "END";
graph_title Freenet connected peers
graph_args --lower-limit 0
graph_vlabel peers
graph_category freenet
graph_info How many peers our node is connected to
connected.label Connected peers
connected.type GAUGE
connected.draw AREA
connected.info Number of connected peers
connected.colour 008000
backedoff.label Backed off peers
backedoff.type GAUGE
backedoff.draw STACK
backedoff.info Number of peers that have backed off
backedoff.colour ff8c00
notconnected.label Not-connected peers
notconnected.type GAUGE
notconnected.draw STACK
notconnected.info Number of not-connected peers
notconnected.colour a0a0a0
END
}
when ('autoconf') {
my $fcp = Net::FCP::Tiny->new(
name => 'Freenet Munin Plugin',
host => $ENV{FREENET_HOST},
port => $ENV{FREENET_PORT},
);
if ($fcp) {
print qq{yes\n};
} else {
printf qq{no (could not make FCP connecton to %s:%d\n}, $ENV{FREENET_HOST}, $ENV{FREENET_PORT};
}
}
default {
my $fcp = Net::FCP::Tiny->new(
name => 'Freenet Munin Plugin',
host => $ENV{FREENET_HOST},
port => $ENV{FREENET_PORT},
);
if ($fcp) {
my $info = $fcp->array2hash($fcp->send_msg(<<'END'));
GetNode
WithPrivate=false
WithVolatile=true
EndMessage
END
printf qq{connected.value %d\n}, $info->{'volatile.numberOfConnected'};
printf qq{backedoff.value %d\n}, $info->{'volatile.numberOfRoutingBackedOff'};
printf qq{notconnected.value %d\n}, $info->{'volatile.numberOfNotConnected'};
}
}
}