1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Added rough CPU usage reading

Also translated strings to english
This commit is contained in:
Leandro Späth 2016-06-27 02:41:34 +02:00 committed by Lars Kruse
parent 7a37bfb1d8
commit 353c0fc063

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# I'm not the author, just wanted to add this plugin to github # I'm not the author, just wanted to add this plugin to github
# Author & instructions: http://wiki.natenom.name/minecraft/munin-plugin # Author & instructions: http://wiki.natenom.name/minecraft/munin-plugin
# CPU usage update and translation by Leandro Späth (https://github.com/LeoDJ)
LC_LANG=C LC_LANG=C
MC_PORT=${0##*_} MC_PORT=${0##*_}
@ -9,9 +10,11 @@ if [ "$1" = "config" ]
then then
printf 'graph_title Minecraft-Server (Port %s)\n' ${MC_PORT} printf 'graph_title Minecraft-Server (Port %s)\n' ${MC_PORT}
printf 'graph_category games' printf 'graph_category games'
printf 'graph_vlabel Anzahl\n' printf 'graph_scale no\n'
printf 'users.label Benutzer\n' printf 'graph_vlabel Players / RAM / CPU\n'
printf 'ramusage.label Verwendeter RAM in GiB\n' printf 'users.label Players\n'
printf 'ramusage.label RAM usage in GiB\n'
printf 'cpuusage.label CPU usage\n'
exit 0 exit 0
fi fi
@ -22,9 +25,13 @@ then #is running
MEMORYRSS=$(ps -p ${MC_PID} -o rss | cut -d' MEMORYRSS=$(ps -p ${MC_PID} -o rss | cut -d'
' -f2) ' -f2)
MEMGiB=$(echo "scale=2;${MEMORYRSS}/1024/1024" | bc -l) MEMGiB=$(echo "scale=2;${MEMORYRSS}/1024/1024" | bc -l)
CPUPERCENT=$(ps -p ${MC_PID} -o %cpu | sed -n 2p)
CPU=$(echo "scale=2;${CPUPERCENT}/100" | bc -l)
else else
MEMGiB=0 MEMGiB=0
CPU=0
fi fi
printf "users.value %i\n" "${PLAYERCOUNT}" printf "users.value %i\n" "${PLAYERCOUNT}"
printf "ramusage.value %3.2f\n" "${MEMGiB}" printf "ramusage.value %3.2f\n" "${MEMGiB}"
printf "cpuusage.value %3.2f\n" "${CPU}"