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

106 lines
3.0 KiB
Plaintext
Raw Permalink Normal View History

2008-06-28 15:21:59 +02:00
#!/bin/ksh
#################################################################
# Title : Qstat plugin for Munin #
# Author : Benjamin DUPUIS - Poil #
# Email : poil@quake.fr #
# First release : 18/10/2007 #
#---------------------------------------------------------------#
#################################################################
# Variable : #
#---------------------------------------------------------------#
qstat_exe='/usr/bin/qstat'
#---------------------------------------------------------------#
# End of config
2018-03-09 05:25:13 +01:00
script_name=$(basename "$0")
2008-06-28 15:21:59 +02:00
#################################################################
#################################################################
# Help #
#---------------------------------------------------------------#
usage() {
echo 'For testing the script, run qstat_ GameType IP Port'
echo ' - GameType : q3s, q4s ... run qstat for seeing available gametype'
echo 'For munin you must ln -s /usr/share/munin/plugins/qstat_ /etc/munin/plugins/qstat_GameType_IP2test_Port'
echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe};
echo 'Have Fun'
}
config() {
if [ "${script_name}" != "qstat_" ]; then
2018-03-09 05:25:13 +01:00
gametype=$(echo "$script_name" | cut -d_ -f2)
ip=$(echo "$script_name" | cut -d_ -f3)
port=$(echo "$script_name" | cut -d_ -f4)
2008-06-28 15:21:59 +02:00
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 64
graph_category games
maxplayer.label bots
player.label players"
}
#################################################################
# Quake Stat, call qstat #
#---------------------------------------------------------------#
quake_stat() {
if [ "${script_name}" != "qstat_" ]; then
2018-03-09 05:25:13 +01:00
gametype=$(echo "$script_name" | cut -d_ -f2)
ip=$(echo "$script_name" | cut -d_ -f3)
port=$(echo "$script_name" | cut -d_ -f4)
2008-06-28 15:21:59 +02:00
else
gametype=$1
ip=$2
port=$3
fi
2018-03-09 05:25:13 +01:00
if [ ! -z "$gametype" ] && [ ! -z "$gametype" ] && [ ! -z "$gametype" ]; then
stat_output=$("$qstat_exe" -P -pa -sort P "-$gametype" "${ip}:${port}" | grep frags)
playervalue=$(echo "$stat_output" | grep -cwv 0ms)
maxplayervalue=$(echo "$stat_output" | grep -cw 0ms)
2008-06-28 15:21:59 +02:00
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)
2018-03-09 05:25:13 +01:00
config "$@"
2008-06-28 15:21:59 +02:00
exit 0
;;
help | ?)
usage
exit 0
;;
autoconf)
echo "no (edit the script for set qstat path)"
;;
*)
2018-03-09 05:25:13 +01:00
quake_stat "$@"
2008-06-28 15:21:59 +02:00
exit 0
;;
esac