Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #munin plugin for cpu usage monitoring of minetestserver for given port
- #author: Ritchie
- #thanks Pitriss for advices
- #inspired by plugin minecraft-users-ram_
- #https://github.com/munin-monitoring/contrib/blob/master/plugins/minecraft/minecraft-users-ram_
- #Author & instructions: http://wiki.natenom.name/minecraft/munin-plugin
- LC_LANG=C
- MT_PORT=${0##*_}
- if [ "$1" = "config" ]
- then
- echo "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100"
- echo "graph_title Minetestserver CPU usage (Port ${MT_PORT})"
- echo "graph_category minetest"
- echo "graph_info This graph shows CPU usage for minetestserver."
- echo "graph_vlabel %"
- echo "graph_scale no"
- echo "graph_period second"
- echo "cpuusage.label cpu usage"
- exit 0
- fi
- MT_PID=$(netstat -ulpn 2>/dev/null | grep ${MT_PORT} | sed -n -e '1p' | awk '{ print $6 }' | cut -d'/' -f1)
- if [ ! -z "${MT_PID}" ]
- then #is running
- CPUusage=$(ps aux | grep ${MT_PID} | grep -v grep | awk '{print $3}')
- else
- CPUusage=0
- fi
- printf "cpuusage.value %3.2f\n" "${CPUusage}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement