Advertisement
Guest User

Minetest RAM usage munin plugin

a guest
Jan 8th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. #!/bin/bash
  2. #munin plugin for ram 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.     printf 'graph_title Minetestserver memory usage (Port %s)\n' ${MT_PORT}
  15.     printf 'graph_vlabel MiB\n'
  16.     printf 'ramusage.label memory usage\n'
  17.     printf 'graph_category minetest'
  18. #    printf 'graph_info Shows RAM usage by minetestserver process'
  19.     exit 0
  20. fi
  21.  
  22. MT_PID=$(netstat -ulpn 2>/dev/null | grep ${MT_PORT}  | sed -n -e '1p' | awk '{ print $6 }' | cut -d'/' -f1)
  23. if [ ! -z "${MT_PID}" ]
  24. then #is running
  25. #   MEMORYRSS=$(ps v ${MT_PID} | awk '{print $8}' | tail -n1)
  26.     MEMORYRSS=$(cat /proc/${MT_PID}/status | grep RSS | awk '{print $2}')
  27.     MEMMiB=$(echo "scale=2;${MEMORYRSS}/1024" | bc -l)
  28. else
  29.     MEMMiB=0
  30. fi
  31.  
  32. printf "ramusage.value %3.2f\n" "${MEMMiB}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement