Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / router / dartybox @ d2161137

Historique | Voir | Annoter | Télécharger (3,4 ko)

1
#! /bin/sh
2
# Parse box information
3
# (c) 2013 - GPLv2 - Steve Schnepp <steve.schnepp@pwkf.org>
4
#
5
# Configuration is done via ENV vars, here is the default :
6
#
7
# [dartybox]
8
# env.IP 192.168.1.254
9

    
10

    
11
. $MUNIN_LIBDIR/plugins/plugin.sh
12

    
13
is_multigraph
14

    
15
# fail on error
16
set -e
17

    
18
IP=${IP:-"192.168.1.254"}
19

    
20
if [ "$1" = "config" ]
21
then
22
	echo multigraph dbox_adsl_bw
23
	echo graph_title DartyBox Adsl Bandwidth
24
	echo graph_category network
25
	echo up.label UpStream
26
	echo down.label DownStream
27
	echo multigraph dbox_adsl_att
28
	echo graph_title DartyBox Adsl Attenuation
29
	echo graph_category network
30
	echo up.label UpStream
31
	echo down.label DownStream
32
	echo multigraph dbox_adsl_snr
33
	echo graph_title DartyBox Adsl SignalNoise Ratio
34
	echo graph_category network
35
	echo up.label UpStream
36
	echo down.label DownStream
37
	echo multigraph dbox_adsl_pkt
38
	echo graph_title DartyBox Adsl Packets
39
	echo graph_category network
40
	echo up.label UpStream
41
	echo down.label DownStream
42
	echo up_c.label UpStream "(Correctable)"
43
	echo down_c.label DownStream "(Correctable)"
44
	echo up_u.label UpStream "(Uncorrectable)"
45
	echo down_u.label DownStream "(Uncorrectable)"
46
	echo up.type DERIVE
47
	echo down.type DERIVE
48
	echo up_c.type DERIVE
49
	echo down_c.type DERIVE
50
	echo up_u.type DERIVE
51
	echo down_u.type DERIVE
52
	echo up.min 0
53
	echo down.min 0
54
	echo up_c.min 0
55
	echo down_c.min 0
56
	echo up_u.min 0
57
	echo down_u.min 0
58
	echo multigraph dbox_adsl_uptime
59
	echo graph_title DartyBox Adsl Uptime
60
	echo graph_category network
61
	echo graph_vlabel days
62
	echo uptime.label Uptime
63

    
64
	exit 0
65
fi
66

    
67
TMPFILE=$(mktemp)
68
trap 'rm -f $TMPFILE' EXIT
69

    
70
wget -qO "$TMPFILE" http://$IP/adslstats.html
71

    
72
[ "$MUNIN_DEBUG" = 1 ] && cat "$TMPFILE"
73

    
74
get() {
75
	PATTERN=$1
76
	gawk "match(\$0, /var $PATTERN\s+=\s+\"([^\"]+)\"/, a) { print a[1] }" $TMPFILE
77
}
78

    
79
getDays() {
80
	# Convert "20 jours 2 heures 2 mn" in a number of days
81
	echo "$@" | gawk "match(\$0, /([0-9.]+) jours ([0-9.]+) heures ([0-9.]+) mn/, a) { print a[1] + a[2]/24 + a[3]/1440 }"
82
}
83

    
84
echo multigraph dbox_adsl_bw
85
echo up.value $(get UpStream)
86
echo down.value $(get DownStream)
87
echo multigraph dbox_adsl_att
88
echo up.value $(get AttNear)
89
echo down.value $(get AttFar)
90
echo multigraph dbox_adsl_snr
91
echo up.value $(get SNRNear)
92
echo down.value $(get SNRFar)
93
echo multigraph dbox_adsl_pkt
94
echo up.value $(get RSWORDSNear)
95
echo down.value $(get RSWORDSFar)
96
echo up_c.value $(get RSCORRERRORNear)
97
echo down_c.value $(get RSCORRERRORFar)
98
echo up_u.value $(get RSUNCORRERRORNear)
99
echo down_u.value $(get RSUNCORRERRORFar)
100
echo multigraph dbox_adsl_uptime
101
echo uptime.value $(getDays $(get AdslUpTime))
102

    
103
exit 0
104

    
105
:<<'EOF'
106
var ADSLLineStatus = "Etabli";
107
var ADSLMode    = "G992_1_A  (G.DMT)   ";
108
var UpStream    = "704";
109
var DownStream  = "7616";
110
var AttNear     = "33.5";
111
var AttFar      = "16.5";
112
var SNRNear     = "11.0";
113
var SNRFar      = "15.0";
114
var HECCountNear= "4836";
115
var HECCountFar= "6";
116
var AdslVer1    = "0x81ef5379";
117
var AdslVer2    = "0x6397bde2";
118
var CmvVer1         = "0x6f249e71";
119
var CmvVer2         = "0xa703362e";
120
var ES15CntNear = "0";
121
var ES15CntFar  = "0";
122
var CRCErrorsNear = "641";
123
var CRCErrorsFar = "7";
124
var ES1CNTNear  = "8";
125
var ES1CNTFar   = "0";
126

    
127
var ESTOTCNTFar = "5";
128
var ESTOTCNTNear = "452";
129
var RSWORDSNear = "1802451823";
130
var RSWORDSFar  = "2881437753";
131
var RSCORRERRORNear  = "57293";
132
var RSCORRERRORFar  = "301";
133
var RSUNCORRERRORNear  = "641";
134
var RSUNCORRERRORFar  = "7";
135
var RSRatioNear  = "0";
136
var RSRatioFar  = "0";
137
var AdslUpTime = "20 jours 2 heures 2 mn";
138
EOF