Services-Statistics.md
... ...
@@ -4,18 +4,19 @@ Please add your public statistics.
4 4
## Scripts
5 5
6 6
### Number of prefixes for collectd
7
-**collectd.conf**
7
+
8
+#### collectd.conf
8 9
9 10
```
10 11
LoadPlugin exec
11 12
<Plugin exec>
12
- Exec nobody "/etc/collectd/bgp_prefixes.sh"
13
+ Exec nobody "/etc/collectd/bgp_prefixes-quagga.sh"
13 14
</Plugin>
14 15
```
15 16
16 17
collectd refuses to exec scripts as root. On Debian vtysh is compiled with PAM support: adding nobody to the quaggavty group suffices.
17 18
18
-**bgp_prefixes.sh**
19
+#### bgp_prefixes-quagga.sh
19 20
20 21
```
21 22
#!/bin/bash
... ...
@@ -34,6 +35,34 @@ sleep $INTERVAL
34 35
done
35 36
```
36 37
38
+#### Number of prefixes per neighbour for bird
39
+
40
+```
41
+#!/bin/sh
42
+#
43
+# Collectd script for collecting the number of routes going through each
44
+# BGP neighour. Works for bird.
45
+#
46
+# See https://dn42.net/Services-Statistics
47
+
48
+INTERVAL=60
49
+HOSTNAME=mydn42router
50
+[ -n "$COLLECTD_HOSTNAME" ] && HOSTNAME="$COLLECTD_HOSTNAME"
51
+
52
+while true
53
+do
54
+ birdc 'show protocols "*"' | grep ' BGP' | cut -d ' ' -f 1 | while read neighbour
55
+ do
56
+ nbroutes=$(birdc "show route protocol $neighbour primary count" | grep -v 'BIRD' | cut -d ' ' -f 1)
57
+ echo "PUTVAL $HOSTNAME/bird-bgpd/routes-$neighbour interval=$INTERVAL N:$nbroutes"
58
+ done
59
+ # FIXME: we probably count non-BGP routes here
60
+ totalroutes=$(birdc "show route primary count" | grep -v 'BIRD' | cut -d ' ' -f 1)
61
+ echo "PUTVAL $HOSTNAME/bird-bgpd/routes-all interval=$INTERVAL N:$totalroutes"
62
+ sleep $INTERVAL
63
+done
64
+```
65
+
37 66
### munin plugin
38 67
* add the following to /etc/munin/plugin-conf.d/munin-node
39 68