Skip to content

Commit c45d760

Browse files
author
RubenKelevra
committed
cake: add two simple plugins
cake.cake_ renders the drops, overlimits and requeues as well as the backlog cake.cake_tin_ renders the packets sent in each tin
1 parent f96bcb4 commit c45d760

File tree

2 files changed

+356
-0
lines changed

2 files changed

+356
-0
lines changed

plugins/cake/cake_

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
# -*- sh -*-
3+
4+
: << =cut
5+
6+
=pod
7+
8+
=encoding UTF-8
9+
10+
=head1 NAME
11+
12+
cake_ - Plugin to monitor cake's backlog, dropped, overlimits and requeues
13+
14+
=head1 CONFIGURATION
15+
16+
None needed.
17+
18+
=head1 INTERPRETATION
19+
20+
Cake, also known as sch_cake is a modern bandwidth limiter, which eliminates
21+
buffer bloat over slow links. It's also capable to give flows, hosts and each
22+
flow of each host a fair part of the avaible bandwidth.
23+
24+
This plugin allows for a monitor of the pressure on the qdisc, by monitoring key
25+
values.
26+
27+
=head1 SEE ALSO
28+
29+
Take a look at "man cake" to get more information about cake.
30+
31+
=head1 MAGIC MARKERS
32+
33+
#%# family=auto
34+
#%# capabilities=autoconf suggest
35+
36+
=head1 AUTHORS
37+
38+
RubenKelevra <[email protected]>
39+
40+
work based on the tc plugin, authors:
41+
Steve Schnepp <[email protected]>,
42+
Samuel Smith <[email protected]>,
43+
44+
45+
=head1 LICENSE
46+
47+
GPLv2 or later
48+
49+
=cut
50+
51+
DEVICE=${0##*/cake_}
52+
53+
tc_cake_sent() {
54+
/sbin/tc -s qdisc show dev "$1" | grep -E "^ Sent" | tr ',' ' ' | tr ')' ' '
55+
}
56+
tc_cake_backlog() {
57+
/sbin/tc -s qdisc show dev "$1" | grep -E "^ backlog" | tr 'p' ' '
58+
}
59+
60+
case "$1" in
61+
autoconf)
62+
if [ -r /proc/net/dev ]; then
63+
echo yes
64+
exit 0
65+
else
66+
echo "no (/proc/net/dev not found)"
67+
exit 1
68+
fi
69+
;;
70+
suggest)
71+
if [ -r /proc/net/dev ]; then
72+
ifs="$(awk '
73+
/^ *(eth|tap|bond|wlan|ath|ra|sw|eno|ens|enp|wlp|wl)[0-9]*/ {
74+
split($0, a, /: */);
75+
gsub(/^ +/,"",a[1]);
76+
if (($2 > 0) || ($10 > 0)) print a[1]; }' /proc/net/dev)"
77+
cake_ifs=()
78+
for if in $ifs; do
79+
qdisc="$(/sbin/tc -s qdisc show dev "$if" | head -n1 | awk '{ print $2 }')"
80+
if [ "$qdisc" == "cake" ]; then
81+
cake_ifs+=("$if")
82+
fi
83+
done
84+
echo "$cake_ifs"
85+
fi
86+
exit 0
87+
;;
88+
config)
89+
90+
echo "graph_title $DEVICE cake packet handling stats"
91+
echo 'graph_args --base 1000'
92+
echo 'graph_vlabel packets per second'
93+
echo 'graph_category network'
94+
echo "graph_info This graph shows the general packet handling status of egress traffic of the $DEVICE network interface."
95+
96+
echo "backlog.label backlog";
97+
echo "backlog.draw LINE2";
98+
echo "backlog.info amount of packets currently buffered";
99+
100+
echo "dropped.label dropped"
101+
echo "dropped.draw AREA"
102+
echo "dropped.type DERIVE"
103+
echo "dropped.min 0"
104+
echo "dropped.info dropped packets in queue"
105+
echo "overlimits.label overlimits"
106+
echo "overlimits.draw STACK"
107+
echo "overlimits.type DERIVE"
108+
echo "overlimits.min 0"
109+
echo "overlimits.info packets exeeded a limit"
110+
echo "requeues.label requeues"
111+
echo "requeues.draw STACK"
112+
echo "requeues.type DERIVE"
113+
echo "requeues.min 0"
114+
echo "requeues.info packets requeued in queue"
115+
116+
exit 0
117+
;;
118+
esac
119+
120+
# sent
121+
tc_cake_sent "$DEVICE" | awk '{
122+
print "dropped.value " $7
123+
print "overlimits.value " $9
124+
print "requeues.value " $11
125+
}'
126+
# backlog
127+
tc_cake_backlog "$DEVICE" | awk '{
128+
print "backlog.value " $3
129+
}'
130+
131+
exit 0

