-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] cake plugins #941
Open
RubenKelevra
wants to merge
29
commits into
munin-monitoring:master
Choose a base branch
from
RubenKelevra:cake_plugins
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[WIP] cake plugins #941
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
052a824
cake: add two simple plugins
467720a
rename cake.cake_tin_ cake.cake_tin_throughput_
f202a4d
mv cake.cake_tin_throughput_ to cake.cake_tin_pps_; optimizing
507d7f1
cake: add cake_tin_delay_ plugin
dd3f63f
cake: add cake_tin_ecn_ plugin
12c4695
cake: fix description of cake_tin_pps_'s graph
af12747
switch vom ms to seconds, to avoid values like 10m ms
d7f9176
change scientific numbers to ordinary floats; add ns range
5d31b60
cake_tin_delay_ optimize headline
8e2aac4
cake_tin_ecn_ optimize headline
a7bd7e3
cake_ optimize headline
e336264
cake: add plugin cake_tin_throughput_
afb969f
cake: update all plugins to add automatic ingress-device detection
b0c1e96
cake: fix errounous graphs in cake_tin_throughput_
491bfc1
cake: add a hint, that backlog in cake.cake_ is not pps but absolute
5e74931
cake: error message fix
86df21b
remove unnecessary end line delimiter
d95aa75
cake: chmod 775
455effd
cake: add static colors
749d302
cake: shellcheck
34d81f7
cake: fix bug on suggest function returning just one devices
234db28
cake: whitespace fixing
fc8ca5b
cake: add error-message to non-supported cake-configs (best effort) f…
7540eb3
cake: change cake_tin_pps_ to logarithmic scale
00888cd
cake: cake.cake_ swap behavoir
6760871
cake: add double quotation marks on integers arithmetics by request
8cc759a
fix shellcheck commit
0ea29f8
cake: remove logarithmic scale, since it cannot be used with negative…
b75fa5c
cake: suggest was just returning one dev, fixing
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
#!/bin/bash | ||
# -*- sh -*- | ||
|
||
: << =cut | ||
|
||
=pod | ||
|
||
=encoding UTF-8 | ||
|
||
=head1 NAME | ||
|
||
cake_ - Plugin to monitor cake's backlog, dropped, overlimits and requeues | ||
|
||
=head1 CONFIGURATION | ||
|
||
None needed. | ||
|
||
=head1 INTERPRETATION | ||
|
||
Cake, also known as sch_cake is a modern bandwidth limiter, which eliminates | ||
buffer bloat over slow links. It's also capable to give flows, hosts and each | ||
flow of each host a fair part of the avaible bandwidth. | ||
|
||
This plugin allows for a monitor of the pressure on the qdisc, by monitoring key | ||
values. | ||
|
||
=head1 SEE ALSO | ||
|
||
Take a look at "man cake" to get more information about cake. | ||
|
||
=head1 MAGIC MARKERS | ||
|
||
#%# family=auto | ||
#%# capabilities=autoconf suggest | ||
|
||
=head1 AUTHORS | ||
|
||
RubenKelevra <[email protected]> | ||
|
||
work based on the tc plugin, authors: | ||
Steve Schnepp <[email protected]>, | ||
Samuel Smith <[email protected]>, | ||
Nye Liu <[email protected]> | ||
|
||
=head1 LICENSE | ||
|
||
GPLv2 or later | ||
|
||
=cut | ||
|
||
DEVICE="${0##*/cake_}" | ||
|
||
tc_get_ifb_dev() { | ||
dev="$(/sbin/tc filter show dev "$DEVICE" parent ffff: protocol all | grep "mirred" | grep "Egress Redirect to device")" | ||
[ "$?" -eq "1" ] && return 1 | ||
|
||
echo "$dev" | sed -n 's/.* device \([^ ]*\).*/\1/p' | tr ')' ' ' | awk '{ print $1 }' | ||
} | ||
|
||
tc_cake_sent() { | ||
/sbin/tc -s qdisc show dev "$1" | grep -E "^ Sent" | tr ',' ' ' | tr ')' ' ' | ||
} | ||
tc_cake_backlog() { | ||
/sbin/tc -s qdisc show dev "$1" | grep -E "^ backlog" | tr 'p' ' ' | ||
} | ||
|
||
DEVICE_IN="$(tc_get_ifb_dev)" | ||
has_if_in=$? | ||
|
||
case "$1" in | ||
autoconf) | ||
if [ -r /proc/net/dev ]; then | ||
echo yes | ||
exit 0 | ||
else | ||
echo "no (/proc/net/dev not found)" | ||
exit 1 | ||
fi | ||
;; | ||
suggest) | ||
if [ -r /proc/net/dev ]; then | ||
ifs="$(awk ' | ||
/^ *(eth|tap|bond|wlan|ath|ra|sw|eno|ens|enp|wlp|wl)[0-9]*/ { | ||
split($0, a, /: */); | ||
gsub(/^ +/,"",a[1]); | ||
if (($2 > 0) || ($10 > 0)) print a[1]; }' /proc/net/dev)" | ||
cake_ifs=() | ||
for if in $ifs; do | ||
qdisc="$(/sbin/tc -s qdisc show dev "$if" | head -n1 | awk '{ print $2 }')" | ||
if [ "$qdisc" == "cake" ]; then | ||
cake_ifs+=("$if") | ||
fi | ||
done | ||
echo "${cake_ifs[@]}" | ||
fi | ||
exit 0 | ||
;; | ||
config) | ||
|
||
if [ "$has_if_in" -eq "0" ]; then | ||
echo "graph_title $DEVICE ($DEVICE_IN) cake queuing" | ||
else | ||
echo "graph_title $DEVICE cake queuing" | ||
fi | ||
echo 'graph_args --base 1000' | ||
if [ "$has_if_in" -eq "0" ]; then | ||
echo 'graph_vlabel pps in (-) / out (+)' | ||
else | ||
echo 'graph_vlabel packets per second' | ||
fi | ||
echo 'graph_category network' | ||
if [ "$has_if_in" -eq "0" ]; then | ||
echo "graph_info This graph shows the general packet handling status of egress+ingress traffic of the $DEVICE ($DEVICE_IN) network interface." | ||
else | ||
echo "graph_info This graph shows the general packet handling status of egress traffic of the $DEVICE network interface." | ||
fi | ||
|
||
if [ "$has_if_in" -eq "0" ]; then | ||
echo "backlog_in.label backlog" | ||
echo "backlog_in.draw LINE2" | ||
echo "backlog_in.colour 85c4e0" | ||
echo "backlog_in.min 0" | ||
echo "backlog_in.info amount of packets currently buffered. This is an absolut value at the time the plugin is running, not an avg over the last 5 minutes (as all other values in this graph)" | ||
echo "backlog_in.graph no" | ||
fi | ||
echo "backlog.label backlog" | ||
echo "backlog.draw LINE2" | ||
echo "backlog.colour 85c4e0" | ||
echo "backlog.min 0" | ||
echo "backlog.info amount of packets currently buffered" | ||
[ "$has_if_in" -eq "0" ] && echo "backlog.negative backlog_in" | ||
|
||
if [ "$has_if_in" -eq "0" ]; then | ||
echo "dropped_in.label dropped" | ||
echo "dropped_in.draw AREA" | ||
echo "dropped_in.colour c77223" | ||
echo "dropped_in.type DERIVE" | ||
echo "dropped_in.min 0" | ||
echo "dropped_in.info dropped packets in queue" | ||
echo "dropped_in.graph no" | ||
fi | ||
echo "dropped.label dropped" | ||
echo "dropped.draw AREA" | ||
echo "dropped.colour c77223" | ||
echo "dropped.type DERIVE" | ||
echo "dropped.min 0" | ||
echo "dropped.info dropped packets in queue" | ||
[ "$has_if_in" -eq "0" ] && echo "dropped.negative dropped_in" | ||
|
||
if [ "$has_if_in" -eq "0" ]; then | ||
echo "overlimits_in.label overlimits" | ||
echo "overlimits_in.draw STACK" | ||
echo "overlimits_in.colour b6655c" | ||
echo "overlimits_in.type DERIVE" | ||
echo "overlimits_in.min 0" | ||
echo "overlimits_in.info packets exeeded a limit" | ||
echo "overlimits_in.graph no" | ||
fi | ||
echo "overlimits.label overlimits" | ||
echo "overlimits.draw STACK" | ||
echo "overlimits.colour b6655c" | ||
echo "overlimits.type DERIVE" | ||
echo "overlimits.min 0" | ||
echo "overlimits.info packets exeeded a limit" | ||
[ "$has_if_in" -eq "0" ] && echo "overlimits.negative overlimits_in" | ||
|
||
if [ "$has_if_in" -eq "0" ]; then | ||
echo "requeues_in.label requeues" | ||
echo "requeues_in.draw STACK" | ||
echo "requeues_in.colour 4e9e14" | ||
echo "requeues_in.type DERIVE" | ||
echo "requeues_in.min 0" | ||
echo "requeues_in.info packets requeued in queue" | ||
echo "requeues_in.graph no" | ||
fi | ||
echo "requeues.label requeues" | ||
echo "requeues.draw STACK" | ||
echo "requeues.colour 4e9e14" | ||
echo "requeues.type DERIVE" | ||
echo "requeues.min 0" | ||
echo "requeues.info packets requeued in queue" | ||
[ "$has_if_in" -eq "0" ] && echo "requeues.negative requeues_in" | ||
|
||
exit 0 | ||
;; | ||
esac | ||
|
||
tc_cake_sent "$DEVICE" | awk '{ | ||
print "dropped.value " $7 | ||
print "overlimits.value " $9 | ||
print "requeues.value " $11 | ||
}' | ||
|
||
tc_cake_backlog "$DEVICE" | awk '{ | ||
print "backlog.value " $3 | ||
}' | ||
|
||
if [ "$has_if_in" -eq "0" ]; then | ||
tc_cake_sent "$DEVICE_IN" | awk '{ | ||
print "dropped_in.value " $7 | ||
print "overlimits_in.value " $9 | ||
print "requeues_in.value " $11 | ||
}' | ||
|
||
tc_cake_backlog "$DEVICE_IN" | awk '{ | ||
print "backlog_in.value " $3 | ||
}' | ||
fi | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there really no specific test for the actual use of
cake
on the system?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in all cases. You could check if the sch_cake module is loaded, but if it's compiled as a built-in module that won't catch it. Also, the module can be loaded without being active.
The only sure way to see if cake is active is to do a
tc qdisc
and loop through all interfaces to try to find it. You could probably dotc -j qdisc
and construct a query with jq that will spit out all cake instances...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks!
But do we really want to get rid of the filter with packets received?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... I'll leave it the way it it. If you want to replace this function, feel free to suggest one which covers all features.
Also make sure to add a simple test, if jq is installed with an error-output for autoconf - for example it isn't installed on my system - never had the need for it - so an output about this dependency would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, what this means. How would you detect this situation? I would be happy to suggest a suitable filter.
Regarding the check of for
jq
- this is simply part of "autoconf", too:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the
if (($2 > 0) || ($10 > 0))
-part of line 26. This was part of the tc_ plugin. :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - I see.
Maybe we have different perceptions regarding the purpose of the "autoconf" test.
Here the plugin needs to answer two questions:
The "autoconf" call should return "yes" only if both questions are affirmed.
Your current implementation of "autoconf" only cares (partly) for the first question.
Additionally it should check two more details:
tc
available? (see my example forjq
above)The latter can probably be tested like this: