Nagios plugins: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Markierung: Ersetzt
 
(10 dazwischenliegende Versionen von 4 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
=check_host=
+
*[[check_severity]]
<pre>
+
*[[check_host]]
#!/bin/bash
+
*[[check_port]]
WAIT="-w 1"
+
*[[check_proxy]]
while getopts H:w: opt
+
*[[check_backup]]
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
 
</pre>
 
 
 
=check port=
 
<pre>
 
#!/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
 
 
 
</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
 
        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
 
</pre>
 
 
 
Usage:
 
./check_proxy -P *WUNSCHPROXY*:3128 -U *URL*/test.file
 

Aktuelle Version vom 24. November 2021, 20:40 Uhr