Advertisement
Guest User

Minetest CPU usage plugin for munin

a guest
Jan 8th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.19 KB | None | 0 0
  1.     #!/bin/bash
  2.     #munin plugin for cpu usage monitoring of minetestserver for given port
  3.     #author: Ritchie
  4.     #thanks Pitriss for advices
  5.     #inspired by plugin minecraft-users-ram_
  6.     #https://github.com/munin-monitoring/contrib/blob/master/plugins/minecraft/minecraft-users-ram_
  7.     #Author & instructions: http://wiki.natenom.name/minecraft/munin-plugin
  8.      
  9.     LC_LANG=C
  10.     MT_PORT=${0##*_}
  11.      
  12.     if [ "$1" = "config" ]
  13.     then
  14.         echo "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100"
  15.         echo "graph_title Minetestserver CPU usage (Port ${MT_PORT})"
  16.         echo "graph_category minetest"
  17.         echo "graph_info This graph shows CPU usage for minetestserver."
  18.         echo "graph_vlabel %"
  19.         echo "graph_scale no"
  20.         echo "graph_period second"
  21.         echo "cpuusage.label cpu usage"
  22.     exit 0
  23.     fi
  24.      
  25.     MT_PID=$(netstat -ulpn 2>/dev/null | grep ${MT_PORT}  | sed -n -e '1p' | awk '{ print $6 }' | cut -d'/' -f1)
  26.     if [ ! -z "${MT_PID}" ]
  27.     then #is running
  28.         CPUusage=$(ps aux | grep ${MT_PID} | grep -v grep | awk '{print $3}')
  29.     else
  30.      
  31.         CPUusage=0
  32.     fi
  33.      
  34.     printf "cpuusage.value %3.2f\n" "${CPUusage}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement