added hostapd clients, average bandwidth (rx, tx), average packets (rx, tx), transmit issues, average signal, average bitrate (rx, tx), average expected throughput
Costa Tsaousis (ktsaou) committed
Dec 27, 2015 at 05:00 UTC
97eedae38bb5e097577126be4365b09520c383bf
2 files changed
+171
-4
charts.d/ap.chart.sh
new
+159
@@ -0,0 +1,159 @@
1
+#!/bin/sh
2
+
3
+# _update_every is a special variable - it holds the number of seconds
4
+# between the calls of the _update() function
5
+ap_update_every=
6
+
7
+declare -A ap_devs=()
8
+
9
+export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
10
+
11
+# _check is called once, to find out if this chart should be enabled or not
12
+ap_check() {
13
+ local ev=$(iw dev | awk '
14
+ BEGIN {
15
+ i = "";
16
+ ssid = "";
17
+ ap = 0;
18
+ }
19
+ /^[ \t]+Interface / {
20
+ if( ap == 1 ) {
21
+ print "ap_devs[" i "]=\"" ssid "\""
22
+ }
23
+
24
+ i = $2;
25
+ ssid = "";
26
+ ap = 0;
27
+ }
28
+ /^[ \t]+ssid / { ssid = $2; }
29
+ /^[ \t]+type AP$/ { ap = 1; }
30
+ END {
31
+ if( ap == 1 ) {
32
+ print "ap_devs[" i "]=\"" ssid "\""
33
+ }
34
+ }
35
+ ')
36
+ eval "${ev}"
37
+
38
+ # this should return:
39
+ # - 0 to enable the chart
40
+ # - 1 to disable the chart
41
+
42
+ [ ${#ap_devs[@]} -gt 0 ] && return 0
43
+ return 1
44
+}
45
+
46
+# _create is called once, to create the charts
47
+ap_create() {
48
+ local ssid dev
49
+
50
+ for dev in "${!ap_devs[@]}"
51
+ do
52
+ ssid="${ap_devs[${dev}]}"
53
+
54
+ # create the chart with 3 dimensions
55
+ cat <<EOF
56
+CHART ap_clients.${dev} '' "Connected clients to ${ssid} on ${dev}" "clients" ${dev} ${dev} line 15000 $ap_update_every
57
+DIMENSION clients '' absolute 1 1
58
+
59
+CHART ap_bandwidth.${dev} '' "Bandwidth for ${ssid} on ${dev}" "kilobits/s" ${dev} ${dev} area 15001 $ap_update_every
60
+DIMENSION received '' incremental 8 1024
61
+DIMENSION sent '' incremental -8 1024
62
+
63
+CHART ap_packets.${dev} '' "Packets for ${ssid} on ${dev}" "packets/s" ${dev} ${dev} line 15002 $ap_update_every
64
+DIMENSION received '' incremental 1 1
65
+DIMENSION sent '' incremental -1 1
66
+
67
+CHART ap_issues.${dev} '' "Transmit Issues for ${ssid} on ${dev}" "issues/s" ${dev} ${dev} line 15003 $ap_update_every
68
+DIMENSION retries 'tx retries' incremental 1 1
69
+DIMENSION failures 'tx failures' incremental -1 1
70
+
71
+CHART ap_signal.${dev} '' "Average Signal for ${ssid} on ${dev}" "dBm" ${dev} ${dev} line 15004 $ap_update_every
72
+DIMENSION signal 'average signal' absolute 1 1
73
+
74
+CHART ap_bitrate.${dev} '' "Bitrate for ${ssid} on ${dev}" "Mbps" ${dev} ${dev} line 15005 $ap_update_every
75
+DIMENSION receive '' absolute 1 1024
76
+DIMENSION transmit '' absolute -1 1024
77
+DIMENSION expected 'expected throughput' absolute 1 1024
78
+EOF
79
+
80
+ done
81
+
82
+ return 0
83
+}
84
+
85
+# _update is called continiously, to collect the values
86
+ap_update() {
87
+ # the first argument to this function is the microseconds since last update
88
+ # pass this parameter to the BEGIN statement (see bellow).
89
+
90
+ # do all the work to collect / calculate the values
91
+ # for each dimension
92
+ # remember: KEEP IT SIMPLE AND SHORT
93
+
94
+ for dev in "${!ap_devs[@]}"
95
+ do
96
+ iw ${dev} station dump |\
97
+ awk "
98
+ BEGIN {
99
+ c = 0;
100
+ rb = 0;
101
+ tb = 0;
102
+ rp = 0;
103
+ tp = 0;
104
+ tr = 0;
105
+ tf = 0;
106
+ tt = 0;
107
+ rt = 0;
108
+ s = 0;
109
+ g = 0;
110
+ e = 0;
111
+ }
112
+ /^Station/ { c++; }
113
+ /^[ \\t]+rx bytes:/ { rb += \$3 }
114
+ /^[ \\t]+tx bytes:/ { tb += \$3 }
115
+ /^[ \\t]+rx packets:/ { rp += \$3 }
116
+ /^[ \\t]+tx packets:/ { tp += \$3 }
117
+ /^[ \\t]+tx retries:/ { tr += \$3 }
118
+ /^[ \\t]+tx failed:/ { tf += \$3 }
119
+ /^[ \\t]+signal:/ { s += \$2; }
120
+ /^[ \\t]+rx bitrate:/ { x = \$3; rt += x * 1000; }
121
+ /^[ \\t]+tx bitrate:/ { x = \$3; tt += x * 1000; }
122
+ /^[ \\t]+expected throughput:(.*)Mbps/ {
123
+ x=\$3;
124
+ sub(/Mbps/, \"\", x);
125
+ e += x * 1000;
126
+ }
127
+ END {
128
+ print \"BEGIN ap_clients.${dev}\"
129
+ print \"SET clients = \" c;
130
+ print \"END\"
131
+ print \"BEGIN ap_bandwidth.${dev}\"
132
+ print \"SET received = \" rb;
133
+ print \"SET sent = \" tb;
134
+ print \"END\"
135
+ print \"BEGIN ap_packets.${dev}\"
136
+ print \"SET received = \" rp;
137
+ print \"SET sent = \" tp;
138
+ print \"END\"
139
+ print \"BEGIN ap_issues.${dev}\"
140
+ print \"SET retries = \" tr;
141
+ print \"SET failures = \" tf;
142
+ print \"END\"
143
+ print \"BEGIN ap_signal.${dev}\"
144
+ print \"SET signal = \" s / c;
145
+ print \"END\"
146
+
147
+ if( c == 0 ) c = 1;
148
+ print \"BEGIN ap_bitrate.${dev}\"
149
+ print \"SET receive = \" rt / c;
150
+ print \"SET transmit = \" tt / c;
151
+ print \"SET expected = \" e / c;
152
+ print \"END\"
153
+ }
154
+ "
155
+ done
156
+
157
+ return 0
158
+}
159
+
web/index.html
+12
-4
@@ -655,7 +655,7 @@ function prepareScreen(data) {
655
c.category = c.type.split('.')[0];
656
657
var tmp = c.category.split('_')[0];
658
- if(tmp === 'net' || tmp === 'disk')
658
+ if(tmp === 'net' || tmp === 'disk' || tmp === 'ap')
659
c.category = tmp;
660
661
switch(c.category) {
@@ -682,6 +682,12 @@ function prepareScreen(data) {
682
c.glyphicon = "glyphicon-transfer";
683
break;
684
685
+ case 'ap':
686
+ c.category_priority = 35;
687
+ c.category_title = 'Access Points';
688
+ c.glyphicon = "glyphicon-transfer";
689
+ break;
690
+
691
case 'apps':
692
c.category_priority = 40;
693
c.category_title = 'Applications Monitoring';
@@ -868,7 +874,7 @@ function prepareScreen(data) {
874
});
875
sidebar += '</ul>';
876
}
871
- else if(t.name === 'net' || t.name === 'tc') {
877
+ else if(t.name === 'net' || t.name === 'tc' || t.name === 'ap') {
878
var interfaces = uniq_with_list(t.charts, function(c) { return c.family; });
879
880
sidebar += '<ul class="nav">';
@@ -884,8 +890,10 @@ function prepareScreen(data) {
890
var c = null;
891
var h = options.chartsHeight / 2;
892
switch(f.type) {
887
- case 'net' : h = options.chartsHeight; break;
888
- case 'tc' : h = options.chartsHeight; break;
893
+ case 'net' : h = options.chartsHeight; break;
894
+ case 'tc' : h = options.chartsHeight; break;
895
+ case 'ap_bandwidth': h = options.chartsHeight; break;
896
+ case 'ap_bitrate' : h = options.chartsHeight; break;
897
}
898
899
html += getMessage(f.id) + '<div data-netdata="' + f.id + '"'