root / plugins / quake / qstatcod4and5_ @ ade3b205
Historique | Voir | Annoter | Télécharger (3,77 ko)
| 1 |
#!/bin/sh |
|---|---|
| 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 |
# Edited: Rouven David Na?l - peperoni # |
| 9 |
# Edit : 09/01/2009 # |
| 10 |
# Plugin edited for COD4+COD5 # |
| 11 |
# Email: peperoni@sac-esports.de # |
| 12 |
#---------------------------------------------------------------# |
| 13 |
################################################################# |
| 14 |
# Variable : # |
| 15 |
#---------------------------------------------------------------# |
| 16 |
# Set path to QSTAT # |
| 17 |
qstat_exe='/usr/local/bin/qstat' # |
| 18 |
#---------------------------------------------------------------# |
| 19 |
# End of config |
| 20 |
script_name=$(basename "$0") |
| 21 |
################################################################# |
| 22 |
|
| 23 |
################################################################# |
| 24 |
# Help # |
| 25 |
#---------------------------------------------------------------# |
| 26 |
usage() {
|
| 27 |
echo 'For testing the script, run qstatcod4and5_ cods IP PORT' |
| 28 |
echo ' - GameType : cods ... run qstat for seeing available gametype' |
| 29 |
echo 'For munin you must ln -s /usr/share/munin/plugins/qstatcod4and5_ /etc/munin/plugins/cod4_cods_IP_PORT' |
| 30 |
echo 'Example you will test this COD4 Server: 123.456.789.123:28960' |
| 31 |
echo 'your symlink looks like this: ln -s /usr/share/munin/plugins/cod4server /etc/munin/plugins/cod4_cods_123.456.789.123_28960' |
| 32 |
echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe};
|
| 33 |
echo 'Have Fun' |
| 34 |
} |
| 35 |
|
| 36 |
config() {
|
| 37 |
if [ "${script_name}" != "qstatcod4and5_" ]; then
|
| 38 |
gametype=$(echo "$script_name" | cut -d_ -f2) |
| 39 |
ip=$(echo "$script_name" | cut -d_ -f3) |
| 40 |
port=$(echo "$script_name" | cut -d_ -f4) |
| 41 |
else |
| 42 |
gametype=$1 |
| 43 |
ip=$2 |
| 44 |
port=$3 |
| 45 |
fi |
| 46 |
|
| 47 |
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
|
| 48 |
graph_vlabel players |
| 49 |
graph_category games |
| 50 |
player.label players" |
| 51 |
} |
| 52 |
|
| 53 |
################################################################# |
| 54 |
# Quake Stat, call qstat # |
| 55 |
#---------------------------------------------------------------# |
| 56 |
quake_stat() {
|
| 57 |
if [ "${script_name}" != "qstatcod4and5_" ]; then
|
| 58 |
gametype=$(echo "$script_name" | cut -d_ -f2) |
| 59 |
ip=$(echo "$script_name" | cut -d_ -f3) |
| 60 |
port=$(echo "$script_name" | cut -d_ -f4) |
| 61 |
else |
| 62 |
gametype=$1 |
| 63 |
ip=$2 |
| 64 |
port=$3 |
| 65 |
fi |
| 66 |
|
| 67 |
if [ ! -z "$gametype" ] && [ ! -z "$gametype" ] && [ ! -z "$gametype" ]; then |
| 68 |
dummy=$("$qstat_exe" -P -pa -sort P "-$gametype" "${ip}:${port}" | grep frags | wc -l)
|
| 69 |
playervalue=$dummy |
| 70 |
|
| 71 |
if [ -z "$playervalue" ]; then |
| 72 |
playervalue=0 |
| 73 |
fi |
| 74 |
|
| 75 |
echo "player.value $playervalue" |
| 76 |
else |
| 77 |
echo "player.value U" |
| 78 |
fi |
| 79 |
} |
| 80 |
|
| 81 |
################################################################# |
| 82 |
# Main # |
| 83 |
#---------------------------------------------------------------# |
| 84 |
case $1 in |
| 85 |
config) |
| 86 |
config "$1" "$2" "$3" |
| 87 |
exit 0 |
| 88 |
;; |
| 89 |
help | ?) |
| 90 |
usage |
| 91 |
exit 0 |
| 92 |
;; |
| 93 |
autoconf) |
| 94 |
echo "no (edit the script for set qstat path)" |
| 95 |
;; |
| 96 |
*) |
| 97 |
quake_stat "$1" "$2" "$3" |
| 98 |
exit 0 |
| 99 |
;; |
| 100 |
esac |
