From 68494656cdb8f174a740d2f40cf9517efc2467ad Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Tue, 14 Feb 2012 23:51:55 +0100 Subject: [PATCH] Added sanity checks, updated version number and README file --- README | 14 ++++++++------ check_quake.sh | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/README b/README index a9bfa82..35e7b2f 100644 --- a/README +++ b/README @@ -1,14 +1,16 @@ check_quake.sh -This is meant to be a Nagios plugin to monitor Quake servers. Currently only -Quake II server are supported, but it's easy to to any types of servers that -are supported by qstat. This plugin uses qstat to do all the queries. +This is a Nagios plugin to monitor Quake servers. Currently only Quake II +servers are supported, but more games will be added in the future. +This plugin uses qstat to do all the queries. +The plugin complies with the Nagios Plugin Development Guidelines. It has +some basic sanity checks, uses the default exit codes, follows the standard +arguments, has only one line of output etc. -Note that this plugin does NOT yet comply with the Nagios Plugin Development -Guidelines (for example missing some sanity checks). The plugin is in use by myself to monitor a friends Quake II server and is working nicely. + Options: -h Print detailed help screen @@ -16,7 +18,7 @@ Options: Print version information -H Set the host/IP of the server to watch --P +-p Set the port number of the Quake server to watch Default is 27910 --warning diff --git a/check_quake.sh b/check_quake.sh index d6dbd0f..4a16a90 100755 --- a/check_quake.sh +++ b/check_quake.sh @@ -29,9 +29,12 @@ # # ############################################################################### -VERSION="0.1" +VERSION="0.2" AUTHOR="(c) 2012 Jack-Benny Persson (jack-benny@cyberinfo.se)" +# Qstat binary +QSTAT=/usr/bin/quakestat + # Exit codes STATE_OK=0 STATE_WARNING=1 @@ -43,6 +46,14 @@ PORT=27919 shopt -s extglob +# Sanity checks +if [[ ! -x "$QSTAT" ]]; then + printf "It appears you don't have the qstat package installed in\ + $QSTAT\n" + exit $STATE_UNKNOWN +fi + + #### Functions #### # Print version information @@ -66,7 +77,7 @@ Options: Print version information -H Set the host/IP of the server to watch --P +-p Set the port number of the Quake server to watch Default is 27910 --warning @@ -106,7 +117,7 @@ while [[ -n "$1" ]]; do shift 2 ;; - -P) + -p) if [[ -z "$2" ]]; then printf "\nOption $1 requires an argument\n" print_help