Révision 51e91e93
Plugin minecraft-users-ram_: more quoting, simpler output
| plugins/minecraft/minecraft-users-ram_ | ||
|---|---|---|
| 37 | 37 |
|
| 38 | 38 |
if [ "$1" = "config" ] |
| 39 | 39 |
then |
| 40 |
printf 'graph_title Minecraft-Server (Port %s)\n' ${MC_PORT}
|
|
| 41 |
printf 'graph_category games'
|
|
| 42 |
printf 'graph_scale no\n'
|
|
| 43 |
printf 'graph_vlabel Players / RAM / CPU\n'
|
|
| 44 |
printf 'users.label Players\n'
|
|
| 45 |
printf 'ramusage.label RAM usage in GiB\n'
|
|
| 46 |
printf 'cpuusage.label CPU usage\n'
|
|
| 40 |
echo "graph_title Minecraft-Server (Port $MC_PORT)"
|
|
| 41 |
echo 'graph_category games'
|
|
| 42 |
echo 'graph_scale no'
|
|
| 43 |
echo 'graph_vlabel Players / RAM / CPU'
|
|
| 44 |
echo 'users.label Players'
|
|
| 45 |
echo 'ramusage.label RAM usage in GiB'
|
|
| 46 |
echo 'cpuusage.label CPU usage'
|
|
| 47 | 47 |
exit 0 |
| 48 | 48 |
fi |
| 49 | 49 |
|
| 50 |
PLAYERCOUNT=$(netstat -tn | grep -i ${MC_PORT} | grep ESTABLISHED | wc -l)
|
|
| 51 |
MC_PID=$(netstat -tlpn | grep ${MC_PORT} | sed -n -e '1p' | awk '{ print $7 }' | cut -d'/' -f1)
|
|
| 50 |
PLAYERCOUNT=$(netstat -tn | grep -i "$MC_PORT" | grep ESTABLISHED | wc -l)
|
|
| 51 |
MC_PID=$(netstat -tlpn | grep "$MC_PORT" | sed -n -e '1p' | awk '{ print $7 }' | cut -d '/' -f1)
|
|
| 52 | 52 |
if [ ! -z "${MC_PID}" ]
|
| 53 | 53 |
then #is running |
| 54 |
MEMORYRSS=$(ps -p ${MC_PID} -o rss | cut -d'
|
|
| 55 |
' -f2) |
|
| 54 |
MEMORYRSS=$(ps -p "$MC_PID" -o rss | cut -d '\n' -f2) |
|
| 56 | 55 |
MEMGiB=$(echo "scale=2;${MEMORYRSS}/1024/1024" | bc -l)
|
| 57 |
CPUPERCENT=$(top -bp ${MC_PID} -n 1 | sed -n '$p' | tr -s ' ' | cut -d ' ' -f10)
|
|
| 56 |
CPUPERCENT=$(top -bp "$MC_PID" -n 1 | sed -n '$p' | tr -s ' ' | cut -d ' ' -f10)
|
|
| 58 | 57 |
CPU=$(echo "scale=2;${CPUPERCENT}/100" | bc -l)
|
| 59 | 58 |
else |
| 60 | 59 |
MEMGiB=0 |
Formats disponibles : Unified diff