services/Services-Statistics.md
... ...
@@ -1,111 +0,0 @@
1
-# Statistics
2
-Please add your public statistics.
3
-
4
-## Scripts
5
-
6
-### Number of prefixes for collectd
7
-
8
-#### collectd.conf
9
-
10
-```
11
-LoadPlugin exec
12
-<Plugin exec>
13
- Exec nobody "/etc/collectd/bgp_prefixes-quagga.sh"
14
-</Plugin>
15
-```
16
-
17
-collectd refuses to exec scripts as root. On Debian vtysh is compiled with PAM support: adding nobody to the quaggavty group suffices.
18
-
19
-#### bgp_prefixes-quagga.sh
20
-
21
-```
22
-#!/bin/bash
23
-
24
-INTERVAL=10
25
-HOSTNAME=dn42.hq.c3d2.de
26
-
27
-while true; do
28
-n4=$(vtysh -d bgpd -c "show ip bgp"|grep Total|sed -e 's/Total number of prefixes //')
29
-n6=$(vtysh -d bgpd -c "show ipv6 bgp"|grep Total|sed -e 's/Total number of prefixes //')
30
-
31
-echo "PUTVAL $HOSTNAME/quagga-bgpd/routes-IPv4 interval=$INTERVAL N:$n4"
32
-echo "PUTVAL $HOSTNAME/quagga-bgpd/routes-IPv6 interval=$INTERVAL N:$n6"
33
-
34
-sleep $INTERVAL
35
-done
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
-
66
-### munin plugin
67
-* add the following to /etc/munin/plugin-conf.d/munin-node
68
-
69
-```
70
-[quagga_bgp]
71
-user root
72
-```
73
-
74
-* place the script as quagga_bgp in /etc/munin/plugins
75
-
76
-```
77
-#!/bin/sh
78
-#
79
-#
80
-# Munin Plugin to show quagga bgp4 routes
81
-
82
-# Standard Config Section Begin ##
83
- if [ "$1" = "autoconf" ]; then
84
- echo yes
85
- exit 0
86
- fi
87
-
88
- if [ "$1" = "config" ]; then
89
-
90
- echo 'graph_title Quagga BGP4 Routes'
91
- echo 'graph_args --base 1000 -l 0'
92
- echo 'graph_scale yes'
93
- echo 'graph_vlabel Received routes via BGP4'
94
- echo 'graph_category Network'
95
- echo 'bgproutes.label Routes'
96
- echo 'graph_info Route information provided by quagga daemon via vtysh'
97
- exit 0
98
- fi
99
-# Standard Config Section End ####
100
-
101
-# Measure Section Begin ##########
102
- data=($(vtysh -c "show ip bgp"|grep Total|cut -d" " -f5))
103
-
104
- if [ "$data" = "" ]; then
105
- echo bgproutes.value 0
106
- else
107
- echo bgproutes.value $data
108
- fi
109
-# Measure Section ##########
110
-```
111
-* restart munin-node
... ...
\ No newline at end of file
services/Statistics.md
... ...
@@ -0,0 +1,111 @@
1
+# Statistics
2
+Please add your public statistics.
3
+
4
+## Scripts
5
+
6
+### Number of prefixes for collectd
7
+
8
+#### collectd.conf
9
+
10
+```
11
+LoadPlugin exec
12
+<Plugin exec>
13
+ Exec nobody "/etc/collectd/bgp_prefixes-quagga.sh"
14
+</Plugin>
15
+```
16
+
17
+collectd refuses to exec scripts as root. On Debian vtysh is compiled with PAM support: adding nobody to the quaggavty group suffices.
18
+
19
+#### bgp_prefixes-quagga.sh
20
+
21
+```
22
+#!/bin/bash
23
+
24
+INTERVAL=10
25
+HOSTNAME=dn42.hq.c3d2.de
26
+
27
+while true; do
28
+n4=$(vtysh -d bgpd -c "show ip bgp"|grep Total|sed -e 's/Total number of prefixes //')
29
+n6=$(vtysh -d bgpd -c "show ipv6 bgp"|grep Total|sed -e 's/Total number of prefixes //')
30
+
31
+echo "PUTVAL $HOSTNAME/quagga-bgpd/routes-IPv4 interval=$INTERVAL N:$n4"
32
+echo "PUTVAL $HOSTNAME/quagga-bgpd/routes-IPv6 interval=$INTERVAL N:$n6"
33
+
34
+sleep $INTERVAL
35
+done
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
+
66
+### munin plugin
67
+* add the following to /etc/munin/plugin-conf.d/munin-node
68
+
69
+```
70
+[quagga_bgp]
71
+user root
72
+```
73
+
74
+* place the script as quagga_bgp in /etc/munin/plugins
75
+
76
+```
77
+#!/bin/sh
78
+#
79
+#
80
+# Munin Plugin to show quagga bgp4 routes
81
+
82
+# Standard Config Section Begin ##
83
+ if [ "$1" = "autoconf" ]; then
84
+ echo yes
85
+ exit 0
86
+ fi
87
+
88
+ if [ "$1" = "config" ]; then
89
+
90
+ echo 'graph_title Quagga BGP4 Routes'
91
+ echo 'graph_args --base 1000 -l 0'
92
+ echo 'graph_scale yes'
93
+ echo 'graph_vlabel Received routes via BGP4'
94
+ echo 'graph_category Network'
95
+ echo 'bgproutes.label Routes'
96
+ echo 'graph_info Route information provided by quagga daemon via vtysh'
97
+ exit 0
98
+ fi
99
+# Standard Config Section End ####
100
+
101
+# Measure Section Begin ##########
102
+ data=($(vtysh -c "show ip bgp"|grep Total|cut -d" " -f5))
103
+
104
+ if [ "$data" = "" ]; then
105
+ echo bgproutes.value 0
106
+ else
107
+ echo bgproutes.value $data
108
+ fi
109
+# Measure Section ##########
110
+```
111
+* restart munin-node
... ...
\ No newline at end of file