diff options
author | Niklas Yann Wettengel <niyawe@niyawe.de> | 2018-03-07 19:50:28 +0100 |
---|---|---|
committer | Niklas Yann Wettengel <niyawe@niyawe.de> | 2018-03-07 19:50:28 +0100 |
commit | 4523a78c97519527ba92fb1ea4276f081e7c6629 (patch) | |
tree | b5e68bf4a0a3bcd783a364c9491a5ae74fef8f1a /roles/install_monitoring/files/munin/munin_fastd_traffic | |
parent | de66f3d823165844e7a97be6adfe24131e178e73 (diff) |
add munin monitoring
Diffstat (limited to 'roles/install_monitoring/files/munin/munin_fastd_traffic')
-rw-r--r-- | roles/install_monitoring/files/munin/munin_fastd_traffic | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/roles/install_monitoring/files/munin/munin_fastd_traffic b/roles/install_monitoring/files/munin/munin_fastd_traffic new file mode 100644 index 0000000..6b60a94 --- /dev/null +++ b/roles/install_monitoring/files/munin/munin_fastd_traffic @@ -0,0 +1,79 @@ +#!/usr/bin/perl -w +# -*- perl -*- + +=head1 NAME + +fastd_traffic_ - Plugin to monitor fastd traffic + +=head1 CONFIGURATION + +Set user and group to have access to the socket +Set path to socketfile if not /tmp/fastd.sock + + [fastd_traffic_*] + user fastd + group fastd + env.socketfile /tmp/fastd.sock + +=head1 USAGE + +Link this plugin to /etc/munin/plugins/ + +After creating the links, restart munin-node. Don't forget to configure the plugin! + +=head1 AUTHORS + +Dominique Goersch <mail@dgoersch.info> +Niklas Yann Wettengel <niyawe@niyawe.de> + +=head1 LICENSE + +GPLv2 + +=head1 MAGIC MARKERS + + #%# family=manual + +=cut + + +use strict; +use warnings; +use File::Basename; +use IO::Socket::UNIX qw( SOCK_STREAM ); +use JSON; + +if ($ARGV[0] and $ARGV[0] eq "config") { #config graph + print "graph_order down up\n"; + print "graph_title fastd traffic\n"; + print "graph_args --base 1000\n"; + print "graph_vlabel bits in (-) / out (+) per second\n"; + print "graph_category fastd\n"; + print "graph_info This graph shows the traffic of fast.\n"; + print "down.label received\n"; + print "down.type DERIVE\n"; + print "down.graph no\n"; + print "down.cdef down,8,*\n"; + print "down.min 0\n"; + print "up.label bps\n"; + print "up.type DERIVE\n"; + print "up.negative down\n"; + print "up.cdef up,8,*\n"; + print "up.min 0\n"; + exit 0; +} + + +my $statusfile = exists $ENV{'socketfile'} ? $ENV{'socketfile'} : "/tmp/fastd.sock"; #get path to socket from environment or use default +my $socket = IO::Socket::UNIX->new(Type => SOCK_STREAM,Peer => $statusfile) #open socket + or die("Can't connect to server: $!\n"); + +my $fastdstatus = ""; +foreach my $line (<$socket>) {$fastdstatus .= $line;} #read contents from socket +my $json = decode_json($fastdstatus); #decode json + +my $fastd_rx_bytes = $json->{statistics}->{rx}->{bytes}; #get recieved bytes from json +my $fastd_tx_bytes = $json->{statistics}->{tx}->{bytes}; #get transmittetd bytes from json + +print "up.value $fastd_tx_bytes\n"; #return transmitted bytes +print "down.value $fastd_rx_bytes\n"; #and recieved bytes |