- Repository
- Munin (contrib)
- Last change
- 2021-12-09
- Graph Categories
- Family
- manual
- Capabilities
- Keywords
- Language
- Bash
- Authors
minecraft-users-ram_
Name
minecraft-users-ram_ - monitor resource usage of a local minecraft server
Applicable Systems
Every system with a running minecraft server.
Usage
Symlink this plugin to /etc/munin/plugins/ by adding the TCP port number used by the local mincecraft server. Afterwards restart the munin-node.
Some more instructions: http://wiki.natenom.name/minecraft/munin-plugin
Author
2011 Natenom
2017 Leandro Späth
Magic Markers
#%# family=manual
#%# capabilities=
#!/bin/bash
: <<=cut
=head1 NAME
minecraft-users-ram_ - monitor resource usage of a local minecraft server
=head1 APPLICABLE SYSTEMS
Every system with a running minecraft server.
=head1 USAGE
Symlink this plugin to /etc/munin/plugins/ by adding the TCP port number used
by the local mincecraft server. Afterwards restart the munin-node.
Some more instructions: http://wiki.natenom.name/minecraft/munin-plugin
=head1 AUTHOR
2011 Natenom
2017 Leandro Späth
=head1 MAGIC MARKERS
#%# family=manual
#%# capabilities=
=cut
MC_PORT=${0##*_}
if [ "$1" = "config" ]
then
echo "graph_title Minecraft-Server (Port $MC_PORT)"
echo 'graph_category games'
echo 'graph_scale no'
echo 'graph_vlabel Players / RAM / CPU'
echo 'users.label Players'
echo 'ramusage.label RAM usage in GiB'
echo 'cpuusage.label CPU usage in %'
exit 0
fi
PLAYERCOUNT=$(LANG=en LC_LANG=C netstat -tn | grep "\:$MC_PORT " | grep -c "ESTABLISHED")
MC_PID=$(netstat -tlpn | grep ":$MC_PORT " | sed -n -e '1p' | awk '{ print $7 }' | cut -d '/' -f1 | grep -v '-')
if [ -n "${MC_PID}" ]
then #is running
MEMGiB=$(ps -p "$MC_PID" -o rss | sed -n '2p' | awk '{ print $1 / 1024 / 1024 }')
CPU=$(ps -p "$MC_PID" -o pcpu | sed -n '2p' | awk '{ print $1 }')
else
MEMGiB="U"
CPU="U"
fi
echo "users.value $PLAYERCOUNT"
echo "ramusage.value $MEMGiB"
echo "cpuusage.value $CPU"