1
mirror of https://git.dn42.dev/wiki/wiki.git synced 2024-12-18 05:25:53 +01:00
wiki/Services-Statistics.md

82 lines
1.7 KiB
Markdown
Raw Normal View History

2012-07-18 19:51:59 +02:00
# Statistics
Please add your public statistics.
## Scripts
### Number of prefixes for collectd
**collectd.conf**
```
LoadPlugin exec
<Plugin exec>
Exec nobody "/etc/collectd/bgp_prefixes.sh"
</Plugin>
```
collectd refuses to exec scripts as root. On Debian vtysh is compiled with PAM support: adding nobody to the quaggavty group suffices.
**bgp_prefixes.sh**
```
#!/bin/bash
INTERVAL=10
HOSTNAME=dn42.hq.c3d2.de
while true; do
n4=$(vtysh -d bgpd -c "show ip bgp"|grep Total|sed -e 's/Total number of prefixes //')
n6=$(vtysh -d bgpd -c "show ipv6 bgp"|grep Total|sed -e 's/Total number of prefixes //')
echo "PUTVAL $HOSTNAME/quagga-bgpd/routes-IPv4 interval=$INTERVAL N:$n4"
echo "PUTVAL $HOSTNAME/quagga-bgpd/routes-IPv6 interval=$INTERVAL N:$n6"
sleep $INTERVAL
done
```
### munin plugin
* add the following to /etc/munin/plugin-conf.d/munin-node
```
[quagga_bgp]
user root
```
* place the script as quagga_bgp in /etc/munin/plugins
```
#!/bin/sh
#
#
# Munin Plugin to show quagga bgp4 routes
# Standard Config Section Begin ##
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Quagga BGP4 Routes'
echo 'graph_args --base 1000 -l 0'
echo 'graph_scale yes'
echo 'graph_vlabel Received routes via BGP4'
echo 'graph_category Network'
echo 'bgproutes.label Routes'
echo 'graph_info Route information provided by quagga daemon via vtysh'
exit 0
fi
# Standard Config Section End ####
# Measure Section Begin ##########
data=($(vtysh -c "show ip bgp"|grep Total|cut -d" " -f5))
if [ "$data" = "" ]; then
echo bgproutes.value 0
else
echo bgproutes.value $data
fi
# Measure Section ##########
```
* restart munin-node