Hi!
I have the following script and do not understand part of it. I have a very little understanding of scripting.
The script is for Nagios to check the response of fast-com.de. The guy who has written it is no longer in the company.
#!/bin/sh
PATH=/adm/bin:/bin:/usr/bin
export PATH
. /adm/libexec/nagios/utils.sh
print_help() {
}
print_usage() {
}
status_out=/tmp/sms-status.out
thresh_warn=5000
thresh_crit=15000
host=www.fast-com.de
url=/gsm/status.php
while test -n "$1"; do
case "$1" in
--help|-h)
print_help
exit $STATE_OK
;;
--version|-V)
print_revision
exit $STATE_OK
;;
--warning|-w)
thresh_warn=$2
shift
;;
--critical|-c)
thresh_crit=$2
shift
;;
--host|-H)
host=$2
shift
;;
--url|-u)
url=$2
shift
;;
*)
$ECHO "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
rm -f $status_out
t=$(time 2>&1 -p wget --quiet --post-data='username=xxxxxx&password=xxxx&id=xxxxx' --no-check-certificate --output-document=$status_out --timeout=30 "https://${host}${url}" | perl -ne 'print int($1 * 1000) if /^real (\S+)/')
if [ ".$t" != . ]; then
if [ -s $status_out ]; then
result="ok"
exitstatus=$STATE_OK
if [ $t -ge $thresh_warn ]; then
result="warning"
exitstatus=$STATE_WARNING
fi
if [ $t -ge $thresh_crit ]; then
result="critical"
exitstatus=$STATE_CRITICAL
fi
else
result="critical"
exitstatus=$STATE_CRITICAL
fi
else
result="critical"
exitstatus=$STATE_CRITICAL
fi
echo "REQUEST $result - $t ms | rtt=$t"
exit $exitstatus
What i don't understand are the following parts:
-
if [ ".$t" != . ]; then
I know that is a not equal check, but .$t and . ? -
if [ -s $status_out ]; then
Here i don't know the meaning of -s -
if [ $t -ge $thresh_warn ]; then
What does the -ge do here? I would expect something like $t -xy=xx
The check is delivering a status "Critical" and when i don't understand this three parts i can not verify the values which are delivered.
Thx
Alex