Nagios plugins: Unterschied zwischen den Versionen

Aus xinux.net
Zur Navigation springen Zur Suche springen
Zeile 69: Zeile 69:
 
</pre>
 
</pre>
  
=check_proxy=
 
<pre>
 
 
#!/bin/bash
 
#!/bin/bash
PROXY="*STANDARDPROXY*:3128"
+
#Hier standardproxy eintragen:
 +
PROXY="XXX.XXX.XXX.XXX:3128"
 +
 
 
while getopts P:U: opt
 
while getopts P:U: opt
 
do
 
do
Zeile 85: Zeile 85:
 
done
 
done
  
if ! test -z "$URL"
+
if ! test -z "$URL"; then
then
+
         export http_proxy="$PROXY"
         if export http_proxy="$PROXY" && wget $URL > /dev/null
+
        if wget -t 1 -q $URL; then
          then
+
            echo "$URL OK"
          echo "$URL OK"
+
            exit 0
            exit 0
+
        else
          else
+
            echo "$URL FAILED"
            echo "$URL FAILED"
+
            exit 2
            exit 2
 
 
         fi
 
         fi
 
else
 
else
 
echo "$URL PARAMETER MISSING"
 
echo "$URL PARAMETER MISSING"
 +
echo "SYNTAX: -P PROXY:PORT -U URL"
 
exit 3
 
exit 3
 
fi
 
fi
</pre>
 
 
Usage:
 
./check_proxy -P *WUNSCHPROXY*:3128 -U *URL*/test.file
 

Version vom 11. August 2014, 10:01 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_port

#!/bin/bash
while getopts H:p: opt
do
   case $opt in
       p)
        PORT="$OPTARG"
        ;;
       H)
        HOST="$OPTARG"
        ;;
   esac
done

if ! test -z "$HOST" && ! test -z "$PORT"
then    
        if  nc -w1 -z $HOST $PORT
                then            
                echo "$HOST OK"
                exit 0
                else
                echo "$HOST FAILED"
                exit 2
        fi
else
        if test -z "$HOST"
        then
        echo "HOSTNAME FEHLT"
        exit 3
        else
        echo "PORT FEHLT"
        exit 3
        fi
fi

  1. !/bin/bash
  2. Hier standardproxy eintragen:

PROXY="XXX.XXX.XXX.XXX:3128"

while getopts P:U: opt do

  case $opt in
      P)
       PROXY="$OPTARG"
       ;;
      U)
       URL="$OPTARG"
       ;;
  esac

done

if ! test -z "$URL"; then

       export http_proxy="$PROXY"
       if wget -t 1 -q $URL; then
            echo "$URL OK"
            exit 0
        else
            echo "$URL FAILED"
            exit 2
        fi

else echo "$URL PARAMETER MISSING" echo "SYNTAX: -P PROXY:PORT -U URL" exit 3 fi