2009-01-12 01:50:13 +01:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
#################################################################
|
|
|
|
|
# Title : Qstat plugin for Munin #
|
2018-08-01 23:04:43 +02:00
|
|
|
|
# Author : Benjamin DUPUIS - Poil #
|
|
|
|
|
# Email : poil@quake.fr #
|
|
|
|
|
# First release : 18/10/2007 #
|
2009-01-12 01:50:13 +01:00
|
|
|
|
#---------------------------------------------------------------#
|
2018-08-01 23:04:43 +02: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
|
|
|
|
#---------------------------------------------------------------#
|
|
|
|
|
#################################################################
|
2018-08-01 23:04:43 +02:00
|
|
|
|
# Variable : #
|
2009-01-12 01:50:13 +01:00
|
|
|
|
#---------------------------------------------------------------#
|
2018-08-01 23:04:43 +02:00
|
|
|
|
# Set path to QSTAT #
|
|
|
|
|
qstat_exe='/usr/local/bin/qstat' #
|
2009-01-12 01:50:13 +01:00
|
|
|
|
#---------------------------------------------------------------#
|
|
|
|
|
# End of config
|
2018-08-01 23:04:43 +02:00
|
|
|
|
script_name=$(basename "$0")
|
2009-01-12 01:50:13 +01:00
|
|
|
|
#################################################################
|
|
|
|
|
|
|
|
|
|
#################################################################
|
2018-08-01 23:04:43 +02:00
|
|
|
|
# Help #
|
2009-01-12 01:50:13 +01:00
|
|
|
|
#---------------------------------------------------------------#
|
|
|
|
|
usage() {
|
2018-08-01 23:04:43 +02:00
|
|
|
|
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() {
|
2018-08-01 23:04:43 +02:00
|
|
|
|
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
|
2018-08-01 23:04:43 +02:00
|
|
|
|
graph_category games
|
2009-01-12 01:50:13 +01:00
|
|
|
|
player.label players"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#################################################################
|
2018-08-01 23:04:43 +02:00
|
|
|
|
# Quake Stat, call qstat #
|
2009-01-12 01:50:13 +01:00
|
|
|
|
#---------------------------------------------------------------#
|
|
|
|
|
quake_stat() {
|
2018-08-01 23:04:43 +02:00
|
|
|
|
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
|
|
|
|
|
2018-08-01 23:04:43 +02: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
|
|
|
|
|
2018-08-01 23:04:43 +02: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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#################################################################
|
2018-08-01 23:04:43 +02:00
|
|
|
|
# Main #
|
2009-01-12 01:50:13 +01:00
|
|
|
|
#---------------------------------------------------------------#
|
|
|
|
|
case $1 in
|
2018-08-01 23:04:43 +02:00
|
|
|
|
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
|