]> arthur.barton.de Git - nagcollect.git/blob - client/bin/nagcollecttest
Enhance output of "nagcollecttest" script
[nagcollect.git] / client / bin / nagcollecttest
1 #!/bin/bash
2 #
3 # NagCollect -- Nagios Data Collector for Passive Checks
4 # Copyright (c)2009-2011 Alexander Barton, alex@barton.de
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 # Please read the file COPYING, README and AUTHORS for more information.
11 #
12
13 NAME=`basename "$0"`
14 MAXTIME=300
15
16 if [ $# -ne 1 ]; then
17         echo "Usage: $NAME <scriptname>"
18         exit 2
19 fi
20 if [ `id -u` -ne 0 ]; then
21         echo "$NAME must be run as root!"
22         exit 2
23 fi
24
25 if [ -r /usr/local/lib/nagcollect/"$1.tst" ]; then
26         tst=/usr/local/lib/nagcollect/"$1.tst"
27 elif [ -r /usr/local/lib/nagcollect/`uname`/"$1.tst" ]; then
28         tst=/usr/local/lib/nagcollect/`uname`/"$1.tst"
29 else
30         echo "$NAME: script \"$1\" not found!"
31         exit 2
32 fi
33
34 SERVICE=""; STATUS=""; TEXT=""
35 echo "Checking \"$tst\" ..."
36 . "$tst"
37
38 [ -n "$STATUS" -o -n "$TEXT" ] \
39         && echo "RESULT: $SERVICE=$STATUS \"$TEXT\"" \
40         || echo "NO result ..."
41
42 # -eof-