Nagios plugins: Unterschied zwischen den Versionen

Aus xinux.net
Zur Navigation springen Zur Suche springen
Zeile 27: Zeile 27:
 
else
 
else
 
echo "$HOST PARAMETER MISSING"
 
echo "$HOST PARAMETER MISSING"
 +
exit 3
 +
fi
 +
</pre>
 +
 +
=check_proxy=
 +
<pre>
 +
#!/bin/bash
 +
PROXY="*STANDARDPROXY*:3128"
 +
while getopts P:U: opt
 +
do
 +
  case $opt in
 +
      P)
 +
        PROXY="$OPTARG"
 +
        ;;
 +
      U)
 +
        URL="$OPTARG"
 +
        ;;
 +
  esac
 +
done
 +
 +
if ! test -z "$URL"
 +
then
 +
        echo homo
 +
        if export http_proxy="$PROXY" && wget $URL > /dev/null
 +
          then
 +
          echo "$URL OK"
 +
            exit 0
 +
          else
 +
            echo "$URL FAILED"
 +
            exit 2
 +
        fi
 +
else
 +
echo "$URL PARAMETER MISSING"
 
exit 3
 
exit 3
 
fi
 
fi
 
</pre>
 
</pre>

Version vom 8. August 2014, 11:00 Uhr

check_host

#!/bin/bash
WAIT="-w 1"
while getopts H:w: opt
do
   case $opt in
       w)
        WAIT="-w $OPTARG"
        ;;
       H)
        HOST="$OPTARG"
        ;;
   esac
done

if ! test -z "$HOST"
then
 if ping $WAIT -c 1 -q $HOST > /dev/null
  then
   echo "$HOST OK"
   exit 0 
  else
   echo "$HOST FAILED"
   exit 2
 fi
else
echo "$HOST PARAMETER MISSING"
exit 3
fi

check_proxy

#!/bin/bash
PROXY="*STANDARDPROXY*:3128"
while getopts P:U: opt
do
   case $opt in
       P)
        PROXY="$OPTARG"
        ;;
       U)
        URL="$OPTARG"
        ;;
   esac
done

if ! test -z "$URL"
then
        echo homo
        if export http_proxy="$PROXY" && wget $URL > /dev/null
           then
          echo "$URL OK"
            exit 0
          else
            echo "$URL FAILED"
            exit 2
         fi
else
echo "$URL PARAMETER MISSING"
exit 3
fi