Skip to content

Commit 63f8552

Browse files
Sebastian Lsumpfralle
Sebastian L
authored andcommitted
quake/qstat: enhancements
- dash - bots - configurable binary
1 parent adcc2f5 commit 63f8552

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

plugins/quake/qstat

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/ksh
1+
#!/bin/sh
22
#################################################################
33
# Title : Qstat plugin for Munin #
44
# Author : Benjamin DUPUIS - Poil #
@@ -9,7 +9,7 @@
99
#################################################################
1010
# Variable : #
1111
#---------------------------------------------------------------#
12-
qstat_exe='/usr/local/bin/qstat'
12+
qstat_exe="${qstat_exe:-/usr/local/bin/qstat}"
1313

1414
#---------------------------------------------------------------#
1515
# End of config
@@ -23,7 +23,7 @@ usage() {
2323
echo 'For testing the script, run qstat_ GameType IP Port'
2424
echo ' - GameType : q3s, q4s ... run qstat for seeing available gametype'
2525
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};
26+
echo 'Perhaps you must have to set qstat_exe path, actually on' "${qstat_exe}";
2727
echo 'Have Fun'
2828
}
2929

@@ -40,16 +40,17 @@ config() {
4040

4141
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
4242
graph_vlabel players
43-
graph_args --base 1000 -r --lower-limit 0 --upper-limit 16
43+
graph_args --base 1000 -r --lower-limit 0
4444
graph_category games
4545
maxplayer.label max players
46+
bot.label bots
4647
player.label players"
4748
}
4849

4950
#################################################################
5051
# Quake Stat, call qstat #
5152
#---------------------------------------------------------------#
52-
quake_stat() {
53+
qstat_run() {
5354
if [ "${script_name}" != "qstat_" ]; then
5455
gametype=$(echo "$script_name" | cut -d_ -f2)
5556
ip=$(echo "$script_name" | cut -d_ -f3)
@@ -61,24 +62,33 @@ quake_stat() {
6162
fi
6263

6364
if [ -n "$gametype" ] && [ -n "$gametype" ] && [ -n "$gametype" ]; then
64-
dummy=$("$qstat_exe" -raw ";" -nh "-$gametype" "${ip}:${port}")
65+
rawstats=$("$qstat_exe" -raw ";" -nh "-$gametype" "${ip}:${port}")
6566

66-
playervalue=$(echo "$dummy" | cut -d\; -f6)
67-
maxplayervalue=$(echo "$dummy" | cut -d\; -f5)
67+
playervalue=$(echo "$rawstats" | cut -d\; -f6)
68+
maxplayervalue=$(echo "$rawstats" | cut -d\; -f5)
69+
70+
# Assume that bots have a ping time of 0 miliseconds
71+
botvalue=$("$qstat_exe" -P -pa -sort P "-$gametype" "${ip}:${port}" | grep -c 0ms)
6872

6973
if [ -z "${playervalue}" ]; then
7074
playervalue=0
7175
fi
7276

77+
if [ -z "${botvalue}" ]; then
78+
botvalue=0
79+
fi
80+
7381
if [ -z "${maxplayervalue}" ]; then
7482
maxplayervalue=0
7583
fi
7684

7785

7886
echo "maxplayer.value "${maxplayervalue};
87+
echo "bot.value "${botvalue};
7988
echo "player.value "${playervalue};
8089
else
8190
echo "maxplayer.value U"
91+
echo "bot.value U"
8292
echo "player.value U"
8393
fi
8494
}
@@ -99,7 +109,7 @@ case $1 in
99109
echo "no (edit the script for set qstat path)"
100110
;;
101111
*)
102-
quake_stat "$@"
112+
qstat_run "$@"
103113
exit 0
104114
;;
105115
esac

0 commit comments

Comments
 (0)