Révision 57367ce9
Plugin qstatcod4and5_: fix shellcheck issues
| plugins/other/qstatcod4and5_ | ||
|---|---|---|
| 1 | 1 |
#!/bin/sh |
| 2 | 2 |
################################################################# |
| 3 | 3 |
# Title : Qstat plugin for Munin # |
| 4 |
# Author : Benjamin DUPUIS - Poil #
|
|
| 5 |
# Email : poil@quake.fr #
|
|
| 6 |
# First release : 18/10/2007 #
|
|
| 4 |
# Author : Benjamin DUPUIS - Poil #
|
|
| 5 |
# Email : poil@quake.fr #
|
|
| 6 |
# First release : 18/10/2007 #
|
|
| 7 | 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 #
|
|
| 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 | 12 |
#---------------------------------------------------------------# |
| 13 | 13 |
################################################################# |
| 14 |
# Variable : #
|
|
| 14 |
# Variable : #
|
|
| 15 | 15 |
#---------------------------------------------------------------# |
| 16 |
# Set path to QSTAT # |
|
| 17 |
qstat_exe='/usr/local/bin/qstat' # |
|
| 18 |
# Set the Group for munin to be displayed e.x. games or COD4 # |
|
| 19 |
munin_group='games' # |
|
| 16 |
# Set path to QSTAT # |
|
| 17 |
qstat_exe='/usr/local/bin/qstat' # |
|
| 20 | 18 |
#---------------------------------------------------------------# |
| 21 | 19 |
# End of config |
| 22 |
script_name=$(basename $0)
|
|
| 20 |
script_name=$(basename "$0")
|
|
| 23 | 21 |
################################################################# |
| 24 | 22 |
|
| 25 | 23 |
################################################################# |
| 26 |
# Help #
|
|
| 24 |
# Help #
|
|
| 27 | 25 |
#---------------------------------------------------------------# |
| 28 | 26 |
usage() {
|
| 29 |
echo 'For testing the script, run qstatcod4and5_ cods IP PORT'
|
|
| 30 |
echo ' - GameType : cods ... run qstat for seeing available gametype'
|
|
| 31 |
echo 'For munin you must ln -s /usr/share/munin/plugins/qstatcod4and5_ /etc/munin/plugins/cod4_cods_IP_PORT'
|
|
| 32 |
echo 'Example you will test this COD4 Server: 123.456.789.123:28960'
|
|
| 33 |
echo 'your symlink looks like this: ln -s /usr/share/munin/plugins/cod4server /etc/munin/plugins/cod4_cods_123.456.789.123_28960'
|
|
| 34 |
echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe};
|
|
| 35 |
echo 'Have Fun'
|
|
| 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'
|
|
| 36 | 34 |
} |
| 37 | 35 |
|
| 38 | 36 |
config() {
|
| 39 |
if [ "${script_name}" != "qstatcod4and5_" ]; then
|
|
| 40 |
gametype=$(echo ${script_name} | cut -d_ -f2)
|
|
| 41 |
ip=$(echo ${script_name} | cut -d_ -f3)
|
|
| 42 |
port=$(echo ${script_name} | cut -d_ -f4)
|
|
| 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)
|
|
| 43 | 41 |
else |
| 44 | 42 |
gametype=$1 |
| 45 | 43 |
ip=$2 |
| ... | ... | |
| 48 | 46 |
|
| 49 | 47 |
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
|
| 50 | 48 |
graph_vlabel players |
| 51 |
graph_category ${munin_group}
|
|
| 49 |
graph_category games
|
|
| 52 | 50 |
player.label players" |
| 53 | 51 |
} |
| 54 | 52 |
|
| 55 | 53 |
################################################################# |
| 56 |
# Quake Stat, call qstat #
|
|
| 54 |
# Quake Stat, call qstat #
|
|
| 57 | 55 |
#---------------------------------------------------------------# |
| 58 | 56 |
quake_stat() {
|
| 59 |
if [ "${script_name}" != "qstatcod4and5_" ]; then
|
|
| 60 |
gametype=$(echo ${script_name} | cut -d_ -f2)
|
|
| 61 |
ip=$(echo ${script_name} | cut -d_ -f3)
|
|
| 62 |
port=$(echo ${script_name} | cut -d_ -f4)
|
|
| 63 |
else
|
|
| 64 |
gametype=$1
|
|
| 65 |
ip=$2
|
|
| 66 |
port=$3
|
|
| 67 |
fi
|
|
| 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
|
|
| 68 | 66 |
|
| 69 |
if [ ! -z ${gametype} ] && [ ! -z ${gametype} ] && [ ! -z ${gametype} ]; then
|
|
| 70 |
dummy=$(${qstat_exe} -P -pa -sort P -${gametype} ${ip}:${port} | grep frags | wc -l)
|
|
| 71 |
playervalue=$dummy |
|
| 72 |
|
|
| 73 |
if [ -z "${playervalue}" ]; then
|
|
| 74 |
playervalue=0 |
|
| 75 |
fi |
|
| 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 |
|
| 76 | 70 |
|
| 77 |
echo "player.value "${playervalue};
|
|
| 78 |
else |
|
| 79 |
echo "player.value U" |
|
| 80 |
fi |
|
| 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 |
|
| 81 | 79 |
} |
| 82 | 80 |
|
| 83 | 81 |
################################################################# |
| 84 |
# Main #
|
|
| 82 |
# Main #
|
|
| 85 | 83 |
#---------------------------------------------------------------# |
| 86 | 84 |
case $1 in |
| 87 |
config)
|
|
| 88 |
config
|
|
| 89 |
exit 0
|
|
| 90 |
;;
|
|
| 91 |
help | ?)
|
|
| 92 |
usage
|
|
| 93 |
exit 0
|
|
| 94 |
;;
|
|
| 95 |
autoconf)
|
|
| 96 |
echo "no (edit the script for set qstat path)"
|
|
| 97 |
;;
|
|
| 98 |
*)
|
|
| 99 |
quake_stat $1 $2 $3
|
|
| 100 |
exit 0
|
|
| 101 |
;;
|
|
| 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 |
;;
|
|
| 102 | 100 |
esac |
| 103 |
|
|
Formats disponibles : Unified diff