1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 10:39:53 +00:00

Plugin minecraft-users-ram_: simplify calculation; do not reduce accuracy

This commit is contained in:
Lars Kruse 2018-07-11 19:25:57 +02:00
parent 51e91e9354
commit 94f46d392b

View file

@ -51,15 +51,13 @@ PLAYERCOUNT=$(netstat -tn | grep -i "$MC_PORT" | grep ESTABLISHED | wc -l)
MC_PID=$(netstat -tlpn | grep "$MC_PORT" | sed -n -e '1p' | awk '{ print $7 }' | cut -d '/' -f1) MC_PID=$(netstat -tlpn | grep "$MC_PORT" | sed -n -e '1p' | awk '{ print $7 }' | cut -d '/' -f1)
if [ ! -z "${MC_PID}" ] if [ ! -z "${MC_PID}" ]
then #is running then #is running
MEMORYRSS=$(ps -p "$MC_PID" -o rss | cut -d '\n' -f2) MEMGiB=$(ps -p "$MC_PID" -o rss | sed -n '2p' | awk '{ print $1 / 1024 / 1024 }')
MEMGiB=$(echo "scale=2;${MEMORYRSS}/1024/1024" | bc -l) CPU=$(top -bp "$MC_PID" -n 1 | sed -n '$p' | awk '{ print $10 / 100; }')
CPUPERCENT=$(top -bp "$MC_PID" -n 1 | sed -n '$p' | tr -s ' ' | cut -d ' ' -f10)
CPU=$(echo "scale=2;${CPUPERCENT}/100" | bc -l)
else else
MEMGiB=0 MEMGiB=0
CPU=0 CPU=0
fi fi
printf "users.value %i\n" "${PLAYERCOUNT}" echo "users.value $PLAYERCOUNT"
printf "ramusage.value %3.2f\n" "${MEMGiB}" echo "ramusage.value $MEMGiB"
printf "cpuusage.value %3.2f\n" "${CPU}" echo "cpuusage.value $CPU"