mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Plugin qstatcod4and5_: fix shellcheck issues
This commit is contained in:
parent
eb9019d6ed
commit
57367ce98c
@ -1,45 +1,43 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#################################################################
|
#################################################################
|
||||||
# Title : Qstat plugin for Munin #
|
# Title : Qstat plugin for Munin #
|
||||||
# Author : Benjamin DUPUIS - Poil #
|
# Author : Benjamin DUPUIS - Poil #
|
||||||
# Email : poil@quake.fr #
|
# Email : poil@quake.fr #
|
||||||
# First release : 18/10/2007 #
|
# First release : 18/10/2007 #
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
# Edited: Rouven David Naßl - peperoni #
|
# Edited: Rouven David Naßl - peperoni #
|
||||||
# Edit : 09/01/2009 #
|
# Edit : 09/01/2009 #
|
||||||
# Plugin edited for COD4+COD5 #
|
# Plugin edited for COD4+COD5 #
|
||||||
# Email: peperoni@sac-esports.de #
|
# Email: peperoni@sac-esports.de #
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
#################################################################
|
#################################################################
|
||||||
# Variable : #
|
# Variable : #
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
# Set path to QSTAT #
|
# Set path to QSTAT #
|
||||||
qstat_exe='/usr/local/bin/qstat' #
|
qstat_exe='/usr/local/bin/qstat' #
|
||||||
# Set the Group for munin to be displayed e.x. games or COD4 #
|
|
||||||
munin_group='games' #
|
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
# End of config
|
# End of config
|
||||||
script_name=$(basename $0)
|
script_name=$(basename "$0")
|
||||||
#################################################################
|
#################################################################
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
# Help #
|
# Help #
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
usage() {
|
usage() {
|
||||||
echo 'For testing the script, run qstatcod4and5_ cods IP PORT'
|
echo 'For testing the script, run qstatcod4and5_ cods IP PORT'
|
||||||
echo ' - GameType : cods ... run qstat for seeing available gametype'
|
echo ' - GameType : cods ... run qstat for seeing available gametype'
|
||||||
echo 'For munin you must ln -s /usr/share/munin/plugins/qstatcod4and5_ /etc/munin/plugins/cod4_cods_IP_PORT'
|
echo 'For munin you must ln -s /usr/share/munin/plugins/qstatcod4and5_ /etc/munin/plugins/cod4_cods_IP_PORT'
|
||||||
echo 'Example you will test this COD4 Server: 123.456.789.123:28960'
|
echo 'Example you will test this COD4 Server: 123.456.789.123:28960'
|
||||||
echo 'your symlink looks like this: ln -s /usr/share/munin/plugins/cod4server /etc/munin/plugins/cod4_cods_123.456.789.123_28960'
|
echo 'your symlink looks like this: ln -s /usr/share/munin/plugins/cod4server /etc/munin/plugins/cod4_cods_123.456.789.123_28960'
|
||||||
echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe};
|
echo 'Perhaps you must have to set qstat_exe path, actually on'${qstat_exe};
|
||||||
echo 'Have Fun'
|
echo 'Have Fun'
|
||||||
}
|
}
|
||||||
|
|
||||||
config() {
|
config() {
|
||||||
if [ "${script_name}" != "qstatcod4and5_" ]; then
|
if [ "${script_name}" != "qstatcod4and5_" ]; then
|
||||||
gametype=$(echo ${script_name} | cut -d_ -f2)
|
gametype=$(echo "$script_name" | cut -d_ -f2)
|
||||||
ip=$(echo ${script_name} | cut -d_ -f3)
|
ip=$(echo "$script_name" | cut -d_ -f3)
|
||||||
port=$(echo ${script_name} | cut -d_ -f4)
|
port=$(echo "$script_name" | cut -d_ -f4)
|
||||||
else
|
else
|
||||||
gametype=$1
|
gametype=$1
|
||||||
ip=$2
|
ip=$2
|
||||||
@ -48,56 +46,55 @@ config() {
|
|||||||
|
|
||||||
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
|
echo "graph_title Number of players on ${gametype} - ${ip}:${port}
|
||||||
graph_vlabel players
|
graph_vlabel players
|
||||||
graph_category ${munin_group}
|
graph_category games
|
||||||
player.label players"
|
player.label players"
|
||||||
}
|
}
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
# Quake Stat, call qstat #
|
# Quake Stat, call qstat #
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
quake_stat() {
|
quake_stat() {
|
||||||
if [ "${script_name}" != "qstatcod4and5_" ]; then
|
if [ "${script_name}" != "qstatcod4and5_" ]; then
|
||||||
gametype=$(echo ${script_name} | cut -d_ -f2)
|
gametype=$(echo "$script_name" | cut -d_ -f2)
|
||||||
ip=$(echo ${script_name} | cut -d_ -f3)
|
ip=$(echo "$script_name" | cut -d_ -f3)
|
||||||
port=$(echo ${script_name} | cut -d_ -f4)
|
port=$(echo "$script_name" | cut -d_ -f4)
|
||||||
else
|
else
|
||||||
gametype=$1
|
gametype=$1
|
||||||
ip=$2
|
ip=$2
|
||||||
port=$3
|
port=$3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z ${gametype} ] && [ ! -z ${gametype} ] && [ ! -z ${gametype} ]; then
|
if [ ! -z "$gametype" ] && [ ! -z "$gametype" ] && [ ! -z "$gametype" ]; then
|
||||||
dummy=$(${qstat_exe} -P -pa -sort P -${gametype} ${ip}:${port} | grep frags | wc -l)
|
dummy=$("$qstat_exe" -P -pa -sort P "-$gametype" "${ip}:${port}" | grep frags | wc -l)
|
||||||
playervalue=$dummy
|
playervalue=$dummy
|
||||||
|
|
||||||
if [ -z "${playervalue}" ]; then
|
|
||||||
playervalue=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "player.value "${playervalue};
|
if [ -z "$playervalue" ]; then
|
||||||
else
|
playervalue=0
|
||||||
echo "player.value U"
|
fi
|
||||||
fi
|
|
||||||
|
echo "player.value $playervalue"
|
||||||
|
else
|
||||||
|
echo "player.value U"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
# Main #
|
# Main #
|
||||||
#---------------------------------------------------------------#
|
#---------------------------------------------------------------#
|
||||||
case $1 in
|
case $1 in
|
||||||
config)
|
config)
|
||||||
config
|
config "$1" "$2" "$3"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
help | ?)
|
help | ?)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
autoconf)
|
autoconf)
|
||||||
echo "no (edit the script for set qstat path)"
|
echo "no (edit the script for set qstat path)"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
quake_stat $1 $2 $3
|
quake_stat "$1" "$2" "$3"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user