2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/quake/qstatcod4and5_

101 lines
3.8 KiB
Plaintext
Raw Permalink Normal View History

2009-01-12 01:50:13 +01:00
#!/bin/sh
#################################################################
# Title : Qstat plugin for Munin #
# Author : Benjamin DUPUIS - Poil #
# Email : poil@quake.fr #
# First release : 18/10/2007 #
2009-01-12 01:50:13 +01:00
#---------------------------------------------------------------#
# Edited: Rouven David Na<4E>l - peperoni #
# Edit : 09/01/2009 #
# Plugin edited for COD4+COD5 #
# Email: peperoni@sac-esports.de #
2009-01-12 01:50:13 +01:00
#---------------------------------------------------------------#
#################################################################
# Variable : #
2009-01-12 01:50:13 +01:00
#---------------------------------------------------------------#
# Set path to QSTAT #
qstat_exe='/usr/local/bin/qstat' #
2009-01-12 01:50:13 +01:00
#---------------------------------------------------------------#
# End of config
script_name=$(basename "$0")
2009-01-12 01:50:13 +01:00
#################################################################
#################################################################
# Help #
2009-01-12 01:50:13 +01:00
#---------------------------------------------------------------#
usage() {
echo 'For testing the script, run qstatcod4and5_ cods IP PORT'
echo ' - GameType : cods ... run qstat for seeing available gametype'
echo 'For munin you must ln -s /usr/share/munin/plugins/qstatcod4and5_ /etc/munin/plugins/cod4_cods_IP_PORT'
echo 'Example you will test this COD4 Server: 123.456.789.123:28960'
echo 'your symlink looks like this: ln -s /usr/share/munin/plugins/cod4server /etc/munin/plugins/cod4_cods_123.456.789.123_28960'
echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe};
echo 'Have Fun'
2009-01-12 01:50:13 +01:00
}
config() {
if [ "${script_name}" != "qstatcod4and5_" ]; then
gametype=$(echo "$script_name" | cut -d_ -f2)
ip=$(echo "$script_name" | cut -d_ -f3)
port=$(echo "$script_name" | cut -d_ -f4)
2009-01-12 01:50:13 +01:00
else
gametype=$1
ip=$2
port=$3
fi
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
graph_vlabel players
graph_category games
2009-01-12 01:50:13 +01:00
player.label players"
}
#################################################################
# Quake Stat, call qstat #
2009-01-12 01:50:13 +01:00
#---------------------------------------------------------------#
quake_stat() {
if [ "${script_name}" != "qstatcod4and5_" ]; 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
2009-01-12 01:50:13 +01:00
if [ ! -z "$gametype" ] && [ ! -z "$gametype" ] && [ ! -z "$gametype" ]; then
dummy=$("$qstat_exe" -P -pa -sort P "-$gametype" "${ip}:${port}" | grep frags | wc -l)
playervalue=$dummy
2009-01-12 01:50:13 +01:00
if [ -z "$playervalue" ]; then
playervalue=0
fi
echo "player.value $playervalue"
else
echo "player.value U"
fi
2009-01-12 01:50:13 +01:00
}
#################################################################
# Main #
2009-01-12 01:50:13 +01:00
#---------------------------------------------------------------#
case $1 in
config)
config "$1" "$2" "$3"
exit 0
;;
help | ?)
usage
exit 0
;;
autoconf)
echo "no (edit the script for set qstat path)"
;;
*)
quake_stat "$1" "$2" "$3"
exit 0
;;
2009-01-12 01:50:13 +01:00
esac