Projet

Général

Profil

Révision 1977235f

ID1977235fd59768ae54516cb3b58f51be0b57e431
Parent 4612c1bc
Enfant b85c9aec

Ajouté par HaseHarald il y a presque 4 ans

[minecraft-users-ram] Fix several bugs in plugin minecraft-users-ram_

Fixes:
- Make playercount work on non english systems
- Avoid getting an invalid PID if not run with sufficient permissions
- Fix getting CPU usage

Enhance:
- Clearify that CPU usage is in percent

Voir les différences:

plugins/minecraft/minecraft-users-ram_
43 43
    echo 'graph_vlabel Players / RAM / CPU'
44 44
    echo 'users.label Players'
45 45
    echo 'ramusage.label RAM usage in GiB'
46
    echo 'cpuusage.label CPU usage'
46
    echo 'cpuusage.label CPU usage in %'
47 47
    exit 0
48 48
fi
49 49

  
50
PLAYERCOUNT=$(LC_LANG=C netstat -tn | grep ":$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=$(LANG=en LC_LANG=C netstat -tn | grep "\:$MC_PORT " | grep -c "ESTABLISHED")
51
MC_PID=$(netstat -tlpn | grep ":$MC_PORT " | sed -n -e '1p' | awk '{ print $7 }' | cut -d '/' -f1 | grep -v '-')
52 52
if [ -n "${MC_PID}" ]
53 53
then #is running
54 54
    MEMGiB=$(ps -p "$MC_PID" -o rss | sed -n '2p' | awk '{ print $1 / 1024 / 1024 }')
55
    CPU=$(top -bp "$MC_PID" -n 1 | sed -n '$p' | awk '{ print $10 / 100; }')
55
    CPU=$(ps -p "$MC_PID" -o pcpu | sed -n '2p' | awk '{ print $1 }')
56 56
else
57 57
    MEMGiB="U"
58 58
    CPU="U"

Formats disponibles : Unified diff