root / plugins / other / qstatcod4and5_ @ 83159620
Historique | Voir | Annoter | Télécharger (3,3 ko)
| 1 | c371409e | Rouven David Na?l - peperoni | #!/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 | # Set the Group for munin to be displayed e.x. games or COD4 # |
||
| 19 | munin_group='games' # |
||
| 20 | #---------------------------------------------------------------# |
||
| 21 | # End of config |
||
| 22 | script_name=$(basename $0) |
||
| 23 | ################################################################# |
||
| 24 | |||
| 25 | ################################################################# |
||
| 26 | # Help # |
||
| 27 | #---------------------------------------------------------------# |
||
| 28 | 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' |
||
| 36 | } |
||
| 37 | |||
| 38 | 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)
|
||
| 43 | else |
||
| 44 | gametype=$1 |
||
| 45 | ip=$2 |
||
| 46 | port=$3 |
||
| 47 | fi |
||
| 48 | |||
| 49 | echo "graph_title Number of players on ${gametype} - ${ip}:${port}
|
||
| 50 | graph_vlabel players |
||
| 51 | graph_category ${munin_group}
|
||
| 52 | player.label players" |
||
| 53 | } |
||
| 54 | |||
| 55 | ################################################################# |
||
| 56 | # Quake Stat, call qstat # |
||
| 57 | #---------------------------------------------------------------# |
||
| 58 | 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 |
||
| 68 | |||
| 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 |
||
| 76 | |||
| 77 | echo "player.value "${playervalue};
|
||
| 78 | else |
||
| 79 | echo "player.value U" |
||
| 80 | fi |
||
| 81 | } |
||
| 82 | |||
| 83 | ################################################################# |
||
| 84 | # Main # |
||
| 85 | #---------------------------------------------------------------# |
||
| 86 | 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 | ;; |
||
| 102 | esac |
