-
-
Save mkubenka/10852099 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# -*- sh -*- | |
: << =cut | |
=head1 NAME | |
zram - Plugin to monitor zram usage | |
=head1 CONFIGURATION | |
No configuration | |
=head1 AUTHOR | |
Unknown author | |
=head1 LICENSE | |
GPLv2 | |
=head1 MAGIC MARKERS | |
#%# family=auto | |
#%# capabilities=autoconf | |
=cut | |
. $MUNIN_LIBDIR/plugins/plugin.sh | |
if [ "$1" = "autoconf" ]; then | |
if [ -r /sys/block/zram0 ]; then | |
echo yes | |
exit 0 | |
else | |
echo "no (no zram device)" | |
exit 0 | |
fi | |
fi | |
if [ "$1" = "config" ]; then | |
echo 'multigraph zram_usage' | |
echo 'graph_title zram usage' | |
echo 'graph_vlabel bytes' | |
echo 'graph_category zram' | |
echo 'disksize.label size' | |
echo 'used.label used' | |
echo 'compressed.label compressed' | |
echo 'memory_used.label memory_used' | |
echo 'graph_args --base 1024' | |
echo | |
echo 'multigraph zram_efficiency' | |
echo 'graph_title zram efficiency' | |
echo "graph_args -r --lower-limit 0 --upper-limit 100" | |
echo 'graph_vlabel compression efficiency' | |
echo 'graph_category zram' | |
echo 'efficiency.label efficiency %' | |
exit 0 | |
fi | |
# Zram Location | |
ZL="/sys/block/zram*" | |
used=$(cat $ZL/orig_data_size | awk '{s+=$1} END {print s}') | |
memory_used=$(cat $ZL/mem_used_total | awk '{s+=$1} END {print s}') | |
disksize=$(cat $ZL/disksize | awk '{s+=$1} END {print s}') | |
compressed=$(cat $ZL/compr_data_size | awk '{s+=$1} END {print s}') | |
efficiency=$(echo "scale=2; 100 - $memory_used * 100 / $used" | bc -l) | |
echo 'multigraph zram_usage' | |
echo "disksize.value $disksize" | |
echo "used.value $used" | |
echo "compressed.value $compressed" | |
echo "memory_used.value $memory_used" | |
echo | |
echo "multigraph zram_efficiency" | |
echo "efficiency.value $efficiency" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment