Skip to content

Commit

Permalink
Plugin cpu: add support for hiding selected fields
Browse files Browse the repository at this point in the history
Specifying "env.ignore_fields idle" may improve the visualization of the
busy cpu usage.

See #1338

Suggested by 22decembre, thanks!
  • Loading branch information
sumpfralle committed Jul 1, 2020
1 parent ded3361 commit 4820373
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions plugins/node.d.linux/cpu.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ All Linux systems
The following is default configuration

[cpu]
env.HZ 100
env.scaleto100 no
env.HZ 100
env.scaleto100 no

"scaleto100" may be "yes" or "no". With "yes" all CPU-related values
are scaled for a limit of 100. With "no" (the default) all CPU-related
values are scaled for a limit of n * 100 ("n" being the number of CPUs).

The "ignore_fields" environment variable (empty by default) may be used
for listing fields (space separated) that should not be visualized.
For example hiding the "idle" field may improve the visualization of the
combined cpu usage.

See "BUGS" for an explanation of the "HZ" setting.

=head2 EXAMPLE WARNING AND CRITICAL SETTINGS
Expand Down Expand Up @@ -113,6 +118,16 @@ fi

HZ=${HZ:-100}
scaleto100=${scaleto100:-no}
ignore_fields=${ignore_fields:-}


maybe_hide_field() {
local fieldname="$1"
if echo "$ignore_fields" | grep -wq "$fieldname"; then
echo "$fieldname.graph no"
fi
}


extinfo=""

Expand Down Expand Up @@ -166,6 +181,7 @@ if [ "$1" = "config" ]; then

for field in system user nice idle; do
print_adjusted_thresholds "$field" "$graphlimit"
maybe_hide_field "$field"
done

if [ "$scaleto100" = "yes" ]; then
Expand Down Expand Up @@ -198,6 +214,7 @@ if [ "$1" = "config" ]; then
fi
for field in iowait irq softirq; do
print_adjusted_thresholds "$field" "$graphlimit"
maybe_hide_field "$field"
done
fi

Expand All @@ -208,6 +225,7 @@ if [ "$1" = "config" ]; then
echo 'steal.min 0'
echo 'steal.type DERIVE'
echo 'steal.info The time that a virtual CPU had runnable tasks, but the virtual CPU itself was not running'
maybe_hide_field "steal"
if [ "$scaleto100" = "yes" ]; then
echo "steal.cdef steal,$NCPU,/"
fi
Expand All @@ -221,6 +239,7 @@ if [ "$1" = "config" ]; then
echo 'guest.min 0'
echo 'guest.type DERIVE'
echo 'guest.info The time spent running a virtual CPU for guest operating systems under the control of the Linux kernel.'
maybe_hide_field "guest"
if [ "$scaleto100" = "yes" ]; then
echo "guest.cdef guest,$NCPU,/"
fi
Expand Down

0 comments on commit 4820373

Please sign in to comment.