mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Initial version
This commit is contained in:
parent
6ddb169d59
commit
7a0da0b2cc
107
plugins/other/cstat
Executable file
107
plugins/other/cstat
Executable file
@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
#################################################################
|
||||
# Title : Cstat plugin for Munin #
|
||||
# Author : Benjamin DUPUIS - Poil #
|
||||
# Email : poil@quake.fr #
|
||||
# First release : 22/03/2011 #
|
||||
#---------------------------------------------------------------#
|
||||
|
||||
#################################################################
|
||||
# Variable : #
|
||||
#---------------------------------------------------------------#
|
||||
cstat_exe='/usr/local/bin/cstat'
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# End of config
|
||||
script_name=$(basename $0)
|
||||
#################################################################
|
||||
|
||||
#################################################################
|
||||
# Help #
|
||||
#---------------------------------------------------------------#
|
||||
usage() {
|
||||
echo 'For testing the script, run cstat_ GameType IP Port'
|
||||
echo ' - GameType : c2s, sbs, bfs ... run cstat for seeing available gametype'
|
||||
echo 'For munin you must ln -s /usr/share/munin/plugins/cstat_ /etc/munin/plugins/cstat_GameType_IP2test_Port'
|
||||
echo 'Perhaps you must have to set cstat_exe path, actually on'${cstat_exe};
|
||||
echo 'Have Fun'
|
||||
}
|
||||
|
||||
config() {
|
||||
if [ "${script_name}" != "cstat_" ]; then
|
||||
gametype=$(echo ${script_name} | cut -d_ -f2)
|
||||
ip=$(echo ${script_name} | cut -d_ -f3)
|
||||
port=$(echo ${script_name} | cut -d_ -f4)
|
||||
else
|
||||
gametype=$1
|
||||
ip=$2
|
||||
port=$3
|
||||
fi
|
||||
|
||||
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
|
||||
graph_vlabel players
|
||||
graph_args --base 1000 -r --lower-limit 0 --upper-limit 16
|
||||
graph_category games
|
||||
maxplayer.label max players
|
||||
player.label players
|
||||
maxplayer.critical 1:"
|
||||
|
||||
}
|
||||
|
||||
#################################################################
|
||||
# Cube Stat, call cstat #
|
||||
#---------------------------------------------------------------#
|
||||
cube_stat() {
|
||||
if [ "${script_name}" != "cstat_" ]; then
|
||||
gametype=$(echo ${script_name} | cut -d_ -f2)
|
||||
ip=$(echo ${script_name} | cut -d_ -f3)
|
||||
port=$(echo ${script_name} | cut -d_ -f4)
|
||||
else
|
||||
gametype=$1
|
||||
ip=$2
|
||||
port=$3
|
||||
fi
|
||||
|
||||
if [ ! -z ${gametype} ] && [ ! -z ${gametype} ] && [ ! -z ${gametype} ]; then
|
||||
dummy=$(${cstat_exe} --xml --${gametype} ${ip}:${port})
|
||||
playervalue=$(echo "${dummy}" | sed -n -e 's/.*<numplayers>\(.*\)<\/numplayers>.*/\1/p')
|
||||
maxplayervalue=$(echo "${dummy}" | sed -n -e 's/.*<maxplayers>\(.*\)<\/maxplayers>.*/\1/p')
|
||||
|
||||
if [ -z "${playervalue}" ]; then
|
||||
playervalue=0
|
||||
fi
|
||||
|
||||
if [ -z "${maxplayervalue}" ]; then
|
||||
maxplayervalue=0
|
||||
fi
|
||||
|
||||
|
||||
echo "maxplayer.value "${maxplayervalue};
|
||||
echo "player.value "${playervalue};
|
||||
else
|
||||
echo "maxplayer.value U"
|
||||
echo "player.value U"
|
||||
fi
|
||||
}
|
||||
|
||||
#################################################################
|
||||
# Main #
|
||||
#---------------------------------------------------------------#
|
||||
case $1 in
|
||||
config)
|
||||
config
|
||||
exit 0
|
||||
;;
|
||||
help | ?)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
autoconf)
|
||||
echo "no (edit the script for set cstat path)"
|
||||
;;
|
||||
*)
|
||||
cube_stat $1 $2 $3
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user