Révision 63f8552a
quake/qstat: enhancements
- dash
- bots
- configurable binary
| plugins/quake/qstat | ||
|---|---|---|
| 1 |
#!/bin/ksh
|
|
| 1 |
#!/bin/sh |
|
| 2 | 2 |
################################################################# |
| 3 | 3 |
# Title : Qstat plugin for Munin # |
| 4 | 4 |
# Author : Benjamin DUPUIS - Poil # |
| ... | ... | |
| 9 | 9 |
################################################################# |
| 10 | 10 |
# Variable : # |
| 11 | 11 |
#---------------------------------------------------------------# |
| 12 |
qstat_exe='/usr/local/bin/qstat'
|
|
| 12 |
qstat_exe="${qstat_exe:-/usr/local/bin/qstat}"
|
|
| 13 | 13 |
|
| 14 | 14 |
#---------------------------------------------------------------# |
| 15 | 15 |
# End of config |
| ... | ... | |
| 23 | 23 |
echo 'For testing the script, run qstat_ GameType IP Port' |
| 24 | 24 |
echo ' - GameType : q3s, q4s ... run qstat for seeing available gametype' |
| 25 | 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};
|
|
| 26 |
echo 'Perhaps you must have to set qstat_exe path, actually on' "${qstat_exe}";
|
|
| 27 | 27 |
echo 'Have Fun' |
| 28 | 28 |
} |
| 29 | 29 |
|
| ... | ... | |
| 40 | 40 |
|
| 41 | 41 |
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
|
| 42 | 42 |
graph_vlabel players |
| 43 |
graph_args --base 1000 -r --lower-limit 0 --upper-limit 16
|
|
| 43 |
graph_args --base 1000 -r --lower-limit 0 |
|
| 44 | 44 |
graph_category games |
| 45 | 45 |
maxplayer.label max players |
| 46 |
bot.label bots |
|
| 46 | 47 |
player.label players" |
| 47 | 48 |
} |
| 48 | 49 |
|
| 49 | 50 |
################################################################# |
| 50 | 51 |
# Quake Stat, call qstat # |
| 51 | 52 |
#---------------------------------------------------------------# |
| 52 |
quake_stat() {
|
|
| 53 |
qstat_run() {
|
|
| 53 | 54 |
if [ "${script_name}" != "qstat_" ]; then
|
| 54 | 55 |
gametype=$(echo "$script_name" | cut -d_ -f2) |
| 55 | 56 |
ip=$(echo "$script_name" | cut -d_ -f3) |
| ... | ... | |
| 61 | 62 |
fi |
| 62 | 63 |
|
| 63 | 64 |
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}")
|
|
| 65 | 66 |
|
| 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)
|
|
| 68 | 72 |
|
| 69 | 73 |
if [ -z "${playervalue}" ]; then
|
| 70 | 74 |
playervalue=0 |
| 71 | 75 |
fi |
| 72 | 76 |
|
| 77 |
if [ -z "${botvalue}" ]; then
|
|
| 78 |
botvalue=0 |
|
| 79 |
fi |
|
| 80 |
|
|
| 73 | 81 |
if [ -z "${maxplayervalue}" ]; then
|
| 74 | 82 |
maxplayervalue=0 |
| 75 | 83 |
fi |
| 76 | 84 |
|
| 77 | 85 |
|
| 78 | 86 |
echo "maxplayer.value "${maxplayervalue};
|
| 87 |
echo "bot.value "${botvalue};
|
|
| 79 | 88 |
echo "player.value "${playervalue};
|
| 80 | 89 |
else |
| 81 | 90 |
echo "maxplayer.value U" |
| 91 |
echo "bot.value U" |
|
| 82 | 92 |
echo "player.value U" |
| 83 | 93 |
fi |
| 84 | 94 |
} |
| ... | ... | |
| 99 | 109 |
echo "no (edit the script for set qstat path)" |
| 100 | 110 |
;; |
| 101 | 111 |
*) |
| 102 |
quake_stat "$@"
|
|
| 112 |
qstat_run "$@"
|
|
| 103 | 113 |
exit 0 |
| 104 | 114 |
;; |
| 105 | 115 |
esac |
Formats disponibles : Unified diff