Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
centreon:scripts-linux [2023/07/05 10:49] – michel | centreon:scripts-linux [2024/12/27 06:28] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
==== check_A335_backup ==== | ==== check_A335_backup ==== | ||
- | # | + | < |
- | | + | # |
- | | + | ########################################################################################## |
- | | + | # Ajout de la ligne de commande pour nrpe dans: / |
- | | + | # command[check_A335_backup]=/ |
- | | + | ########################################################################################## |
- | | + | # Deplacement vers le dossier de recherche |
- | | + | cd / |
- | | + | |
- | | + | # Recherche du fichier le + récent |
- | | + | VAR1=$(ls -t | head -n1) |
- | | + | |
- | | + | # Recherche du mot pour OK |
- | | + | VAR4=$(grep ' |
- | | + | |
- | | + | # Check fichier plus de 1 jour |
- | | + | if [[ $(find " |
- | | + | echo "Log du jour absent" |
- | | + | fi |
- | | + | |
- | | + | #Vérif si retour recherche vide |
- | | + | if [[ -z $VAR4 ]]; then |
- | | + | echo " |
- | | + | fi |
- | | + | |
- | | + | # Si fichier OK et backup OK alors OK |
- | | + | if [ -n " |
- | | + | echo " |
- | | + | exit 0 |
- | | + | fi |
- | | + | |
- | | + | # Envois du resultat à Centreon |
- | | + | while read line; do echo $line; done |
+ | exit 2 | ||
+ | ###################################### | ||
+ | # Rendre le fichier executable | ||
+ | # chmod +x check_A335_backup.sh | ||
+ | # Pensez à redémarre le service | ||
+ | # service nagios-nrpe-server restart # | ||
+ | ###################################### | ||
+ | </ | ||
==== check_by_ssh_erreurs_badgeuses.sh ==== | ==== check_by_ssh_erreurs_badgeuses.sh ==== | ||
- | # | + | < |
- | | + | # |
- | | + | #set -x |
- | | + | HOST=$1 |
- | | + | |
- | | + | COMMAND=$(ssh -t -i / |
+ | #echo $COMMAND | ||
+ | |||
+ | OUT=$? | ||
if [ $OUT -eq 1 ] | if [ $OUT -eq 1 ] | ||
then | then | ||
Ligne 70: | Ligne 81: | ||
exit 0 | exit 0 | ||
fi | fi | ||
- | ==== Check_Certfif_asa ==== | + | </ |
- | | + | ==== Check_Certfif_asa ==== |
- | | + | < |
- | | + | # |
- | | + | |
- | | + | #set -x |
- | | + | |
- | | + | #Adresse IP en parametre |
- | | + | HOSTNAME=$1 |
- | | + | |
- | | + | #nom utilisateur d'un profil de gestion des ASA |
- | | + | USERNAME=SARANCIDBck01 |
- | | + | |
- | | + | #mot de passe du profil de gestion des ASA |
- | | + | PASSWORD=2k3zX4bV9i4hNaHl |
- | | + | |
- | | + | MONTH=(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) |
+ | |||
+ | #date du jour | ||
+ | NOW=`date +%Y%m%d` | ||
+ | |||
+ | #variable stockant le niveau d' | ||
+ | sortie=0 | ||
+ | |||
+ | |||
+ | #convertir le mois de l' | ||
+ | #Le parametre à passer doit etre de la forme de la liste MONTH (ex: Jan) | ||
+ | mois_chiffre() { | ||
local i=0 | local i=0 | ||
local len=${# | local len=${# | ||
Ligne 98: | Ligne 121: | ||
fi | fi | ||
let i++ | let i++ | ||
+ | |||
done | done | ||
- | } | + | } |
- | | + | |
- | | + | #verifie l'etat du status |
- | | + | #mettre en parametre le status (ex: " |
+ | check_status() { | ||
stat=`echo $1 | cut -c 1-9` | stat=`echo $1 | cut -c 1-9` | ||
if [[ " | if [[ " | ||
then | then | ||
sortie=2 | sortie=2 | ||
+ | |||
fi | fi | ||
- | } | + | } |
- | | + | |
- | | + | #permet de creer et de renvoyer la variable date du certificat |
- | | + | #mettre les parametres dans l' |
+ | create_cert_date() { | ||
local mois=$(mois_chiffre $2) | local mois=$(mois_chiffre $2) | ||
edate=$(date -d $1-$mois-$3 +" | edate=$(date -d $1-$mois-$3 +" | ||
echo $edate | echo $edate | ||
- | } | + | } |
- | | + | |
- | | + | #renvoie le delta en jours entre deux dates |
- | | + | #les parametres doivent etre : date_certif date_du_jour |
+ | compare_date() { | ||
let DIFF=($(date +%s -d $1) - $(date +%s -d $2))/86400 | let DIFF=($(date +%s -d $1) - $(date +%s -d $2))/86400 | ||
echo $DIFF | echo $DIFF | ||
- | } | + | } |
- | | + | |
- | | + | |
- | | + | |
- | | + | #section connexion à l'ASA et suite de commandes pour recuperer les certificats des ASA |
- | | + | sshpass -p $PASSWORD ssh -q -o StrictHostKeyChecking=no $USERNAME@$HOSTNAME << ' |
- | | + | enable |
- | | + | 2k3zX4bV9i4hNaHl |
- | | + | conf t |
- | | + | pager 0 |
- | | + | end |
- | | + | show crypto ca certificates |
+ | exit | ||
+ | EOF | ||
+ | |||
+ | |||
+ | while read line; do | ||
#echo $line | #echo $line | ||
eval ARRAY=(`echo $line`) | eval ARRAY=(`echo $line`) | ||
#echo ${ARRAY[0]} | #echo ${ARRAY[0]} | ||
+ | |||
+ | |||
+ | |||
# | # | ||
if [[ ${ARRAY[0]} == " | if [[ ${ARRAY[0]} == " | ||
Ligne 145: | Ligne 183: | ||
echo " | echo " | ||
sortie=2 | sortie=2 | ||
+ | |||
#WARNING: date du certificat inferieur a 30 jours | #WARNING: date du certificat inferieur a 30 jours | ||
elif [[ " | elif [[ " | ||
then | then | ||
echo " | echo " | ||
+ | |||
if [[ " | if [[ " | ||
then | then | ||
Ligne 154: | Ligne 194: | ||
fi | fi | ||
fi | fi | ||
+ | |||
fi | fi | ||
+ | |||
+ | |||
#Status | #Status | ||
if [[ ${ARRAY[0]} == " | if [[ ${ARRAY[0]} == " | ||
Ligne 160: | Ligne 203: | ||
check_status ${ARRAY[1]} $assos | check_status ${ARRAY[1]} $assos | ||
fi | fi | ||
+ | |||
#End Date | #End Date | ||
if [[ ${ARRAY[0]} == " | if [[ ${ARRAY[0]} == " | ||
Ligne 170: | Ligne 214: | ||
#echo "Jours restant avant expiration du certificat : $delta_date" | #echo "Jours restant avant expiration du certificat : $delta_date" | ||
fi | fi | ||
- | done <<< | + | |
- | / | + | done <<< |
- | | + | |
- | | + | rm -f / |
- | | + | |
- | | + | #Les certificats sont bons ou il n'y en a pas, on renvoie un output pour Centreon |
+ | if [[ $sortie -eq 0 ]] | ||
+ | then | ||
echo " | echo " | ||
- | fi | + | fi |
- | | + | |
+ | |||
+ | exit $sortie | ||
+ | </ | ||
==== check_dispo_sla.sh ==== | ==== check_dispo_sla.sh ==== | ||
- | # | + | < |
- | | + | # |
- | | + | |
- | | + | #suppress error outputs |
+ | |||
+ | |||
+ | #try to read vars from file, for windows and tests purpose | ||
+ | if [ -f ./ | ||
. ./ | . ./ | ||
- | fi | + | fi |
- | | + | |
- | | + | #set default JQ value should be OK on linux if jq is installed |
- | | + | JQ=${JQ: |
- | | + | |
- | | + | #debug defincition for execution traces |
- | | + | CENTREON_DEBUG=${CENTREON_DEBUG: |
- | | + | |
- | | + | #regexp used for host |
- | | + | CENTREON_HOST_REGEXP=${3: |
- | | + | CENTREON_HOST_REGEXP=${CENTREON_HOST_REGEXP// |
- | | + | #regexp used for service |
- | | + | CENTREON_SVC_REGEXP=${4: |
- | | + | CENTREON_SVC_REGEXP=${CENTREON_SVC_REGEXP// |
- | | + | #centreon url |
- | | + | CENTREON_URL=" |
- | | + | |
- | | + | CENTREON_LOGIN=${1: |
- | [0].security.token' | + | CENTREON_PASSWORD=${2: |
- | | + | |
- | | + | #query centreon token |
- | {\" | + | TOKEN_QUERY_DATA=" |
- | | + | CENTREON_TOKEN=`curl -s -k -X POST -d " |
- | | + | |
+ | #query used to request sstates | ||
+ | CENTREON_QUERY=" | ||
+ | |||
+ | #function to request data, was more complex at the beginning | ||
+ | centreon_request() { | ||
# warning at the limit, no High availability with more than 50 instance | # warning at the limit, no High availability with more than 50 instance | ||
- | curl -s -k -H " | + | curl -s -k -H " |
- | | + | } |
- | | + | |
- | | + | #print values used for execution |
- | | + | if [ " |
echo JQ: $JQ | echo JQ: $JQ | ||
echo centreon_query: | echo centreon_query: | ||
echo centreon_token: | echo centreon_token: | ||
- | else | + | else |
exec 2>/ | exec 2>/ | ||
- | fi | + | fi |
- | | + | |
- | | + | |
+ | #print query | ||
+ | if [ " | ||
echo request for $CENTREON_QUERY | echo request for $CENTREON_QUERY | ||
- | fi | + | fi |
- | | + | |
- | | + | # request data |
- | | + | state=`centreon_request ${CENTREON_QUERY}` |
- | | + | |
+ | #show status codes | ||
+ | if [ " | ||
echo Results | echo Results | ||
echo $state | $JQ -r " | echo $state | $JQ -r " | ||
- | fi | + | fi |
- | | + | |
- | | + | |
- | | + | # use a service group for that |
- | | + | # compute result which is addition of all status code |
- | | + | # result=`echo $state | $JQ -r " |
- | | + | |
- | | + | # compute result which is mulitplication of all status code |
+ | values=`echo $state | $JQ -r " | ||
+ | result=1 | ||
+ | for i in $values; do | ||
# echo " | # echo " | ||
result=$((result*i)) | result=$((result*i)) | ||
# echo ">> | # echo ">> | ||
- | done | + | done |
- | | + | |
- | | + | # result=`echo $state | $JQ -r " |
+ | |||
+ | if [[ " | ||
AGGREGATION_OUPUT=3 | AGGREGATION_OUPUT=3 | ||
comment=" | comment=" | ||
- | elif [[ $result == 0 ]] ; then | + | elif [[ $result == 0 ]] ; then |
AGGREGATION_OUPUT=0 | AGGREGATION_OUPUT=0 | ||
comment=" | comment=" | ||
- | else | + | else |
AGGREGATION_OUPUT=2 | AGGREGATION_OUPUT=2 | ||
comment=" | comment=" | ||
- | fi | + | fi |
- | | + | |
+ | if [ " | ||
echo AGGREGATION_OUPUT: | echo AGGREGATION_OUPUT: | ||
- | fi | + | fi |
- | | + | |
- | | + | echo $comment" |
- | | + | centreon_details=`echo $state | $JQ -cr " |
+ | for detail in " | ||
echo " | echo " | ||
- | | + | done |
- | exit $AGGREGATION_OUPUT | + | |
+ | exit $AGGREGATION_OUPUT | ||
+ | </ | ||
+ | ==== check_file_age ==== | ||
+ | < | ||
+ | #! /bin/sh | ||
+ | #Si un fichier .runnning est présent depuis plus de 4h, on alerte | ||
+ | for f in `ls / | ||
+ | do | ||
+ | FILECHANGE=`stat --printf=%Y $f` | ||
+ | CURRENTDATE=`date +%s` | ||
+ | FILEAGE=$((CURRENTDATE-FILECHANGE)) | ||
+ | if [ $FILEAGE -gt 28800 ] | ||
+ | then | ||
+ | echo " | ||
+ | exit 2 | ||
+ | elif [ $FILEAGE -gt 14400 ] | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | done | ||
+ | echo "OK - Rsync OK" | ||
+ | exit 0 | ||
+ | </ | ||
+ | ==== check_file_exist ==== | ||
+ | < | ||
+ | #! /bin/bash | ||
+ | # | ||
+ | # Author : Diego Martin Gardella [dgardella@gmail.com] | ||
+ | # Desc : Plugin to verify if a file exists | ||
+ | # | ||
+ | # | ||
+ | |||
+ | PROGNAME=`basename $0` | ||
+ | PROGPATH=`echo $0 | sed -e ' | ||
+ | |||
+ | . $PROGPATH/ | ||
+ | |||
+ | if [ " | ||
+ | then | ||
+ | echo -e " Use : $PROGNAME < | ||
+ | exit $STATE_UNKNOWN | ||
+ | fi | ||
+ | |||
+ | |||
+ | if [ -f $1 ] | ||
+ | then | ||
+ | echo "OK - $1 : EXISTS :: `head -3 $1`" # shows the first three lines of the file | ||
+ | exit $STATE_OK | ||
+ | else | ||
+ | echo " | ||
+ | exit $STATE_CRITICAL | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_gateway_lora ==== | ||
+ | < | ||
+ | # | ||
+ | # Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug) | ||
+ | set -x | ||
+ | |||
+ | # On definit les variables | ||
+ | |||
+ | # curl | ||
+ | CURL="/ | ||
+ | |||
+ | # La variable que l'on entre en fin de commande dans centreon (nom de la gateway) | ||
+ | HOST=$1 | ||
+ | |||
+ | # La variable si dessous est un renouvellement du token a chaque check | ||
+ | TOKEN=`$CURL -s -k -X POST -H ' | ||
+ | |||
+ | # La variable si dessous recupere le ref de la gateway | ||
+ | REF=`$CURL -s -k -X GET -H ' | ||
+ | |||
+ | # La variable si dessous donne les resultats de l' | ||
+ | RESULT=`$CURL -s -k -X GET -H ' | ||
+ | |||
+ | # Alertes suivant les retour | ||
+ | # Details 'etat adin, etat connexion, etat status' | ||
+ | # Critique = ' | ||
+ | # Warning = ' | ||
+ | # OK = ' | ||
+ | # autre = ' | ||
+ | |||
+ | # Si critique | ||
+ | if [[ $RESULT = ' | ||
+ | then | ||
+ | echo "KO Gateway is Critical" | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si warning | ||
+ | if [[ $RESULT = ' | ||
+ | then | ||
+ | echo "KO Gateway is Warning" | ||
+ | exit 3 | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_ilo_hp ==== | ||
+ | < | ||
+ | # Get Token | ||
+ | #! /bin/bash | ||
+ | # Desc : Plugin to verify Ilo status on HP-OneView | ||
+ | # checks possible: server-hardware, | ||
+ | |||
+ | # Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug) | ||
+ | #set -x | ||
+ | |||
+ | # On suprime l' | ||
+ | rm -f "/ | ||
+ | |||
+ | # Variables | ||
+ | RESULT="/ | ||
+ | HOST=$1 | ||
+ | CHECK=$2 | ||
+ | TOKEN=$(cat " | ||
+ | |||
+ | # Check token and renew if necessary | ||
+ | CHECKTOKEN=$(curl -s -k -H ' | ||
+ | |||
+ | if [[ $CHECKTOKEN = " | ||
+ | then | ||
+ | TOKEN=" | ||
+ | |||
+ | elif [[ $CHECKTOKEN != " | ||
+ | then | ||
+ | NEWTOKEN=$(curl -s -k -H ' | ||
+ | TOKEN=" | ||
+ | fi | ||
+ | |||
+ | # Ecriture du token dans le fichier text | ||
+ | echo $TOKEN > "/ | ||
+ | |||
+ | # On recupere la liste des résultats | ||
+ | curl -s -k -H ' | ||
+ | |||
+ | # Variables resultats | ||
+ | CRITICAL=`grep " | ||
+ | WARNING=`grep " | ||
+ | OK=`grep " | ||
+ | |||
+ | if [[ " | ||
+ | then | ||
+ | echo -e " | ||
+ | exit 2 | ||
+ | |||
+ | # Si warning | ||
+ | elif [[ " | ||
+ | then | ||
+ | echo -e " | ||
+ | exit 1 | ||
+ | |||
+ | # Si OK | ||
+ | else | ||
+ | echo " | ||
+ | exit 0 | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_ntp_stratum ==== | ||
+ | < | ||
+ | # | ||
+ | STATE_OK=0 | ||
+ | STATE_WARNING=1 | ||
+ | STATE_CRITICAL=2 | ||
+ | STATE_UNKNOWN=3 | ||
+ | STATE="" | ||
+ | STATUS=(OK WARNING CRITICAL UNKNOWN) | ||
+ | |||
+ | set -e | ||
+ | |||
+ | ########## | ||
+ | ## MAIN ## | ||
+ | ########## | ||
+ | # Process user-provided parameters | ||
+ | while getopts " | ||
+ | do | ||
+ | case ${OPT} in | ||
+ | H) HOST=${OPTARG};; | ||
+ | s) EXPECTED_STRATUM=${OPTARG};; | ||
+ | \?) | ||
+ | echo "" | ||
+ | echo " | ||
+ | echo "-s for exptected stratum" | ||
+ | echo "" | ||
+ | exit ${STATE_UNKNOWN} | ||
+ | ;; | ||
+ | esac | ||
+ | done | ||
+ | |||
+ | if [ -z " | ||
+ | CRIT_THRESHOLD=2 | ||
+ | fi | ||
+ | |||
+ | #Debug | ||
+ | #set -x | ||
+ | |||
+ | STRATUM=$(ntpq -c readlist $HOST | grep -Eo ' | ||
+ | |||
+ | if [ -z " | ||
+ | echo " | ||
+ | exit ${STATE_UNKNOWN} | ||
+ | fi | ||
+ | |||
+ | if [ " | ||
+ | STATE=1 | ||
+ | elif [ " | ||
+ | STATE=2 | ||
+ | else | ||
+ | STATE=0 | ||
+ | fi | ||
+ | |||
+ | echo " | ||
+ | exit $STATE | ||
+ | </ | ||
+ | ==== check_netapp_lun_size ==== | ||
+ | < | ||
+ | #! /bin/bash | ||
+ | # Desc : Plugin to verify LUN size on NETAPP | ||
+ | # admin: | ||
+ | # To get lun's uuid: | ||
+ | # curl -s -k -u admin: | ||
+ | |||
+ | # Decommentez la ligne ci-dessous pour debug | ||
+ | set -x | ||
+ | |||
+ | # Variables | ||
+ | HOST=$1 | ||
+ | USER=$2 | ||
+ | PASS=$3 | ||
+ | LUN=$4 | ||
+ | ALERT=$5 | ||
+ | HAUT=$6 | ||
+ | |||
+ | # check si toutes les variables sont la | ||
+ | if [[ $# -ne 6 ]] | ||
+ | then echo "Il manque des variables" | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Commande pour recuperer le total/used de la LUN via son UUID | ||
+ | RESULT=$(curl -k -s -u $USER:$PASS -X GET https://" | ||
+ | |||
+ | # On coupe le resultat pour garder le used | ||
+ | TOTAL=`echo $RESULT | awk ' | ||
+ | |||
+ | # On coupe le resultat pour garder le total multiplie par la variable pourcentage mise sans la commande pour definir les seuils d' | ||
+ | WARN=`echo $RESULT | awk ' | ||
+ | CRIT=`echo $RESULT | awk ' | ||
+ | |||
+ | # Si critique | ||
+ | if [[ $TOTAL -gt " | ||
+ | then | ||
+ | echo "LUN Usage is CRITICAL: $RESULT" | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si warning | ||
+ | if [[ $TOTAL -gt " | ||
+ | then | ||
+ | echo "LUN Usage is Warning: $RESULT" | ||
+ | exit 1 | ||
+ | |||
+ | |||
+ | # Si OK | ||
+ | else | ||
+ | echo "LUN Usage is OK: $RESULT" | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_netapp_volume ==== | ||
+ | < | ||
+ | #Faire un service | ||
+ | |||
+ | #/ | ||
+ | # Desc : Plugin to verify volume size on NETAPP | ||
+ | |||
+ | # Pour lister les volumes sur le Vfilers | ||
+ | # curl -s http:// | ||
+ | |||
+ | # Decommentez la ligne ci-dessous pour debug | ||
+ | # set -x | ||
+ | |||
+ | # Variables | ||
+ | CLU=$1 | ||
+ | VFL=$2 | ||
+ | VOL=$3 | ||
+ | WARN=$4 | ||
+ | CRIT=$5 | ||
+ | |||
+ | RESULT=$(curl -s http:// | ||
+ | TOTAL=$(curl -s http:// | ||
+ | PRCT=`echo " | ||
+ | |||
+ | # Si critique | ||
+ | if [[ $PRCT -gt " | ||
+ | then | ||
+ | echo " | ||
+ | exit 2 | ||
+ | |||
+ | # Si warning | ||
+ | elif [[ $PRCT -gt " | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | |||
+ | # Si pas de résultat unknown | ||
+ | elif [[ -z $PRCT ]] | ||
+ | then | ||
+ | echo "No response from plugin" | ||
+ | exit 3 | ||
+ | |||
+ | # Si OK | ||
+ | else | ||
+ | echo " | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_netapp_vfiler ==== | ||
+ | < | ||
+ | #! /bin/bash | ||
+ | # Desc : Plugin to verify volume size on NETAPP | ||
+ | |||
+ | # Decommentez la ligne ci-dessous pour debug | ||
+ | #set -x | ||
+ | |||
+ | # On suprime l' | ||
+ | rm -f / | ||
+ | rm -f / | ||
+ | rm -f / | ||
+ | # Variables | ||
+ | CLU=$1 | ||
+ | VFL=$2 | ||
+ | WARN=$3 | ||
+ | CRIT=$4 | ||
+ | PERFO_FILE=/ | ||
+ | Volume=/ | ||
+ | |||
+ | # On recupere la liste des volumes sur le Vfilers | ||
+ | curl -s http:// | ||
+ | cat $Volume | grep ' | ||
+ | |||
+ | while read VOL; | ||
+ | do | ||
+ | RESULT=$(cat $Volume | grep -oE ' | ||
+ | TOTAL=$(cat $Volume | grep -oE ' | ||
+ | PRCT=`echo " | ||
+ | |||
+ | # Si critique | ||
+ | if [[ $PRCT -gt " | ||
+ | then | ||
+ | echo " | ||
+ | elif [[ $PRCT -gt " | ||
+ | then | ||
+ | echo " | ||
+ | elif [[ -z $PRCT ]] | ||
+ | then | ||
+ | echo " | ||
+ | else | ||
+ | echo "OK volume $VOL used $PRCT% of $TOTAL" | ||
+ | fi | ||
+ | |||
+ | done < "/ | ||
+ | |||
+ | #VAL=`cat "/ | ||
+ | VAL2=/ | ||
+ | |||
+ | # Si critique | ||
+ | CRITICAL=`grep " | ||
+ | WARNING=`grep " | ||
+ | OK=`grep " | ||
+ | |||
+ | if [[ $CRITICAL != "" | ||
+ | then | ||
+ | grep " | ||
+ | grep " | ||
+ | grep " | ||
+ | exit 2 | ||
+ | # Si warning | ||
+ | elif [[ $WARNING != "" | ||
+ | then | ||
+ | grep " | ||
+ | grep " | ||
+ | exit 1 | ||
+ | # Si OK | ||
+ | else | ||
+ | grep " | ||
+ | exit 0 | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_netapp_lun_state ==== | ||
+ | < | ||
+ | #! /bin/bash | ||
+ | # Desc : Plugin to verify LUN status on NETAPP | ||
+ | |||
+ | # Decommentez la ligne ci-dessous pour debug | ||
+ | # set -x | ||
+ | |||
+ | # Variables | ||
+ | USER=$1 | ||
+ | PASS=$2 | ||
+ | HOST=$3 | ||
+ | FILTER=$4 | ||
+ | |||
+ | # Commande si filtrage de certaines LUNs | ||
+ | if | ||
+ | [[ ! -z $FILTER ]] | ||
+ | then | ||
+ | RESULT=$(curl -s -k -u $USER:$PASS -X GET ' | ||
+ | |||
+ | # Commande si pas de filtrage | ||
+ | else | ||
+ | RESULT=$(curl -s -k -u $USER:$PASS -X GET ' | ||
+ | fi | ||
+ | |||
+ | # Si resultat vide | ||
+ | if | ||
+ | [[ -z $RESULT ]] | ||
+ | then | ||
+ | echo " | ||
+ | exit 3 | ||
+ | fi | ||
+ | |||
+ | # Si critique | ||
+ | CRIT=`echo -e " | ||
+ | if [[ $RESULT != *" | ||
+ | then | ||
+ | printf " | ||
+ | exit 2 | ||
+ | |||
+ | # Si OK | ||
+ | else | ||
+ | echo "OK: $RESULT" | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_inode_size.sh ==== | ||
+ | < | ||
+ | # | ||
+ | # Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug) | ||
+ | # set -x | ||
+ | |||
+ | # Desc : Plugin to verify INODE percent used on NETAPP | ||
+ | |||
+ | # Variables | ||
+ | VSERV=/ | ||
+ | VOL=$2 | ||
+ | WARN=${3: | ||
+ | CRIT=${4: | ||
+ | |||
+ | RESULT=$(cat $VSERV-vol.txt | grep -oE ' | ||
+ | |||
+ | # Si critique | ||
+ | if [[ $RESULT -gt " | ||
+ | then | ||
+ | echo "INODE Usage is CRITICAL: $RESULT%" | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si warning | ||
+ | if [[ $RESULT -gt " | ||
+ | then | ||
+ | echo "INODE Usage is Warning: $RESULT%" | ||
+ | exit 1 | ||
+ | |||
+ | |||
+ | # Si OK | ||
+ | else | ||
+ | echo "INODE Usage is OK: $RESULT%" | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_postfix_mailq ==== | ||
+ | < | ||
+ | # | ||
+ | |||
+ | OID=" | ||
+ | STATE_OK=0 | ||
+ | STATE_WARNING=1 | ||
+ | STATE_CRITICAL=2 | ||
+ | STATE_UNKNOWN=3 | ||
+ | STATE="" | ||
+ | STATUS=(OK WARNING CRITICAL UNKNOWN) | ||
+ | |||
+ | set -e | ||
+ | |||
+ | # Process user-provided parameters | ||
+ | while getopts " | ||
+ | do | ||
+ | case ${OPT} in | ||
+ | H) SNMP_HOST=${OPTARG};; | ||
+ | C) SNMP_COMMUNITY=${OPTARG};; | ||
+ | v) SNMP_VERSION=${OPTARG};; | ||
+ | w) WARN_THRESHOLD=${OPTARG};; | ||
+ | c) CRIT_THRESHOLD=${OPTARG};; | ||
+ | \?) | ||
+ | echo "" | ||
+ | echo " | ||
+ | echo "-w for warning threshold and -c for critical threshold." | ||
+ | echo "" | ||
+ | exit ${STATE_UNKNOWN} | ||
+ | ;; | ||
+ | esac | ||
+ | done | ||
+ | #set -x | ||
+ | |||
+ | if [ -z " | ||
+ | WARN_THRESHOLD=250 | ||
+ | fi | ||
+ | |||
+ | if [ -z " | ||
+ | CRIT_THRESHOLD=400 | ||
+ | fi | ||
+ | |||
+ | if [ -z " | ||
+ | SNMP_COMMUNITY=' | ||
+ | fi | ||
+ | |||
+ | if [ -z " | ||
+ | SNMP_VERSION=' | ||
+ | fi | ||
+ | |||
+ | STATS[0]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.1 | grep -E -o ' | ||
+ | STATS[1]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.2 | grep -E -o ' | ||
+ | STATS[2]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.3 | grep -E -o ' | ||
+ | |||
+ | STATS_TOTAL=0 | ||
+ | for stats in ${STATS[@]} ; do | ||
+ | STATS_TOTAL=$(( $STATS_TOTAL + $stats )) | ||
+ | done | ||
+ | |||
+ | STATS[3]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.4 | grep -E -o ' | ||
+ | |||
+ | if [ $STATS_TOTAL -ge $CRIT_THRESHOLD ]; then | ||
+ | STATE=2 | ||
+ | elif [ $STATS_TOTAL -ge $WARN_THRESHOLD ]; then | ||
+ | STATE=1 | ||
+ | else | ||
+ | STATE=0 | ||
+ | fi | ||
+ | |||
+ | echo " | ||
+ | exit $STATE | ||
+ | </ | ||
+ | ==== check_postfix_mailstats ==== | ||
+ | < | ||
+ | # | ||
+ | |||
+ | OID=" | ||
+ | STATE_OK=0 | ||
+ | STATE_WARNING=1 | ||
+ | STATE_CRITICAL=2 | ||
+ | STATE_UNKNOWN=3 | ||
+ | STATE="" | ||
+ | STATUS=(OK WARNING CRITICAL UNKNOWN) | ||
+ | |||
+ | set -e | ||
+ | |||
+ | # Process user-provided parameters | ||
+ | while getopts " | ||
+ | do | ||
+ | case ${OPT} in | ||
+ | H) SNMP_HOST=${OPTARG};; | ||
+ | C) SNMP_COMMUNITY=${OPTARG};; | ||
+ | v) SNMP_VERSION=${OPTARG};; | ||
+ | w) WARN_THRESHOLD=${OPTARG};; | ||
+ | c) CRIT_THRESHOLD=${OPTARG};; | ||
+ | \?) | ||
+ | echo "" | ||
+ | echo " | ||
+ | echo "-w for warning threshold and -c for critical threshold." | ||
+ | echo "" | ||
+ | exit ${STATE_UNKNOWN} | ||
+ | ;; | ||
+ | esac | ||
+ | done | ||
+ | set -x | ||
+ | |||
+ | if [ -z " | ||
+ | WARN_THRESHOLD=250 | ||
+ | fi | ||
+ | |||
+ | if [ -z " | ||
+ | CRIT_THRESHOLD=500 | ||
+ | fi | ||
+ | |||
+ | if [ -z " | ||
+ | SNMP_COMMUNITY=' | ||
+ | fi | ||
+ | |||
+ | if [ -z " | ||
+ | SNMP_VERSION=' | ||
+ | fi | ||
+ | |||
+ | STATS[0]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.1 | grep -E -o ' | ||
+ | STATS[1]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.2 | grep -E -o ' | ||
+ | STATS[2]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.3 | grep -E -o ' | ||
+ | STATS[3]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.4 | grep -E -o ' | ||
+ | |||
+ | if [ ${STATS[0]} -eq ' | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | STATS_TOTAL=0 | ||
+ | for stats in ${STATS[@]} ; do | ||
+ | STATS_TOTAL=$(( $STATS_TOTAL + $stats )) | ||
+ | done | ||
+ | |||
+ | if [ $STATS_TOTAL -ge $CRIT_THRESHOLD ]; then | ||
+ | STATE=2 | ||
+ | elif [ $STATS_TOTAL -ge $WARN_THRESHOLD ]; then | ||
+ | STATE=1 | ||
+ | else | ||
+ | STATE=0 | ||
+ | fi | ||
+ | |||
+ | echo " | ||
+ | exit $STATE | ||
+ | </ | ||
+ | ==== check_simple_oid ==== | ||
+ | < | ||
+ | # | ||
+ | # Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug) | ||
+ | # set -x | ||
+ | |||
+ | # On definit les variables | ||
+ | COMM=$1 | ||
+ | HOST=$2 | ||
+ | OID=$3 | ||
+ | WARN=$4 | ||
+ | CRIT=$5 | ||
+ | |||
+ | # La variable si dessous recupere le dernier champ de la requète | ||
+ | RESULT=$(snmpwalk -c $COMM -v 2c $HOST $OID | awk ' | ||
+ | |||
+ | # Si critique | ||
+ | if [[ " | ||
+ | then | ||
+ | echo "Value is Critical: $RESULT" | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si warning | ||
+ | if [[ " | ||
+ | then | ||
+ | echo "Value is Warning: $RESULT" | ||
+ | exit 1 | ||
+ | |||
+ | # Si OK | ||
+ | else | ||
+ | echo "Value is OK: $RESULT" | ||
+ | exit 0 | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_simple_oid_perfo ==== | ||
+ | < | ||
+ | # | ||
+ | # Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug) | ||
+ | # set -x | ||
+ | |||
+ | # On definit les variables | ||
+ | COMM=$1 | ||
+ | HOST=$2 | ||
+ | OID=$3 | ||
+ | WARN=$4 | ||
+ | CRIT=$5 | ||
+ | |||
+ | #prend les 6 et 7 parametre ou 0 15000 si ils ne sont pas définis | ||
+ | MIN=${6: | ||
+ | MAX=${7: | ||
+ | |||
+ | # La variable si dessous recupere le dernier champ de la requète | ||
+ | RESULT=$(snmpwalk -c $COMM -v 2c $HOST $OID | awk ' | ||
+ | |||
+ | # Si critique | ||
+ | if [[ " | ||
+ | then | ||
+ | state=Critical | ||
+ | output=2 | ||
+ | # Si warning | ||
+ | elif [[ " | ||
+ | then | ||
+ | state=Warning | ||
+ | output=1 | ||
+ | # Si OK | ||
+ | else | ||
+ | state=OK | ||
+ | output=0 | ||
+ | fi | ||
+ | |||
+ | echo "Value is $state: $RESULT|connections=$RESULT; | ||
+ | exit $output | ||
+ | </ | ||
+ | ==== check_sla_dispo_process_Linux.sh ==== | ||
+ | < | ||
+ | # | ||
+ | #################################################### | ||
+ | # Script pour verifier qu'au moins un process | ||
+ | # precis tourne sur un ou plusieurs serveurs Linux | ||
+ | # By adex036137 | ||
+ | #################################################### | ||
+ | |||
+ | # Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug) | ||
+ | # set -x | ||
+ | |||
+ | # On definit les variables et on fait une boucle pour chaques serveurs demandes | ||
+ | FICHIER=$() | ||
+ | for VAR in $2; do | ||
+ | HOST=$VAR | ||
+ | COMM=$1 | ||
+ | #HOST=$2 | ||
+ | SERV=$(snmpwalk -c $COMM -v 2c $HOST HOST-RESOURCES-MIB:: | ||
+ | WARN=${4: | ||
+ | CRIT=${5: | ||
+ | FICHIER+=($(snmpwalk -c $COMM -v 2c $HOST HOST-RESOURCES-MIB:: | ||
+ | done | ||
+ | RESULT=$(printf " | ||
+ | |||
+ | # Remontee des alertes | ||
+ | # Si critique | ||
+ | if [[ " | ||
+ | | ||
+ | echo " | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si warning | ||
+ | if [[ " | ||
+ | | ||
+ | echo " | ||
+ | exit 1 | ||
+ | |||
+ | # Si OK | ||
+ | else | ||
+ | echo "OK: $RESULT services: $3 ' | ||
+ | exit 0 | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_sla_dispo_services_windows.sh ==== | ||
+ | < | ||
+ | # | ||
+ | #################################################### | ||
+ | # Script pour verifier qu'au moins un service | ||
+ | # precis tourne sur un ou plusieurs serveurs Windows | ||
+ | # By adex036137 | ||
+ | #################################################### | ||
+ | |||
+ | # Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug) | ||
+ | # set -x | ||
+ | |||
+ | # On definit les variables et on fait une boucle pour chaques serveurs demandes | ||
+ | FICHIER=$() | ||
+ | for VAR in $2; do | ||
+ | HOST=$VAR | ||
+ | COMM=$1 | ||
+ | #HOST=$2 | ||
+ | SERV=$3 | ||
+ | WARN=${4: | ||
+ | CRIT=${5: | ||
+ | FICHIER+=($(snmpwalk -c $COMM -v 2c $HOST 1.3.6.1.4.1.77.1.2.3.1.1 | grep " | ||
+ | done | ||
+ | RESULT=$(printf ' | ||
+ | # Remontee des alertes | ||
+ | # Si critique | ||
+ | if [[ " | ||
+ | | ||
+ | echo " | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si warning | ||
+ | if [[ " | ||
+ | | ||
+ | echo " | ||
+ | exit 1 | ||
+ | |||
+ | Si OK | ||
+ | else | ||
+ | echo "OK: $RESULT services: $SERV ' | ||
+ | exit 0 | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_snmp_dell_equalogic ==== | ||
+ | < | ||
+ | # | ||
+ | # / | ||
+ | # check_snmp_dell_equallogic | ||
+ | # Description : Check the status of Dell EqualLogic storage | ||
+ | # Version : 1.5 | ||
+ | # Author : Yoann LAMY | ||
+ | # Licence : GPLv2 | ||
+ | |||
+ | # Commands | ||
+ | CMD_BASENAME="/ | ||
+ | CMD_SNMPGET="/ | ||
+ | CMD_SNMPWALK="/ | ||
+ | CMD_AWK="/ | ||
+ | CMD_GREP="/ | ||
+ | CMD_BC="/ | ||
+ | CMD_EXPR="/ | ||
+ | |||
+ | # Script name | ||
+ | SCRIPTNAME=`$CMD_BASENAME $0` | ||
+ | |||
+ | # Version | ||
+ | VERSION=" | ||
+ | |||
+ | # Plugin return codes | ||
+ | STATE_OK=0 | ||
+ | STATE_WARNING=1 | ||
+ | STATE_CRITICAL=2 | ||
+ | STATE_UNKNOWN=3 | ||
+ | |||
+ | # ' | ||
+ | OID_MEMBER_ID=" | ||
+ | |||
+ | # ' | ||
+ | OID_BATTERY_STATUS=" | ||
+ | |||
+ | # ' | ||
+ | OID_MODEL=" | ||
+ | |||
+ | # ' | ||
+ | OID_SERIALNUMBER=" | ||
+ | |||
+ | # ' | ||
+ | OID_NUMBERCONTROLLERS=" | ||
+ | |||
+ | # ' | ||
+ | OID_NUMBERDISKS=" | ||
+ | |||
+ | # ' | ||
+ | OID_CONNECTIONS_ISCSI=" | ||
+ | |||
+ | # ' | ||
+ | OID_FAN_NAME=" | ||
+ | |||
+ | # ' | ||
+ | OID_FAN_VALUE=" | ||
+ | |||
+ | # ' | ||
+ | OID_HEALTH_STATUS=" | ||
+ | |||
+ | # ' | ||
+ | OID_IO_READ=" | ||
+ | |||
+ | # ' | ||
+ | OID_IO_WRITE=" | ||
+ | |||
+ | # ' | ||
+ | OID_LATENCY_READ=" | ||
+ | |||
+ | # ' | ||
+ | OID_LATENCY_WRITE=" | ||
+ | |||
+ | # ' | ||
+ | OID_CONTROLLER_PRIMSEC=" | ||
+ | |||
+ | # ' | ||
+ | OID_DISK_ID=" | ||
+ | |||
+ | # ' | ||
+ | OID_DISK_TYPE=" | ||
+ | |||
+ | # ' | ||
+ | OID_DISK_TOTAL=" | ||
+ | |||
+ | # ' | ||
+ | OID_DISK_STATUS=" | ||
+ | |||
+ | # ' | ||
+ | OID_NETWORK_NAME=" | ||
+ | |||
+ | # ' | ||
+ | OID_NETWORK_ID=" | ||
+ | |||
+ | # ' | ||
+ | OID_NETWORK_MTU=" | ||
+ | |||
+ | # ' | ||
+ | OID_NETWORK_SPEED=" | ||
+ | |||
+ | # ' | ||
+ | OID_NETWORK_STATUS=" | ||
+ | # ' | ||
+ | OID_POWERSUPPLY_NAME=" | ||
+ | |||
+ | # ' | ||
+ | OID_POWERSUPPLY_STATUS=" | ||
+ | |||
+ | # ' | ||
+ | OID_RAID_STATUS=" | ||
+ | |||
+ | # ' | ||
+ | OID_TEMPERATURE_NAME=" | ||
+ | |||
+ | # ' | ||
+ | OID_TEMPERATURE_VALUE=" | ||
+ | |||
+ | # ' | ||
+ | OID_USAGE_TOTAL=" | ||
+ | |||
+ | # ' | ||
+ | OID_USAGE_USED=" | ||
+ | |||
+ | # ' | ||
+ | OID_USAGE_SNAPSHOTS=" | ||
+ | |||
+ | # ' | ||
+ | OID_USAGE_REPLICAS=" | ||
+ | |||
+ | # ' | ||
+ | OID_VOLUME_NAME=" | ||
+ | |||
+ | # ' | ||
+ | OID_VOLUME_STATUS=" | ||
+ | |||
+ | # ' | ||
+ | OID_VOLUME_TOTAL=" | ||
+ | |||
+ | # ' | ||
+ | OID_VOLUME_USED=" | ||
+ | |||
+ | # ' | ||
+ | OID_VOLUME_STORAGEPOOL_ID=" | ||
+ | |||
+ | # ' | ||
+ | OID_STORAGEPOOL_NAME=" | ||
+ | |||
+ | # Default variables | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_UNKNOWN | ||
+ | CODE=0 | ||
+ | |||
+ | # Default options | ||
+ | COMMUNITY=" | ||
+ | HOSTNAME=" | ||
+ | NAME="" | ||
+ | TYPE=" | ||
+ | NETWORK=" | ||
+ | MTU=9000 | ||
+ | SPEED=1000 | ||
+ | DISK=1 | ||
+ | VOLUME=" | ||
+ | WARNING=0 | ||
+ | CRITICAL=0 | ||
+ | |||
+ | # Option processing | ||
+ | print_usage() { | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | } | ||
+ | |||
+ | print_version() { | ||
+ | echo $SCRIPTNAME version $VERSION | ||
+ | echo "" | ||
+ | echo "This nagios plugins comes with ABSOLUTELY NO WARRANTY." | ||
+ | echo "You may redistribute copies of the plugins under the terms of the GNU General Public License v2." | ||
+ | } | ||
+ | |||
+ | print_help() { | ||
+ | print_version | ||
+ | echo "" | ||
+ | print_usage | ||
+ | echo "" | ||
+ | echo "Check the status of Dell EqualLogic storage" | ||
+ | echo "" | ||
+ | echo "-H ADDRESS" | ||
+ | echo " | ||
+ | echo "-C STRING" | ||
+ | echo " | ||
+ | echo "-n STRING" | ||
+ | echo " | ||
+ | echo "-t STRING" | ||
+ | echo " | ||
+ | echo "-i STRING" | ||
+ | echo " | ||
+ | echo "-m INTEGER" | ||
+ | echo " | ||
+ | echo "-s INTEGER" | ||
+ | echo " | ||
+ | echo "-d INTEGER" | ||
+ | echo " | ||
+ | echo "-v STRING" | ||
+ | echo " | ||
+ | echo "-w INTEGER" | ||
+ | echo " | ||
+ | echo "-c INTEGER" | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo "" | ||
+ | echo "" | ||
+ | echo "This plugin uses the ' | ||
+ | echo "This plugin support performance data output (connection, | ||
+ | } | ||
+ | |||
+ | while getopts H: | ||
+ | do | ||
+ | case $OPT in | ||
+ | H) HOSTNAME=" | ||
+ | C) COMMUNITY=" | ||
+ | n) NAME=" | ||
+ | t) TYPE=" | ||
+ | i) NETWORK=" | ||
+ | m) MTU=$OPTARG ;; | ||
+ | s) SPEED=$OPTARG ;; | ||
+ | d) DISK=$OPTARG ;; | ||
+ | v) VOLUME=" | ||
+ | w) WARNING=$OPTARG ;; | ||
+ | c) CRITICAL=$OPTARG ;; | ||
+ | h) | ||
+ | print_help | ||
+ | | ||
+ | ;; | ||
+ | V) | ||
+ | print_version | ||
+ | exit $STATE_UNKNOWN | ||
+ | ;; | ||
+ | | ||
+ | done | ||
+ | |||
+ | # Plugin processing | ||
+ | size_convert() { | ||
+ | if [ $VALUE -ge 1099511627776 ]; then | ||
+ | VALUE=`echo " | ||
+ | VALUE=" | ||
+ | elif [ $VALUE -ge 1073741824 ]; then | ||
+ | VALUE=`echo " | ||
+ | VALUE=" | ||
+ | elif [ $VALUE -ge 1048576 ]; then | ||
+ | VALUE=`echo " | ||
+ | VALUE=" | ||
+ | else | ||
+ | VALUE=`echo " | ||
+ | VALUE=" | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | if [ -n " | ||
+ | MEMBER_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME $OID_MEMBER_ID | $CMD_GREP -iw $NAME | $CMD_AWK '{ print $1}' | $CMD_AWK -F " | ||
+ | |||
+ | if [ -n " | ||
+ | |||
+ | if [ $TYPE = " | ||
+ | # Check battery status (Usage : ./ | ||
+ | DESCRIPTION=" | ||
+ | COMMA=", | ||
+ | for CONTROLLER_ID in 1 2; do | ||
+ | BATTERY_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_BATTERY_STATUS}.${MEMBER_ID}.${CONTROLLER_ID}` | ||
+ | case $BATTERY_STATUS in | ||
+ | 1) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | ;; | ||
+ | 2) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | break | ||
+ | ;; | ||
+ | 3) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | break | ||
+ | ;; | ||
+ | 4) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | break | ||
+ | ;; | ||
+ | 5) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | break | ||
+ | ;; | ||
+ | 6) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | break | ||
+ | ;; | ||
+ | *) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_UNKNOWN | ||
+ | break | ||
+ | ;; | ||
+ | esac | ||
+ | COMMA="" | ||
+ | done | ||
+ | elif [ $TYPE = " | ||
+ | # Number of connection (Usage : ./ | ||
+ | CONNECTIONS_ISCSI=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_CONNECTIONS_ISCSI}.${MEMBER_ID}` | ||
+ | if [ -n " | ||
+ | if [ $WARNING != 0 ] || [ $CRITICAL != 0 ]; then | ||
+ | if [ $CONNECTIONS_ISCSI -gt $CRITICAL ] && [ $CRITICAL != 0 ]; then | ||
+ | STATE=$STATE_CRITICAL | ||
+ | elif [ $CONNECTIONS_ISCSI -gt $WARNING ] && [ $WARNING != 0 ]; then | ||
+ | STATE=$STATE_WARNING | ||
+ | else | ||
+ | STATE=$STATE_OK | ||
+ | fi | ||
+ | else | ||
+ | STATE=$STATE_OK | ||
+ | fi | ||
+ | DESCRIPTION=" | ||
+ | fi | ||
+ | elif [ $TYPE = " | ||
+ | # Controllers status (Usage : ./ | ||
+ | CONTROLLER_NUMBER=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_CONTROLLER_PRIMSEC}.${MEMBER_ID} | wc -l` | ||
+ | DESCRIPTION=" | ||
+ | if [ $CONTROLLER_NUMBER = 2 ]; then | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | else | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | fi | ||
+ | elif [ $TYPE = " | ||
+ | # Disks storage status (Usage : ./ | ||
+ | DISK_SLOT=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_DISK_ID}.${MEMBER_ID}.${DISK}` | ||
+ | DISK_TYPE=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_DISK_TYPE}.${MEMBER_ID}.${DISK}` | ||
+ | DISK_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_DISK_TOTAL}.${MEMBER_ID}.${DISK}` | ||
+ | DISK_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_DISK_STATUS}.${MEMBER_ID}.${DISK}` | ||
+ | DISK_TOTAL=`$CMD_EXPR $DISK_TOTAL \* 1048576` | ||
+ | case $DISK_TYPE in | ||
+ | 1) | ||
+ | DISK_TYPE_TEXT=" | ||
+ | ;; | ||
+ | 2) | ||
+ | DISK_TYPE_TEXT=" | ||
+ | ;; | ||
+ | *) | ||
+ | DISK_TYPE_TEXT=" | ||
+ | ;; | ||
+ | esac | ||
+ | VALUE=$DISK_TOTAL | ||
+ | size_convert | ||
+ | DISK_TOTAL=$VALUE | ||
+ | DESCRIPTION=" | ||
+ | case $DISK_STATUS in | ||
+ | 1) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | ;; | ||
+ | 2) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | ;; | ||
+ | 3) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | ;; | ||
+ | 4) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | ;; | ||
+ | 5) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | ;; | ||
+ | 6) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | ;; | ||
+ | 7) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | ;; | ||
+ | 8) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | ;; | ||
+ | *) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_UNKNOWN | ||
+ | ;; | ||
+ | esac | ||
+ | elif [ $TYPE = " | ||
+ | # Check fans RPM (Usage : ./ | ||
+ | DESCRIPTION=" | ||
+ | for FAN_ID in `$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_FAN_NAME} | $CMD_AWK '{ print $1}' | $CMD_AWK -F " | ||
+ | FAN_NAME=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_FAN_NAME}.${MEMBER_ID}.${FAN_ID} | $CMD_AWK -F '"' | ||
+ | FAN_VALUE=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_FAN_VALUE}.${MEMBER_ID}.${FAN_ID}` | ||
+ | DESCRIPTION=" | ||
+ | PERFORMANCE_DATA=" | ||
+ | done | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | elif [ $TYPE = " | ||
+ | # Check global system status (Usage : ./ | ||
+ | HEALTH_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_HEALTH_STATUS}.${MEMBER_ID}` | ||
+ | DESCRIPTION=" | ||
+ | case $HEALTH_STATUS in | ||
+ | 1) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | ;; | ||
+ | 2) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | ;; | ||
+ | 3) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | ;; | ||
+ | *) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_UNKNOWN | ||
+ | ;; | ||
+ | esac | ||
+ | elif [ $TYPE = " | ||
+ | # Information (Usage : ./ | ||
+ | MODEL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_MODEL}.${MEMBER_ID} | $CMD_AWK -F '"' | ||
+ | SERIALNUMBER=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_SERIALNUMBER}.${MEMBER_ID} | $CMD_AWK -F '"' | ||
+ | CONTROLLERS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_NUMBERCONTROLLERS}.${MEMBER_ID}` | ||
+ | DISKS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_NUMBERDISKS}.${MEMBER_ID}` | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | elif [ $TYPE = " | ||
+ | # Check I/O performance (Usage : ./ | ||
+ | IO_READ=`$CMD_SNMPGET -t 2 -r 2 -v 2c -c $COMMUNITY -Ovq $HOSTNAME ${OID_IO_READ}.${MEMBER_ID}` | ||
+ | IO_WRITE=`$CMD_SNMPGET -t 2 -r 2 -v 2c -c $COMMUNITY -Ovq $HOSTNAME ${OID_IO_WRITE}.${MEMBER_ID}` | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | elif [ $TYPE = " | ||
+ | # Check average latency (Usage : ./ | ||
+ | LATENCY_READ=`$CMD_SNMPGET -t 2 -r 2 -v 2c -c $COMMUNITY -Ovq $HOSTNAME ${OID_LATENCY_READ}.${MEMBER_ID}` | ||
+ | LATENCY_WRITE=`$CMD_SNMPGET -t 2 -r 2 -v 2c -c $COMMUNITY -Ovq $HOSTNAME ${OID_LATENCY_WRITE}.${MEMBER_ID}` | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | elif [ $TYPE = " | ||
+ | # Network interface status (Usage : ./ | ||
+ | NETWORK_IP=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_NETWORK_NAME}.${MEMBER_ID} | $CMD_GREP -i $NETWORK | $CMD_AWK ' | ||
+ | NETWORK_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_NETWORK_ID} | $CMD_GREP -i $NETWORK | $CMD_AWK '{ print $1}' | $CMD_AWK -F " | ||
+ | NETWORK_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_NETWORK_STATUS}.${NETWORK_ID}` | ||
+ | NETWORK_MTU=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_NETWORK_MTU}.${NETWORK_ID}` | ||
+ | NETWORK_SPEED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_NETWORK_SPEED}.${NETWORK_ID}` | ||
+ | NETWORK_SPEED=`$CMD_EXPR $NETWORK_SPEED / 1000000` | ||
+ | DESCRIPTION=" | ||
+ | if [ $NETWORK_STATUS = " | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | else | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | fi | ||
+ | DESCRIPTION=" | ||
+ | elif [ $TYPE = " | ||
+ | # Power supply status (Usage : ./ | ||
+ | DESCRIPTION=" | ||
+ | COMMA=", | ||
+ | for POWERSUPPLY_ID in 1 2; do | ||
+ | POWERSUPPLY_NAME=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_POWERSUPPLY_NAME}.${MEMBER_ID}.${POWERSUPPLY_ID} | $CMD_AWK -F '"' | ||
+ | POWERSUPPLY_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_POWERSUPPLY_STATUS}.${MEMBER_ID}.${POWERSUPPLY_ID}` | ||
+ | case $POWERSUPPLY_STATUS in | ||
+ | 1) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | ;; | ||
+ | 2) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | break | ||
+ | ;; | ||
+ | 3) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | break | ||
+ | ;; | ||
+ | *) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_UNKNOWN | ||
+ | break | ||
+ | ;; | ||
+ | esac | ||
+ | COMMA="" | ||
+ | done | ||
+ | elif [ $TYPE = " | ||
+ | # RAID status (Usage : ./ | ||
+ | RAID_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_RAID_STATUS}.${MEMBER_ID}` | ||
+ | DESCRIPTION=" | ||
+ | case $RAID_STATUS in | ||
+ | 1) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | ;; | ||
+ | 2) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | ;; | ||
+ | 3) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | ;; | ||
+ | 4) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | ;; | ||
+ | 5) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | ;; | ||
+ | 6) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_CRITICAL | ||
+ | ;; | ||
+ | 7) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_WARNING | ||
+ | ;; | ||
+ | *) | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_UNKNOWN | ||
+ | ;; | ||
+ | esac | ||
+ | elif [ $TYPE = " | ||
+ | # Check temperature (Usage : ./ | ||
+ | DESCRIPTION=" | ||
+ | for TEMPERATURE_ID in `$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_TEMPERATURE_NAME} | $CMD_AWK '{ print $1}' | $CMD_AWK -F " | ||
+ | TEMPERATURE_NAME=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_TEMPERATURE_NAME}.${MEMBER_ID}.${TEMPERATURE_ID} | $CMD_AWK -F '"' | ||
+ | TEMPERATURE_VALUE=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_TEMPERATURE_VALUE}.${MEMBER_ID}.${TEMPERATURE_ID}` | ||
+ | DESCRIPTION=" | ||
+ | PERFORMANCE_DATA=" | ||
+ | done | ||
+ | DESCRIPTION=" | ||
+ | STATE=$STATE_OK | ||
+ | elif [ $TYPE = " | ||
+ | # Disk usage (Usage : ./ | ||
+ | USAGE_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_USAGE_TOTAL}.${MEMBER_ID}` | ||
+ | USAGE_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_USAGE_USED}.${MEMBER_ID}` | ||
+ | USAGE_SNAPSHOTS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_USAGE_SNAPSHOTS}.${MEMBER_ID}` | ||
+ | USAGE_REPLICAS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_USAGE_REPLICAS}.${MEMBER_ID}` | ||
+ | |||
+ | if [ $USAGE_TOTAL != 0 ]; then | ||
+ | USAGE_TOTAL=`$CMD_EXPR $USAGE_TOTAL \* 1048576` | ||
+ | USAGE_USED=`$CMD_EXPR $USAGE_USED \* 1048576` | ||
+ | USAGE_SNAPSHOTS=`$CMD_EXPR $USAGE_SNAPSHOTS \* 1048576` | ||
+ | USAGE_REPLICAS=`$CMD_EXPR $USAGE_REPLICAS \* 1048576` | ||
+ | |||
+ | USAGE_USED_POURCENT=`$CMD_EXPR \( $USAGE_USED \* 100 \) / $USAGE_TOTAL` | ||
+ | USAGE_SNAPSHOTS_POURCENT=`$CMD_EXPR \( $USAGE_SNAPSHOTS \* 100 \) / $USAGE_TOTAL` | ||
+ | USAGE_REPLICAS_POURCENT=`$CMD_EXPR \( $USAGE_REPLICAS \* 100 \) / $USAGE_TOTAL` | ||
+ | |||
+ | PERFDATA_WARNING=0 | ||
+ | PERFDATA_CRITICAL=0 | ||
+ | |||
+ | if [ $WARNING != 0 ] || [ $CRITICAL != 0 ]; then | ||
+ | PERFDATA_WARNING=`$CMD_EXPR \( $USAGE_TOTAL \* $WARNING \) / 100` | ||
+ | PERFDATA_CRITICAL=`$CMD_EXPR \( $USAGE_TOTAL \* $CRITICAL \) / 100` | ||
+ | |||
+ | if [ $USAGE_USED_POURCENT -gt $CRITICAL ] && [ $CRITICAL != 0 ]; then | ||
+ | STATE=$STATE_CRITICAL | ||
+ | elif [ $USAGE_USED_POURCENT -gt $WARNING ] && [ $WARNING != 0 ]; then | ||
+ | STATE=$STATE_WARNING | ||
+ | else | ||
+ | STATE=$STATE_OK | ||
+ | fi | ||
+ | else | ||
+ | STATE=$STATE_OK | ||
+ | fi | ||
+ | |||
+ | VALUE=$USAGE_TOTAL | ||
+ | size_convert | ||
+ | USAGE_TOTAL_FORMAT=$VALUE | ||
+ | |||
+ | VALUE=$USAGE_USED | ||
+ | size_convert | ||
+ | USAGE_USED_FORMAT=$VALUE | ||
+ | |||
+ | DESCRIPTION=" | ||
+ | fi | ||
+ | elif [ $TYPE = " | ||
+ | # Volume status (Usage : ./ | ||
+ | VOLUME_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_VOLUME_NAME} | $CMD_GREP -i $VOLUME | $CMD_AWK ' | ||
+ | VOLUME_MEMBER_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_VOLUME_NAME} | $CMD_GREP -i $VOLUME | $CMD_AWK ' | ||
+ | VOLUME_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_VOLUME_STATUS}.${VOLUME_MEMBER_ID}.${VOLUME_ID}` | ||
+ | VOLUME_STORAGEPOOL_ID=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_VOLUME_STORAGEPOOL_ID}.${VOLUME_MEMBER_ID}.${VOLUME_ID}` | ||
+ | VOLUME_STORAGEPOOL_NAME=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_STORAGEPOOL_NAME}.${VOLUME_STORAGEPOOL_ID} | $CMD_AWK -F '"' | ||
+ | case $VOLUME_STATUS in | ||
+ | 1) | ||
+ | VOLUME_STATUS_DESC=" | ||
+ | ;; | ||
+ | 2) | ||
+ | VOLUME_STATUS_DESC=" | ||
+ | ;; | ||
+ | 3) | ||
+ | VOLUME_STATUS_DESC=" | ||
+ | ;; | ||
+ | 4) | ||
+ | VOLUME_STATUS_DESC=" | ||
+ | ;; | ||
+ | 5) | ||
+ | VOLUME_STATUS_DESC=" | ||
+ | ;; | ||
+ | *) | ||
+ | VOLUME_STATUS_DESC=" | ||
+ | ;; | ||
+ | esac | ||
+ | DESCRIPTION=" | ||
+ | VOLUME_TOTAL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_VOLUME_TOTAL}.${VOLUME_MEMBER_ID}.${VOLUME_ID}` | ||
+ | VOLUME_USED=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_VOLUME_USED}.${VOLUME_MEMBER_ID}.${VOLUME_ID}` | ||
+ | |||
+ | if [ $VOLUME_TOTAL != 0 ]; then | ||
+ | VOLUME_TOTAL=`$CMD_EXPR $VOLUME_TOTAL \* 1048576` | ||
+ | VOLUME_USED=`$CMD_EXPR $VOLUME_USED \* 1048576` | ||
+ | VOLUME_USED_POURCENT=`$CMD_EXPR \( $VOLUME_USED \* 100 \) / $VOLUME_TOTAL` | ||
+ | PERFDATA_WARNING=0 | ||
+ | PERFDATA_CRITICAL=0 | ||
+ | |||
+ | if [ $WARNING != 0 ] || [ $CRITICAL != 0 ]; then | ||
+ | PERFDATA_WARNING=`$CMD_EXPR \( $VOLUME_TOTAL \* $WARNING \) / 100` | ||
+ | PERFDATA_CRITICAL=`$CMD_EXPR \( $VOLUME_TOTAL \* $CRITICAL \) / 100` | ||
+ | |||
+ | if [ $VOLUME_USED_POURCENT -gt $CRITICAL ] && [ $CRITICAL != 0 ]; then | ||
+ | STATE=$STATE_CRITICAL | ||
+ | elif [ $VOLUME_USED_POURCENT -gt $WARNING ] && [ $WARNING != 0 ]; then | ||
+ | STATE=$STATE_WARNING | ||
+ | else | ||
+ | STATE=$STATE_OK | ||
+ | fi | ||
+ | else | ||
+ | STATE=$STATE_OK | ||
+ | fi | ||
+ | |||
+ | VALUE=$VOLUME_TOTAL | ||
+ | size_convert | ||
+ | VOLUME_TOTAL_FORMAT=$VALUE | ||
+ | |||
+ | VALUE=$VOLUME_USED | ||
+ | size_convert | ||
+ | VOLUME_USED_FORMAT=$VALUE | ||
+ | |||
+ | DESCRIPTION=" | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | echo $DESCRIPTION | ||
+ | exit $STATE | ||
+ | </ | ||
+ | ==== check_snmp_dell_vrtx ==== | ||
+ | < | ||
+ | #! /bin/bash | ||
+ | # Desc : Plugin to verify status DELL VRTX | ||
+ | # List check: INFO, CPU, DET-MEM, STATE-MEM, NAME-DISK, STATE-DISK, NAME-VDISK, STATE-VDISK, | ||
+ | |||
+ | COM=$2 | ||
+ | IP=$1 | ||
+ | CHECK=$3 | ||
+ | |||
+ | ################################### | ||
+ | #1. Device Info | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.1.3.12.0 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #2. Check CPU | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.200.10.1.50.1 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #3. Memory Detail | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.1100.50.1.14.1 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.200.10.1.27.1 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #4. Check Physical Disk | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.55 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.24 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #5. Check Virtual Disk | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1.36 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1.20 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #6. Battery Detail | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.600.50.1.7.1 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.600.50.1.5.1 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #7. Power Supply Detail | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.600.12.1.15.1 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.600.50.1.5.1 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #8. Fan Detail | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.600.12.1.15.1 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.600.50.1.5.1 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.4.700.12.1.6.1 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #9. Check Disk Controller | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1.2 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1.38 | grep -oE ' | ||
+ | fi | ||
+ | |||
+ | ################################### | ||
+ | #10. Temperature Celsius | ||
+ | ################################### | ||
+ | if [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1.2 | grep -oE ' | ||
+ | elif [[ $CHECK == " | ||
+ | then | ||
+ | snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1.38 | grep -oE ' | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_bdd_on_cluster ==== | ||
+ | < | ||
+ | # | ||
+ | ############################################ | ||
+ | # Script pour verifier les BDD en cluster | ||
+ | # Qu' | ||
+ | # By adex036137 | ||
+ | ############################################ | ||
+ | |||
+ | # Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug) | ||
+ | #set -x | ||
+ | |||
+ | # On suprime l' | ||
+ | rm -f '/ | ||
+ | |||
+ | # Les variables | ||
+ | WARN=$1 | ||
+ | for VAR in $3 | ||
+ | do | ||
+ | BDD=$VAR | ||
+ | COMM=$2 | ||
+ | HOST1=$4 | ||
+ | HOST2=${5: | ||
+ | HOST3=${6: | ||
+ | HOST4=${7: | ||
+ | HOST5=${8: | ||
+ | |||
+ | # Recherche BDD sur 1ere machine | ||
+ | RESULT=`snmpwalk -c $COMM -v 2c $HOST1 HOST-RESOURCES-MIB:: | ||
+ | # Recherche BDD sur 2eme machine | ||
+ | RESULT2=`snmpwalk -c $COMM -v 2c $HOST2 HOST-RESOURCES-MIB:: | ||
+ | # Recherche BDD sur 3eme machine | ||
+ | RESULT3=`snmpwalk -c $COMM -v 2c $HOST3 HOST-RESOURCES-MIB:: | ||
+ | # Recherche BDD sur 4eme machine | ||
+ | RESULT4=`snmpwalk -c $COMM -v 2c $HOST4 HOST-RESOURCES-MIB:: | ||
+ | # Recherche BDD sur 5eme machine | ||
+ | RESULT5=`snmpwalk -c $COMM -v 2c $HOST5 HOST-RESOURCES-MIB:: | ||
+ | |||
+ | # Check des resultats | ||
+ | if [[ " | ||
+ | then | ||
+ | echo " | ||
+ | elif [[ " | ||
+ | then | ||
+ | echo " | ||
+ | elif [[ " | ||
+ | then | ||
+ | echo " | ||
+ | elif [[ " | ||
+ | then | ||
+ | echo " | ||
+ | elif [[ " | ||
+ | then | ||
+ | echo " | ||
+ | # Autres resultats | ||
+ | else | ||
+ | echo " | ||
+ | fi | ||
+ | done | ||
+ | |||
+ | # Tri des resultats et remonte des alertes | ||
+ | TRI=$(cat / | ||
+ | DUPL=`cat / | ||
+ | if [[ " | ||
+ | then | ||
+ | sort -u "/ | ||
+ | exit 2 | ||
+ | elif [[ " | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | else | ||
+ | sort -u "/ | ||
+ | exit 0 | ||
+ | fi | ||
+ | </ | ||
+ | ==== backup_veeam ==== | ||
+ | < | ||
+ | # | ||
+ | set -x | ||
+ | |||
+ | |||
+ | cd / | ||
+ | |||
+ | HOST=$1 | ||
+ | CHECK=$2 | ||
+ | TIME=$3 | ||
+ | |||
+ | RESULT=$( ./ | ||
+ | # Si OK | ||
+ | if [[ $RESULT = ' | ||
+ | then | ||
+ | echo "OK au moins 1 backup lors des 48 dernieres heures" | ||
+ | exit 0 | ||
+ | fi | ||
+ | |||
+ | RESULT=$( ./ | ||
+ | # Si Warning | ||
+ | if [[ $RESULT = ' | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | RESULT=$( ./ | ||
+ | # Si critique | ||
+ | if [[ $RESULT = ' | ||
+ | then | ||
+ | echo "KO aucun backup depuis plus de 48h" | ||
+ | exit 2 | ||
+ | fi | ||
+ | </ | ||
+ | ==== backup_veeam2 ==== | ||
+ | < | ||
+ | # | ||
+ | #set -x | ||
+ | |||
+ | |||
+ | cd / | ||
+ | |||
+ | HOST=$1 | ||
+ | CHECK=$2 | ||
+ | TIME=$3 | ||
+ | |||
+ | |||
+ | RESULT=$( ./ | ||
+ | # Si OK | ||
+ | if [[ $RESULT = ' | ||
+ | then | ||
+ | echo "OK au moins 1 backup lors des 48 dernieres heures" | ||
+ | exit 0 | ||
+ | fi | ||
+ | |||
+ | RESULT=$( ./ | ||
+ | # Si critique | ||
+ | if [[ $RESULT = " | ||
+ | then | ||
+ | echo "KO aucun backup depuis plus de 48h" | ||
+ | fi | ||
+ | exit 2 | ||
+ | |||
+ | |||
+ | RESULT=$( ./ | ||
+ | # Si Warning | ||
+ | if [[ $RESULT = ' | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_vs-certif_f5 ==== | ||
+ | < | ||
+ | # | ||
+ | # set -x | ||
+ | # Variable | ||
+ | HOST=$1 | ||
+ | URL=${2: | ||
+ | COM=${3: | ||
+ | VER=${4: | ||
+ | |||
+ | |||
+ | # On recupere l'id de l' | ||
+ | OID=$(snmpwalk -c $COM -v $VER $HOST .1.3.6.1.4.1.3375.2.1.15.1.2.1.1 | grep $2 | awk ' | ||
+ | |||
+ | # On recupere le temps restant | ||
+ | TMP=$(snmpwalk -c $COM -v $VER $HOST 1.3.6.1.4.1.3375.2.1.15.1.2.1.5 | grep $OID | awk ' | ||
+ | |||
+ | # Calcul entre la date actuelle et la date du certif. RESULT= date unix convertie en date lisible. | ||
+ | TODAY=$(date +%s) | ||
+ | RESULT=$(date -d @$TMP +' | ||
+ | DIFF=$(echo " | ||
+ | |||
+ | # Si pas de retour | ||
+ | if [[ -z $OID ]] | ||
+ | then | ||
+ | echo " | ||
+ | exit 3 | ||
+ | |||
+ | # Si moins de 15 jours | ||
+ | elif [[ " | ||
+ | then | ||
+ | echo " | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si moins de 30 jours | ||
+ | if [[ " | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | # Si OK | ||
+ | else | ||
+ | echo "OK $URL expire le $RESULT" | ||
+ | exit 0 | ||
+ | fi | ||
+ | </ |