Révision adcf3c09
Initial version
| plugins/other/qstatqw_ | ||
|---|---|---|
| 1 |
#!/bin/ksh |
|
| 2 |
################################################################# |
|
| 3 |
# Title : Qstat plugin for Munin # |
|
| 4 |
# Author : Benjamin DUPUIS - Poil # |
|
| 5 |
# Email : poil@quake.fr # |
|
| 6 |
# First release : 18/10/2007 # |
|
| 7 |
#---------------------------------------------------------------# |
|
| 8 |
|
|
| 9 |
################################################################# |
|
| 10 |
# Variable : # |
|
| 11 |
#---------------------------------------------------------------# |
|
| 12 |
qstat_exe='/usr/bin/qstat' |
|
| 13 |
|
|
| 14 |
#---------------------------------------------------------------# |
|
| 15 |
# End of config |
|
| 16 |
script_name=$(basename $0) |
|
| 17 |
################################################################# |
|
| 18 |
|
|
| 19 |
################################################################# |
|
| 20 |
# Help # |
|
| 21 |
#---------------------------------------------------------------# |
|
| 22 |
usage() {
|
|
| 23 |
echo 'For testing the script, run qstat_ GameType IP Port' |
|
| 24 |
echo ' - GameType : q3s, q4s ... run qstat for seeing available gametype' |
|
| 25 |
echo 'For munin you must ln -s /usr/share/munin/plugins/qstat_ /etc/munin/plugins/qstat_GameType_IP2test_Port' |
|
| 26 |
echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe};
|
|
| 27 |
echo 'Have Fun' |
|
| 28 |
} |
|
| 29 |
|
|
| 30 |
config() {
|
|
| 31 |
if [ "${script_name}" != "qstat_" ]; then
|
|
| 32 |
gametype=$(echo ${script_name} | cut -d_ -f2)
|
|
| 33 |
ip=$(echo ${script_name} | cut -d_ -f3)
|
|
| 34 |
port=$(echo ${script_name} | cut -d_ -f4)
|
|
| 35 |
else |
|
| 36 |
gametype=$1 |
|
| 37 |
ip=$2 |
|
| 38 |
port=$3 |
|
| 39 |
fi |
|
| 40 |
|
|
| 41 |
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
|
|
| 42 |
graph_vlabel players |
|
| 43 |
#graph_args --base 1000 -r --lower-limit 0 --upper-limit 64 |
|
| 44 |
graph_category games |
|
| 45 |
maxplayer.label bots |
|
| 46 |
player.label players" |
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
################################################################# |
|
| 50 |
# Quake Stat, call qstat # |
|
| 51 |
#---------------------------------------------------------------# |
|
| 52 |
quake_stat() {
|
|
| 53 |
if [ "${script_name}" != "qstat_" ]; then
|
|
| 54 |
gametype=$(echo ${script_name} | cut -d_ -f2)
|
|
| 55 |
ip=$(echo ${script_name} | cut -d_ -f3)
|
|
| 56 |
port=$(echo ${script_name} | cut -d_ -f4)
|
|
| 57 |
else |
|
| 58 |
gametype=$1 |
|
| 59 |
ip=$2 |
|
| 60 |
port=$3 |
|
| 61 |
fi |
|
| 62 |
|
|
| 63 |
if [ ! -z ${gametype} ] && [ ! -z ${gametype} ] && [ ! -z ${gametype} ]; then
|
|
| 64 |
dummy=$(${qstat_exe} -P -pa -sort P -${gametype} ${ip}:${port} | grep team | grep -wv 0ms | wc -l)
|
|
| 65 |
dummy2=$(${qstat_exe} -P -pa -sort P -${gametype} ${ip}:${port} | grep team | grep -w 0ms | wc -l)
|
|
| 66 |
playervalue=$dummy |
|
| 67 |
maxplayervalue=$dummy2 |
|
| 68 |
|
|
| 69 |
if [ -z "${playervalue}" ]; then
|
|
| 70 |
playervalue=0 |
|
| 71 |
fi |
|
| 72 |
|
|
| 73 |
if [ -z "${maxplayervalue}" ]; then
|
|
| 74 |
maxplayervalue=0 |
|
| 75 |
fi |
|
| 76 |
|
|
| 77 |
|
|
| 78 |
echo "maxplayer.value "${maxplayervalue};
|
|
| 79 |
echo "player.value "${playervalue};
|
|
| 80 |
else |
|
| 81 |
echo "maxplayer.value U" |
|
| 82 |
echo "player.value U" |
|
| 83 |
fi |
|
| 84 |
} |
|
| 85 |
|
|
| 86 |
################################################################# |
|
| 87 |
# Main # |
|
| 88 |
#---------------------------------------------------------------# |
|
| 89 |
case $1 in |
|
| 90 |
config) |
|
| 91 |
config |
|
| 92 |
exit 0 |
|
| 93 |
;; |
|
| 94 |
help | ?) |
|
| 95 |
usage |
|
| 96 |
exit 0 |
|
| 97 |
;; |
|
| 98 |
autoconf) |
|
| 99 |
echo "no (edit the script for set qstat path)" |
|
| 100 |
;; |
|
| 101 |
*) |
|
| 102 |
quake_stat $1 $2 $3 |
|
| 103 |
exit 0 |
|
| 104 |
;; |
|
| 105 |
esac |
|
| 106 |
|
|
Formats disponibles : Unified diff