git.infertux.com munin-bitcoin / master bitcoind_network_traffic
master

Tree @master (Download .tar.gz)

bitcoind_network_traffic @masterraw · history · blame

#!/bin/sh
# -*- sh -*-
# vim: ft=sh

: << =cut

=head1 NAME

bitcoind_network_traffic - Plugin to monitor the network traffic

=head1 CONFIGURATION

 [bitcoind*]
    user bitcoin
    env.binary bitcoin-cli
    env.data_dir /var/lib/bitcoin

=head1 AUTHOR

Cedric Felizard

=head1 LICENSE

AGPLv3+

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=cut

BINARY=${binary:-"/usr/bin/bitcoin-cli"}
DATA_DIR=${data_dir:-"/var/lib/bitcoin"}

if [ "$1" = "autoconf" ]; then
    autoconf="yes"

    command -v $BINARY >/dev/null || autoconf="no"

    echo $autoconf
    exit 0
fi

if [ "$1" = "config" ]; then
    echo 'graph_title Network traffic'
    echo 'graph_vlabel bytes'
    echo 'graph_category bitcoind'
    echo 'graph_info This graph shows the sum of incoming and outgoing traffic.'
    echo 'bitcoind_network_traffic.label network traffic'
    echo 'bitcoind_network_traffic.info The network traffic.'
    exit 0
fi

echo "bitcoind_network_traffic.value $($BINARY -datadir=$DATA_DIR getnettotals | grep totalbytes | grep -o '[0-9]*' | sed "N;s/\n/+/" | bc)"