plugins/cake/cake_tin_

+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
#!/bin/bash
2+
# -*- sh -*-
3+
4+
: << =cut
5+
6+
=pod
7+
8+
=encoding UTF-8
9+
10+
=head1 NAME
11+
12+
cake_tin_ - Plugin to monitor cake's tin' performances in packages per second
13+
14+
=head1 CONFIGURATION
15+
16+
None needed.
17+
18+
=head1 INTERPRETATION
19+
20+
Cake, also known as sch_cake is a modern bandwidth limiter, which eliminates
21+
buffer bloat over slow links. It's also capable to give flows, hosts and each
22+
flow of each host a fair part of the avaible bandwidth.
23+
24+
This plugin allows for a monitoring packets per tins on the qdisc.
25+
26+
=head1 SEE ALSO
27+
28+
Take a look at "man cake" to get more information about cake.
29+
30+
=head1 MAGIC MARKERS
31+
32+
#%# family=auto
33+
#%# capabilities=autoconf suggest
34+
35+
=head1 AUTHORS
36+
37+
RubenKelevra <[email protected]>
38+
39+
work based on the tc plugin, authors:
40+
Steve Schnepp <[email protected]>,
41+
Samuel Smith <[email protected]>,
42+
43+
44+
=head1 LICENSE
45+
46+
GPLv2 or later
47+
48+
=cut
49+
50+
DEVICE="wlp3s0"
51+
#DEVICE=${0##*/cake_tin_}
52+
53+
tc_cake_get_diffserv() {
54+
/sbin/tc -s qdisc show dev "$DEVICE" | head -n1 | grep -i "diffserv3" > /dev/null
55+
if [ $? -eq 0 ]; then
56+
echo 3
57+
fi
58+
/sbin/tc -s qdisc show dev "$DEVICE" | head -n1 | grep -i "diffserv4" > /dev/null
59+
if [ $? -eq 0 ]; then
60+
echo 4
61+
fi
62+
/sbin/tc -s qdisc show dev "$DEVICE" | head -n1 | grep -i "diffserv8" > /dev/null
63+
if [ $? -eq 0 ]; then
64+
echo 8
65+
fi
66+
return 0
67+
}
68+
69+
case "$1" in
70+
autoconf)
71+
if [ -r /proc/net/dev ]; then
72+
echo yes
73+
exit 0
74+
else
75+
echo "no (/proc/net/dev not found)"
76+
exit 1
77+
fi
78+
;;
79+
suggest)
80+
if [ -r /proc/net/dev ]; then
81+
ifs="$(awk '
82+
/^ *(eth|tap|bond|wlan|ath|ra|sw|eno|ens|enp|wlp|wl)[0-9]*/ {
83+
split($0, a, /: */);
84+
gsub(/^ +/,"",a[1]);
85+
if (($2 > 0) || ($10 > 0)) print a[1]; }' /proc/net/dev)"
86+
cake_ifs=()
87+
for if in $ifs; do
88+
qdisc="$(/sbin/tc -s qdisc show dev "$if" | head -n1 | awk '{ print $2 }')"
89+
if [ "$qdisc" == "cake" ]; then
90+
cake_ifs+=("$if")
91+
fi
92+
done
93+
echo "$cake_ifs"
94+
fi
95+
exit 0
96+
;;
97+
config)
98+
99+
echo "graph_title $DEVICE cake QoS tin stats"
100+
echo 'graph_args --base 1000'
101+
echo 'graph_vlabel packets per second'
102+
echo 'graph_category network'
103+
echo "graph_info This graph shows the packages per tin of egress traffic of the $DEVICE network interface."
104+
105+
diffserv_no="$(tc_cake_get_diffserv)"
106+
107+
if [ "$diffserv_no" == "3" ]; then
108+
109+
echo "bulk.label Bulk"
110+
echo "bulk.draw AREA"
111+
echo "bulk.type DERIVE"
112+
echo "bulk.min 0"
113+
echo "bulk.info sent bulk packets thru cake"
114+
115+
echo "besteffort.label Best Effort"
116+
echo "besteffort.draw STACK"
117+
echo "besteffort.type DERIVE"
118+
echo "besteffort.min 0"
119+
echo "besteffort.info sent best effort packets thru cake"
120+
121+
echo "voice.label Voice"
122+
echo "voice.draw STACK"
123+
echo "voice.type DERIVE"
124+
echo "voice.min 0"
125+
echo "voice.info sent Voice packets thru cake"
126+
127+
exit 0
128+
fi
129+
130+
if [ "$diffserv_no" == "4" ]; then
131+
132+
echo "bulk.label Bulk"
133+
echo "bulk.draw AREA"
134+
echo "bulk.type DERIVE"
135+
echo "bulk.min 0"
136+
echo "bulk.info sent bulk packets thru cake"
137+
138+
echo "besteffort.label Best Effort"
139+
echo "besteffort.draw STACK"
140+
echo "besteffort.type DERIVE"
141+
echo "besteffort.min 0"
142+
echo "besteffort.info sent best effort packets thru cake"
143+
144+
echo "video.label Video"
145+
echo "video.draw STACK"
146+
echo "video.type DERIVE"
147+
echo "video.min 0"
148+
echo "video.info sent Video packets thru cake"
149+
150+
echo "voice.label Voice"
151+
echo "voice.draw STACK"
152+
echo "voice.type DERIVE"
153+
echo "voice.min 0"
154+
echo "voice.info sent Voice packets thru cake"
155+
156+
exit 0
157+
fi
158+
159+
if [ "$diffserv_no" == "8" ]; then
160+
161+
echo "tin1.label Tin 1"
162+
echo "tin1.draw AREA"
163+
echo "tin1.type DERIVE"
164+
echo "tin1.min 0"
165+
echo "tin1.info sent Tin 1 packets thru cake"
166+
167+
for i in `seq 2 8`; do
168+
echo "tin${i}.label Tin $i"
169+
echo "tin${i}.draw STACK"
170+
echo "tin${i}.type DERIVE"
171+
echo "tin${i}.min 0"
172+
echo "tin${i}.info sent Tin $i packets thru cake"
173+
done
174+
175+
exit 0
176+
fi
177+
178+
echo "cake_tin: no diffserv set (besteffort?)" >&2
179+
echo 1
180+
181+
;;
182+
esac
183+
184+
185+
diffserv_no="$(tc_cake_get_diffserv)"
186+
187+
if [ "$diffserv_no" == "3" ]; then
188+
/sbin/tc -s qdisc show dev "$DEVICE" | grep "^ pkts" | awk '{
189+
print "bulk.value " $2
190+
print "besteffort.value " $3
191+
print "voice.value " $4
192+
}'
193+
exit 0
194+
fi
195+
if [ "$diffserv_no" == "4" ]; then
196+
/sbin/tc -s qdisc show dev "$DEVICE" | grep "^ pkts" | awk '{
197+
print "bulk.value " $2
198+
print "besteffort.value " $3
199+
print "video.value " $4
200+
print "voice.value " $5
201+
}'
202+
exit 0
203+
fi
204+
if [ "$diffserv_no" == "8" ]; then
205+
/sbin/tc -s qdisc show dev "$DEVICE" | grep "^ pkts" | awk '{
206+
print "tin1.value " $2
207+
print "tin2.value " $3
208+
print "tin3.value " $4
209+
print "tin4.value " $5
210+
print "tin5.value " $6
211+
print "tin6.value " $7
212+
print "tin7.value " $8
213+
print "tin8.value " $9
214+
}'
215+
exit 0
216+
fi
217+
218+
219+
exit 1
220+
221+
222+
223+
224+
225+

0 commit comments

Comments
 (0)