20d9d07a27adf5299ee82fe848ad884eca9c8631
Services-Statistics.md
| ... | ... | @@ -0,0 +1,82 @@ |
| 1 | +# Statistics |
|
| 2 | +Please add your public statistics. |
|
| 3 | + |
|
| 4 | +## Scripts |
|
| 5 | + |
|
| 6 | +### Number of prefixes for collectd |
|
| 7 | +**collectd.conf** |
|
| 8 | + |
|
| 9 | +``` |
|
| 10 | +LoadPlugin exec |
|
| 11 | +<Plugin exec> |
|
| 12 | + Exec nobody "/etc/collectd/bgp_prefixes.sh" |
|
| 13 | +</Plugin> |
|
| 14 | +``` |
|
| 15 | + |
|
| 16 | +collectd refuses to exec scripts as root. On Debian vtysh is compiled with PAM support: adding nobody to the quaggavty group suffices. |
|
| 17 | + |
|
| 18 | +**bgp_prefixes.sh** |
|
| 19 | + |
|
| 20 | +``` |
|
| 21 | +#!/bin/bash |
|
| 22 | + |
|
| 23 | +INTERVAL=10 |
|
| 24 | +HOSTNAME=dn42.hq.c3d2.de |
|
| 25 | + |
|
| 26 | +while true; do |
|
| 27 | +n4=$(vtysh -d bgpd -c "show ip bgp"|grep Total|sed -e 's/Total number of prefixes //') |
|
| 28 | +n6=$(vtysh -d bgpd -c "show ipv6 bgp"|grep Total|sed -e 's/Total number of prefixes //') |
|
| 29 | + |
|
| 30 | +echo "PUTVAL $HOSTNAME/quagga-bgpd/routes-IPv4 interval=$INTERVAL N:$n4" |
|
| 31 | +echo "PUTVAL $HOSTNAME/quagga-bgpd/routes-IPv6 interval=$INTERVAL N:$n6" |
|
| 32 | + |
|
| 33 | +sleep $INTERVAL |
|
| 34 | +done |
|
| 35 | +``` |
|
| 36 | + |
|
| 37 | +### munin plugin |
|
| 38 | +* add the following to /etc/munin/plugin-conf.d/munin-node |
|
| 39 | + |
|
| 40 | +``` |
|
| 41 | +[quagga_bgp] |
|
| 42 | +user root |
|
| 43 | +``` |
|
| 44 | + |
|
| 45 | +* place the script as quagga_bgp in /etc/munin/plugins |
|
| 46 | + |
|
| 47 | +``` |
|
| 48 | +#!/bin/sh |
|
| 49 | +# |
|
| 50 | +# |
|
| 51 | +# Munin Plugin to show quagga bgp4 routes |
|
| 52 | + |
|
| 53 | +# Standard Config Section Begin ## |
|
| 54 | + if [ "$1" = "autoconf" ]; then |
|
| 55 | + echo yes |
|
| 56 | + exit 0 |
|
| 57 | + fi |
|
| 58 | + |
|
| 59 | + if [ "$1" = "config" ]; then |
|
| 60 | + |
|
| 61 | + echo 'graph_title Quagga BGP4 Routes' |
|
| 62 | + echo 'graph_args --base 1000 -l 0' |
|
| 63 | + echo 'graph_scale yes' |
|
| 64 | + echo 'graph_vlabel Received routes via BGP4' |
|
| 65 | + echo 'graph_category Network' |
|
| 66 | + echo 'bgproutes.label Routes' |
|
| 67 | + echo 'graph_info Route information provided by quagga daemon via vtysh' |
|
| 68 | + exit 0 |
|
| 69 | + fi |
|
| 70 | +# Standard Config Section End #### |
|
| 71 | + |
|
| 72 | +# Measure Section Begin ########## |
|
| 73 | + data=($(vtysh -c "show ip bgp"|grep Total|cut -d" " -f5)) |
|
| 74 | + |
|
| 75 | + if [ "$data" = "" ]; then |
|
| 76 | + echo bgproutes.value 0 |
|
| 77 | + else |
|
| 78 | + echo bgproutes.value $data |
|
| 79 | + fi |
|
| 80 | +# Measure Section ########## |
|
| 81 | +``` |
|
| 82 | +* restart munin-node |
|
| ... | ... | \ No newline at end of file |