Outils pour utilisateurs

Outils du site


Writing /app/www/public/data/meta/centreon/scripts-linux.meta failed
centreon:scripts-linux

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
centreon:scripts-linux [2023/07/05 10:33] michelcentreon: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 ====
-   #!/bin/bash +<code> 
-   ########################################################################################## +#!/bin/bash 
-   # Ajout de la ligne de commande pour nrpe dans: /etc/nagios/nrpe.d/check_A335_backup.cfg # +########################################################################################## 
-   # command[check_A335_backup]=/usr/lib/nagios/plugins/check_A335_backup.sh                # +# Ajout de la ligne de commande pour nrpe dans: /etc/nagios/nrpe.d/check_A335_backup.cfg # 
-   ########################################################################################## +# command[check_A335_backup]=/usr/lib/nagios/plugins/check_A335_backup.sh                # 
-   # Deplacement vers le dossier de recherche +########################################################################################## 
-   cd /mariadb/backup/log/ +# Deplacement vers le dossier de recherche 
-   # Recherche du fichier le + récent +cd /mariadb/backup/log/ 
-   VAR1=$(ls -t | head -n1) + 
-   # Recherche du mot pour OK +# Recherche du fichier le + récent 
-   VAR4=$(grep 'completed OK!' $VAR1) +VAR1=$(ls -t | head -n1) 
-   # Check fichier plus de 1 jour + 
-   if [[ $(find "$VAR1" -mtime +1 -print) ]]; then +# Recherche du mot pour OK 
-   echo "Log du jour absent" +VAR4=$(grep 'completed OK!' $VAR1) 
-   fi + 
-   #Vérif si retour recherche vide +# Check fichier plus de 1 jour 
-   if [[ -z  $VAR4  ]]; then +if [[ $(find "$VAR1" -mtime +1 -print) ]]; then 
-   echo "Backup KO" +echo "Log du jour absent" 
-   fi +fi 
-   # Si fichier OK et backup OK alors OK + 
-   if [ -n "$VAR4" ] ; then +#Vérif si retour recherche vide 
-   echo "Backup et fichier log OK" +if [[ -z  $VAR4  ]]; then 
-   exit 0 +echo "Backup KO" 
-   fi +fi 
-   # Envois du resultat à Centreon + 
-   while read line; do echo $line; done +# Si fichier OK et backup OK alors OK 
-   exit 2 +if [ -n "$VAR4" ] ; then 
-   ###################################### +echo "Backup et fichier log OK" 
-   # Rendre le fichier executable       # +exit 0 
-   # chmod +x check_A335_backup.sh      # +fi 
-   # Pensez à redémarre le service      # + 
-   # service nagios-nrpe-server restart # +# 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 # 
 +###################################### 
 +</code>
 ====  check_by_ssh_erreurs_badgeuses.sh ==== ====  check_by_ssh_erreurs_badgeuses.sh ====
-   #!/bin/bash +<code> 
-   #set -x +#!/bin/bash 
-   HOST=$1 +#set -x 
-   COMMAND=$(ssh -t -i /usr/lib64/nagios/plugins/.ssh/id_rsa_badg opteama@$HOST '{ sleep 10; echo "i tr"; sleep 10; } | axsh | grep "TO SEND"' | cut -c 15-15) +HOST=$1 
-   #echo $COMMAND + 
-   OUT=$?+COMMAND=$(ssh -t -i /usr/lib64/nagios/plugins/.ssh/id_rsa_badg opteama@$HOST '{ sleep 10; echo "i tr"; sleep 10; } | axsh | grep "TO SEND"' | cut -c 15-15) 
 +#echo $COMMAND 
 + 
 +OUT=$?
     if [ $OUT -eq 1 ]     if [ $OUT -eq 1 ]
     then     then
Ligne 70: Ligne 81:
         exit 0         exit 0
     fi     fi
 +</code>
 +==== Check_Certfif_asa ====
 +<code>
 +#!/bin/bash
 +
 +#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'alerte Centreon ( 0: rien , 1: Warning, 2: Critical)
 +sortie=0
 +
 +
 +#convertir le mois de l'annee en lettre à chiffre
 +#Le parametre à passer doit etre de la forme de la liste MONTH (ex: Jan)
 +mois_chiffre() {
 +
 +        local i=0
 +        local len=${#MONTH[@]}
 +        while [ $i -lt $len ];
 +        do
 +                if [[ "$1" == "${MONTH[$i]}" ]]
 +                then
 +                        let i++
 +                        echo "$i"
 +                        break
 +                fi
 +                let i++
 +
 +        done
 +}
 +
 +#verifie l'etat du status
 +#mettre en parametre le status (ex: "Available")
 +check_status() {
 +
 +        stat=`echo $1 | cut -c 1-9`
 +        if [[ "$stat" != "Available" ]]
 +        then
 +                sortie=2
 +
 +        fi
 +}
 +
 +#permet de creer et de renvoyer la variable date du certificat
 +#mettre les parametres dans l'ordre suivant : year month(lettre) day
 +create_cert_date() {
 +        local mois=$(mois_chiffre $2)
 +        edate=$(date -d $1-$mois-$3 +"%Y%m%d")
 +        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
 +        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 << 'EOF' | tee "/usr/lib64/nagios/plugins/cisco_asa_show_crypto/output$HOSTNAME.txt" &> /dev/null
 +enable
 +2k3zX4bV9i4hNaHl
 +conf t
 +pager 0
 +end
 +show crypto ca certificates
 +exit
 +EOF
 +
 +
 +while read line; do
 +        #echo $line
 +        eval ARRAY=(`echo $line`)
 +        #echo ${ARRAY[0]}
 +
 +
 +
 +        #Trustpoints
 +        if [[ ${ARRAY[0]} == "Associated" ]]
 +        then
 +                assos=${ARRAY[2]}
 +                #CRITICAL : date du certificat inferieur a 15 jours
 +                if [[ "$delta_date" -lt 15 ]]
 +                then
 +                        echo "CRITICAL $stat $delta_date $assos"
 +                        sortie=2
 +
 +                #WARNING: date du certificat inferieur a 30 jours
 +                elif [[ "$delta_date" -lt 30 ]]
 +                then
 +                        echo "WARNING $stat $delta_date $assos"
 +
 +                        if [[ "$sortie" -ne 2 ]]
 +                        then
 +                                sortie=3
 +                        fi
 +                fi
 +
 +        fi
 +
 +
 +        #Status
 +        if [[ ${ARRAY[0]} == "Status:" ]]
 +        then
 +                check_status ${ARRAY[1]} $assos
 +        fi
 +
 +        #End Date
 +        if [[ ${ARRAY[0]} == "end" ]]
 +        then
 +                end_jour=`echo ${ARRAY[5]} | cut -c 1-2`
 +                end_mois=`echo ${ARRAY[4]} | cut -c 1-3`
 +                end_annee=`echo ${ARRAY[6]} | cut -c 1-4`
 +                end_date=`create_cert_date $end_annee $end_mois $end_jour`
 +                delta_date=`compare_date $end_date $NOW`
 +                #echo "Jours restant avant expiration du certificat : $delta_date"
 +        fi
 +
 +done <<< "$(grep -e ^"CA Certificate" -e  ^"Certificate" -e "end   date:" -e "Associated" -e "Status:" /usr/lib64/nagios/plugins/cisco_asa_show_crypto/output$HOSTNAME.txt)"
 +
 +rm -f /usr/lib64/nagios/plugins/cisco_asa_show_crypto/output$HOSTNAME.txt
 +
 +#Les certificats sont bons ou il n'y en a pas, on renvoie un output pour Centreon
 +if [[ $sortie -eq 0 ]]
 +then
 +        echo "Certificat(s) OK"
 +fi
 +
 +
 +exit $sortie
 +</code>
 +==== check_dispo_sla.sh ====
 +<code>
 +#!/bin/bash
 +
 +#suppress error outputs
 +
 +
 +#try to read vars from file, for windows and tests purpose
 +if [ -f ./centreon_conf_local.bash ] ; then
 +    . ./centreon_conf_local.bash
 +fi
 +
 +#set default JQ value should be OK on linux if jq is installed
 +JQ=${JQ:-"jq"}
 +
 +#debug defincition for execution traces
 +CENTREON_DEBUG=${CENTREON_DEBUG:-0}
 +
 +#regexp used for host
 +CENTREON_HOST_REGEXP=${3:-P-A389-CENS}
 +CENTREON_HOST_REGEXP=${CENTREON_HOST_REGEXP// /%20}
 +#regexp used for service
 +CENTREON_SVC_REGEXP=${4:-CANADA}
 +CENTREON_SVC_REGEXP=${CENTREON_SVC_REGEXP// /%20}
 +#centreon url
 +CENTREON_URL="${5:-https://p-a389-vipp-001.mycorp.corp}"
 +
 +CENTREON_LOGIN=${1:-userapi_1}
 +CENTREON_PASSWORD=${2:-Userapi1}
 +
 +#query centreon token
 +TOKEN_QUERY_DATA="{\"security\": {\"credentials\": {\"login\": \"$CENTREON_LOGIN\",\"password\": \"$CENTREON_PASSWORD\""
 +CENTREON_TOKEN=`curl -s -k -X POST -d "$TOKEN_QUERY_DATA" -H "Content-Type: application/json" -X POST $CENTREON_URL/centreon/api/beta/login |  $JQ -s '.[0].security.token' | tr -d \" | sed -e "s/[\"\r]//g"  `
 +
 +#query used to request sstates
 +CENTREON_QUERY="\{\"\$and\":\[\{\"service.description\":\{\"\$lk\":\"%$CENTREON_SVC_REGEXP%\"\}\},\{\"host.name\":\{\"\$lk\":\"%$CENTREON_HOST_REGEXP%\"\\\]\"
 +
 +#function to request data, was more complex at the beginning
 +centreon_request() {
 +    # warning at the limit, no High availability with more than 50 instance
 +    curl -s -k -H "X-AUTH-TOKEN: ${CENTREON_TOKEN}" -H "Content-Type: application/json" -X GET "${CENTREON_URL}/centreon/api/beta/monitoring/services?search=$1&limit=50"
 +}
 +
 +#print values used for execution
 +if [ "$CENTREON_DEBUG" == "1" ]; then
 +    echo JQ: $JQ
 +    echo centreon_query: $CENTREON_QUERY
 +    echo centreon_token: $CENTREON_TOKEN
 +else
 +    exec 2>/dev/null
 +fi
 +
 +
 +#print query
 +if [ "$CENTREON_DEBUG" == "1" ]; then
 +    echo request for $CENTREON_QUERY
 +fi
 +
 +# request data
 +state=`centreon_request ${CENTREON_QUERY}`
 +
 +#show status codes
 +if [ "$CENTREON_DEBUG" == "1" ]; then
 +    echo Results
 +    echo $state | $JQ  -r ".result | .[].status.code "
 +fi
 +
 +
 +# use a service group for that
 +# compute result which is addition of all status code
 +# result=`echo $state | $JQ  -r ".result | .[].status.code" | $JQ -s 'add' | tr -d \" | sed -e 's/[\r ]//g'`
 +
 +# compute result which is mulitplication of all status code
 +values=`echo $state | $JQ  -r ".result | .[].status.code" | tr -d \" | sed -e 's/\r//g' `
 +result=1
 +for i in $values; do
 +    # echo "result * i : $r * $i"
 +    result=$((result*i))
 +    # echo ">> $r"
 +done
 +
 +# result=`echo $state | $JQ  -r ".result | .[].status.code" | $JQ -s 'add' | tr -d \" | sed -e 's/[\r ]//g'`
 +
 +if [[ "$result" == "" ]] ; then
 +    AGGREGATION_OUPUT=3
 +    comment="Unknown: Probe Not runned properly"
 +elif [[ $result == 0 ]] ; then
 +    AGGREGATION_OUPUT=0
 +    comment="OK: Nominal State"
 +else
 +    AGGREGATION_OUPUT=2
 +    comment="Critical: Non Nominal State"
 +fi
 +
 +if [ "$CENTREON_DEBUG" == "1" ]; then
 +    echo AGGREGATION_OUPUT: $AGGREGATION_OUPUT
 +fi
 +
 +echo $comment"|"
 +centreon_details=`echo $state | $JQ  -cr ".result | map( {host:.host.name, service:.description, status:.status.name,} ) " | sed -e "s/[}],/},\n/g"`
 +for detail in "${centreon_details[@]}" ; do
 +    echo "$detail"
 +done
 +
 +exit $AGGREGATION_OUPUT
 +</code>
 +==== check_file_age ====
 +<code>
 +#! /bin/sh
 +#Si un fichier .runnning est présent depuis plus de 4h, on alerte
 +for f in `ls /var/BA/rsync_script/*running 2>/dev/null`
 +do
 +        FILECHANGE=`stat --printf=%Y $f`
 +        CURRENTDATE=`date +%s`
 +        FILEAGE=$((CURRENTDATE-FILECHANGE))
 +        if [ $FILEAGE -gt 28800 ]
 +        then
 +                echo "CRITICAL - fichier de lock $f présent depuis plus de 2 jours !!!"
 +                exit 2
 +        elif [ $FILEAGE -gt 14400 ]
 +        then
 +                echo "WARNING - fichier de lock $f présent depuis plus d'une journee"
 +                exit 1
 +        fi
 +done
 +echo "OK - Rsync OK"
 +exit 0
 +</code>
 +==== check_file_exist ====
 +<code>
 +#! /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 's,[\\/][^\\/][^\\/]*$,,'`
 +
 +. $PROGPATH/utils.sh
 +
 +if [ "$1" = "" ]
 +then
 + echo -e " Use : $PROGNAME <file_name> -- Ex : $PROGNAME /etc/hosts \n "
 + 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 "CRITICAL : $1 Does NOT exists "
 + exit $STATE_CRITICAL
 +fi
 +</code>
 +==== check_gateway_lora ====
 +<code>
 +#!/bin/bash
 +# Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug)
 +set -x
 +
 +# On definit les variables
 +
 +# curl
 +CURL="/usr/bin/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 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: application/json' -d 'grant_type=client_credentials&client_id=tpe-api/ml-operations@stelia-aerospace.com&client_secret=PASS=12hours'  https://lorawan.opteama.stelia.aero/thingpark/dx/admin/latest/api/oauth/token  | grep -oE '"access_token":.*' | awk '{ split($1,a,/"/); print a[4] }'`
 +
 +# La variable si dessous recupere le ref de la gateway
 +REF=`$CURL -s -k -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer '$TOKEN'' https://lorawan.opteama.stelia.aero/thingpark/dx/core/latest/api/baseStations | egrep -o '.*:"'$HOST'"' | awk -F '"' '{print $(NF-13)}'`
 +
 +# La variable si dessous donne les resultats de l'etat
 +RESULT=`$CURL -s -k -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer '$TOKEN'' https://lorawan.opteama.stelia.aero/thingpark/dx/core/latest/api/baseStations/$REF | json_pp -json_opt pretty,canonical | egrep -o '"administrationState" : .*|"connectionState" : .*|"healthState" : .*' | tr -d '\n' | cut -d '"' -f4,8,12`
 +
 +# Alertes suivant les retour
 +# Details 'etat adin, etat connexion, etat status'
 +# Critique = 'ACTIVE"DISC"ACTIVE'
 +# Warning = 'ACTIVE"NEVERCNX"ACTIVE'
 +# OK = 'ACTIVE"CNX"ACTIVE'
 +# autre = 'Unknown response from plugin'
 +
 +# Si critique
 +if [[ $RESULT = 'ACTIVE"DISC"ACTIVE' ]]
 +then
 +echo "KO Gateway is Critical"
 +exit 2
 +fi
 +
 +# Si warning
 +if [[ $RESULT = 'ACTIVE"NEVERCNX"ACTIVE' ]]
 +then
 +echo "KO Gateway is Warning"
 +exit 3
 +fi
 +</code>
 +==== check_ilo_hp ====
 +<code>
 +# Get Token
 +#! /bin/bash
 +# Desc : Plugin to verify Ilo status on HP-OneView
 +# checks possible: server-hardware, server-profiles,
 +
 +# Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug)
 +#set -x
 +
 +# On suprime l'ancien fichier texte si il existe
 +rm -f "/usr/lib64/nagios/plugins/hp-oneview/$1-result.txt"
 +
 +# Variables
 +RESULT="/usr/lib64/nagios/plugins/hp-oneview/$1-result.txt"
 +HOST=$1
 +CHECK=$2
 +TOKEN=$(cat "$1-token.txt")
 +
 +# Check token and renew if necessary
 +CHECKTOKEN=$(curl -s -k -H 'accept: application/json' -H 'content-type: application/json' -H "auth: $TOKEN" -X PUT https://$HOST/rest/login-sessions  | jq -r '.sessionID')
 +
 +if [[ $CHECKTOKEN = "$TOKEN" ]]
 +then
 +TOKEN="$CHECKTOKEN"
 +
 +elif [[ $CHECKTOKEN != "$TOKEN" ]]
 +then
 +NEWTOKEN=$(curl -s -k -H 'accept: application/json' -H 'content-type: application/json' -d '{"userName":"sacentmoni","password":"M0n1toring1234"}' -X POST https://$HOST/rest/login-sessions | jq -r ".sessionID")
 +TOKEN="$NEWTOKEN"
 +fi
 +
 +# Ecriture du token dans le fichier text
 +echo $TOKEN > "/usr/lib64/nagios/plugins/hp-oneview/$1-token.txt"
 +
 +# On recupere la  liste des résultats
 +curl -s -k -H 'accept: application/json' -H 'content-type: application/json' -H "auth: $TOKEN" -X GET https://$HOST/rest/$CHECK  | jq -r '.members[] | "\(.status),\(.name),\(.state)"' >> "/usr/lib64/nagios/plugins/hp-oneview/$1-result.txt"
 +
 +# Variables resultats
 +CRITICAL=`grep "Critical" "$RESULT"`
 +WARNING=`grep "Warning" "$RESULT"`
 +OK=`grep "^OK" "$RESULT"`
 +
 +if [[ "$CRITICAL" != "" ]]
 +then
 +echo -e "$CRITICAL"'\n'"$WARNING"'\n'"$OK"
 +exit 2
 +
 +# Si warning
 +elif  [[ "$WARNING" != "" ]]
 +then
 +echo -e "$WARNING"'\n'"$OK"
 +exit 1
 +
 +# Si OK
 +else
 +echo "$OK"
 +exit 0
 +fi
 +</code>
 +==== check_ntp_stratum ====
 +<code>
 +#!/bin/bash
 +STATE_OK=0          # define the exit code if status is OK
 +STATE_WARNING=1     # define the exit code if status is Warning
 +STATE_CRITICAL=2    # define the exit code if status is Critical
 +STATE_UNKNOWN=3     # define the exit code if status is Unknown
 +STATE=""
 +STATUS=(OK WARNING CRITICAL UNKNOWN)
 +
 +set -e
 +
 +##########
 +## MAIN ##
 +##########
 +# Process user-provided parameters
 +while getopts "H:s:" OPT;
 +do
 +    case ${OPT} in
 +    H)    HOST=${OPTARG};;
 +    s)    EXPECTED_STRATUM=${OPTARG};;
 +    \?)
 +        echo ""
 +        echo "Please use options -H for hostname"
 +        echo "-s for exptected stratum"
 +        echo ""
 +        exit ${STATE_UNKNOWN}
 +        ;;
 +    esac
 +done
 +
 +if [ -z "$CRIT_THRESHOLD" ]; then
 + CRIT_THRESHOLD=2
 +fi
 +
 +#Debug
 +#set -x
 +
 +STRATUM=$(ntpq -c readlist $HOST | grep -Eo 'stratum=[0-9]*' | grep -Eo '[0-9]*')
 +
 +if [ -z "$STRATUM" ]; then
 + echo "Unable to get sysinfo from $HOST"
 + exit ${STATE_UNKNOWN}
 +fi
 +
 +if [ "$STRATUM" -eq "16" ]; then
 + STATE=1
 +elif [ "$STRATUM" -ne "$EXPECTED_STRATUM" ]; then
 + STATE=2
 +else
 + STATE=0
 +fi
 +
 +echo "${STATUS[$STATE]} Stratum $STRATUM - Exptected Stratum : $EXPECTED_STRATUM"
 +exit $STATE
 +</code>
 +==== check_netapp_lun_size ====
 +<code>
 +#! /bin/bash
 +# Desc : Plugin to verify LUN size on NETAPP
 +# admin:C1sc0123
 +# To get lun's uuid:
 +# curl -s -k -u admin:C1sc0123 -X GET 'https://P-NTAP-CLU-010.infra.aerolia.corp/api/storage/luns?status.state=online' -H 'accept: application/hal+json' | grep -oE '"uuid":.*|"name":.*'
 +
 +# 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://"$HOST"/api/storage/luns/"$LUN"?fields=** -H 'accept: application/hal+json' | grep -oE '"size":.*|"used":.*' | tr -d '\n' | awk '{$2=$2/(1024^3); $3=$3/(1024^3);print "USED:",$3,"GB","_ TOTAL:",$2,"GB"}')
 +
 +# On coupe le resultat pour garder le used
 +TOTAL=`echo $RESULT | awk '{split($2,a,"."); print a[1]}'`
 +
 +# On coupe le resultat pour garder le total multiplie par la variable pourcentage mise sans la commande pour definir les seuils d'alertes
 +WARN=`echo $RESULT | awk '{split($6,a,"."); print a[1]*'$ALERT'/100}' | cut -d "." -f1`
 +CRIT=`echo $RESULT | awk '{split($6,a,"."); print a[1]*'$HAUT'/100}' | cut -d "." -f1`
 +
 +# Si critique
 +if [[ $TOTAL -gt "$CRIT" ]]
 +then
 +echo "LUN Usage is CRITICAL: $RESULT"
 +exit 2
 +fi
 +
 +# Si warning
 +if  [[ $TOTAL -gt "$WARN" ]]
 +then
 +echo "LUN Usage is Warning: $RESULT"
 +exit 1
 +
 +
 +# Si OK
 +else
 +echo "LUN Usage is OK: $RESULT"
 +fi
 +</code>
 +==== check_netapp_volume ====
 +<code>
 +#Faire un service 
 +
 +#/opt/netapp-api-exporter/netapp-api-exporter_linux_amd64 -c /opt/netapp-api-exporter/netapp-filers.yaml -l 127.0.0.1 -v 5m  --no-aggregate --no-system
 +# Desc : Plugin to verify volume size on NETAPP
 +
 +# Pour lister les volumes sur le Vfilers
 +# curl -s http://127.0.0.1:9108/metrics | grep 'P-NTAP-CLU-001' | grep -oE 'netapp_volume_total_bytes.*' | grep -oE '.*p-vf-airbus-02.*' | grep -oE 'volume=.*'| cut -d '"' -f2
 +
 +# Decommentez la ligne ci-dessous pour debug
 +# set -x
 +
 +# Variables
 +CLU=$1
 +VFL=$2
 +VOL=$3
 +WARN=$4
 +CRIT=$5
 +
 +RESULT=$(curl -s http://127.0.0.1:9108/metrics | grep -oE 'netapp_volume_used_percentage.*' |  grep '.*'$CLU'.*' | grep -oE '.*'$VFL'.*' | grep -oE ''$VOL'.*' | awk '{ split($0,a,/"/); print "Volume", a[1],"Used",$2,"%" }')
 +TOTAL=$(curl -s http://127.0.0.1:9108/metrics | grep -oE 'netapp_volume_total_bytes.*' | grep '.*'$CLU'.*' | grep -oE '.*'$VFL'.*' | grep -oE ''$VOL'.*' | awk '{ split($0,a,/"/); print "Volume", a[1],"Used",$2,"%" }' | awk '{ split($4,a,/e/); print a[1]*100,"GB"}')
 +PRCT=`echo "$RESULT" | awk '{print $4}'`
 +
 +# Si critique
 +if [[ $PRCT -gt "$CRIT" ]]
 +then
 +echo "Volume Usage is CRITICAL: $RESULT de $TOTAL"
 +exit 2
 +
 +# Si warning
 +elif  [[ $PRCT -gt "$WARN" ]]
 +then
 +echo "Volume Usage is Warning: $RESULT de $TOTAL"
 +exit 1
 +
 +# Si pas de résultat unknown
 +elif  [[ -z $PRCT  ]]
 +then
 +echo "No response from plugin"
 +exit 3
 +
 +# Si OK
 +else
 +echo "Volume Usage is OK: $RESULT de $TOTAL"
 +fi
 +</code>
 +==== check_netapp_vfiler ====
 +<code>
 +#! /bin/bash
 +# Desc : Plugin to verify volume size on NETAPP
 +
 +# Decommentez la ligne ci-dessous pour debug
 +#set -x
 +
 +# On suprime l'ancien fichier texte si il existe
 +rm -f /usr/lib64/nagios/plugins/NETAPP-VFILER/$2.txt
 +rm -f /usr/lib64/nagios/plugins/NETAPP-VFILER/$2-result.txt
 +rm -f /usr/lib64/nagios/plugins/NETAPP-VFILER/$2-vol.txt
 +# Variables
 +CLU=$1
 +VFL=$2
 +WARN=$3
 +CRIT=$4
 +PERFO_FILE=/usr/lib64/nagios/plugins/NETAPP-VFILER/$VFL-result.txt
 +Volume=/usr/lib64/nagios/plugins/NETAPP-VFILER/$VFL-vol.txt
 +
 +# On recupere la  liste des volumes sur le Vfilers
 +curl -s http://127.0.0.1:9108/metrics > /usr/lib64/nagios/plugins/NETAPP-VFILER/$VFL-vol.txt
 +cat $Volume | grep '.*'$CLU'.*' | grep -oE 'netapp_volume_total_bytes.*' | grep -oE '.*'$VFL'.*' | grep -oE 'volume=.*'| cut -d '"' -f2 >> /usr/lib64/nagios/plugins/NETAPP-VFILER/$VFL.txt
 +
 +while read VOL;
 +do
 +  RESULT=$(cat $Volume | grep -oE 'netapp_volume_used_percentage.*' |  grep '.*'$CLU'.*' | grep -oE '.*'$VFL'.*' | grep -oE ''$VOL'\".*' | awk '{ split($0,a,/"/); print "Volume", a[1],"Used",$2,"%" }')
 +  TOTAL=$(cat $Volume | grep -oE 'netapp_volume_total_bytes.*' | grep '.*'$CLU'.*' | grep -oE '.*'$VFL'.*' | grep -oE ''$VOL'\".*' | awk '{ split($0,a,/"/); print "Volume", a[1],"Used",$2,"%" }' | awk '{ split($4,a,/e/); print a[1]*100,"GB"}')
 +  PRCT=`echo "$RESULT" | awk '{print $4}'`
 +
 +# Si critique
 +  if [[ $PRCT -gt "$CRIT" ]]
 +    then
 +      echo "CRITICAL volume $VOL used $PRCT% of $TOTAL" >> $PERFO_FILE
 +  elif  [[ $PRCT -gt "$WARN" ]]
 +    then
 +      echo "WARNING volume $VOL used $PRCT% of $TOTAL" >> $PERFO_FILE
 +  elif  [[ -z $PRCT  ]]
 +    then
 +      echo "UNKNOWN no response from plugin"
 +  else
 +      echo "OK volume $VOL used $PRCT% of $TOTAL" >> $PERFO_FILE
 +  fi
 +
 +done <  "/usr/lib64/nagios/plugins/NETAPP-VFILER/${VFL}.txt"
 +
 +#VAL=`cat "/usr/lib64/nagios/plugins/NETAPP-VFILER/$VFL-result.txt"`
 +VAL2=/usr/lib64/nagios/plugins/NETAPP-VFILER/$VFL-result.txt
 +
 +# Si critique
 +CRITICAL=`grep "^CRITICAL" "$VAL2"`
 +WARNING=`grep "^WARNING" "$VAL2"`
 +OK=`grep "^OK" "$VAL2"`
 +
 +if [[ $CRITICAL != "" ]]
 +then
 +grep "^CRITICAL" "$VAL2"
 +grep "^WARNING" "$VAL2"
 +grep "^OK" "$VAL2"
 +exit 2
 +# Si warning
 +elif  [[ $WARNING != "" ]]
 +then
 +grep "^WARNING" "$VAL2"
 +grep "^OK" "$VAL2"
 +exit 1
 +# Si OK
 +else
 +grep "^OK" "$VAL2"
 +exit 0
 +fi
 +</code>
 +==== check_netapp_lun_state ====
 +<code>
 +#! /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 'https://'$HOST'/api/storage/luns?status.state=*' | jq '.' | grep -oE '"state":.*|"name":.*' | sed '/./N; s/\n/ /' | grep -Ewv  $FILTER)
 +
 +# Commande si pas de filtrage
 +else
 +RESULT=$(curl -s -k -u $USER:$PASS -X GET 'https://'$HOST'/api/storage/luns?status.state=*' | jq '.' | grep -oE '"state":.*|"name":.*' | sed '/./N; s/\n/ /')
 +fi
 +
 +# Si resultat vide
 +if
 +[[ -z $RESULT ]]
 +then
 +echo "WARNING: Pas de retour du script"
 +exit 3
 +fi
 +
 +# Si critique
 +CRIT=`echo -e "$RESULT" | grep -oE  '(.*"offline"|.*"foreign-lun-error"|.*"nvfail"|.*"space-error")'`
 +if [[ $RESULT != *"online"* ]]
 +then
 +printf "CRITICAL: $CRIT\n"
 +exit 2
 +
 +# Si OK
 +else
 +echo "OK: $RESULT"
 +fi
 +</code>
 +==== check_inode_size.sh ====
 +<code>
 +#!/bin/bash
 +# 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=/usr/lib64/nagios/plugins/NETAPP-VFILER/$1
 +VOL=$2
 +WARN=${3:-95}
 +CRIT=${4:-98}
 +
 +RESULT=$(cat $VSERV-vol.txt | grep -oE  '^netapp_volume_inode_files_used_percentage.*volume="'$VOL'".*'|cut -d '.' -f2-| cut -c 1-2)
 +
 +# Si critique
 +if [[ $RESULT -gt "$CRIT" ]]
 +then
 +echo "INODE Usage is CRITICAL: $RESULT%"
 +exit 2
 +fi
 +
 +# Si warning
 +if  [[ $RESULT -gt "$WARN" ]]
 +then
 +echo "INODE Usage is Warning: $RESULT%"
 +exit 1
 +
 +
 +# Si OK
 +else
 +echo "INODE Usage is OK: $RESULT%"
 +fi
 +</code>
 +==== check_postfix_mailq ====
 +<code>
 +#!/bin/bash
 +
 +OID="iso.3.6.1.4.1.8072.1.3.2.4.1.2.10.109.97.105.108.113.115.116.97.116.115"
 +STATE_OK=0          # define the exit code if status is OK
 +STATE_WARNING=1     # define the exit code if status is Warning
 +STATE_CRITICAL=2    # define the exit code if status is Critical
 +STATE_UNKNOWN=3     # define the exit code if status is Unknown
 +STATE=""
 +STATUS=(OK WARNING CRITICAL UNKNOWN)
 +
 +set -e
 +
 +# Process user-provided parameters
 +while getopts "v:H:C:w:c:" OPT;
 +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 "Please use options -H for hostname, -C for SNMP community, -t for type,"
 +        echo "-w for warning threshold and -c for critical threshold."
 +        echo ""
 +        exit ${STATE_UNKNOWN}
 +        ;;
 +    esac
 +done
 +#set -x
 +
 +if [ -z "$WARN_THRESHOLD" ]; then
 + WARN_THRESHOLD=250
 +fi
 +
 +if [ -z "$CRIT_THRESHOLD" ]; then
 + CRIT_THRESHOLD=400
 +fi
 +
 +if [ -z "$SNMP_COMMUNITY" ]; then
 + SNMP_COMMUNITY='public'
 +fi
 +
 +if [ -z "$SNMP_VERSION" ]; then
 + SNMP_VERSION='2C'
 +fi
 +
 +STATS[0]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.1 | grep -E -o '[0-9]{1,}' )
 +STATS[1]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.2 | grep -E -o '[0-9]{1,}' )
 +STATS[2]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.3 | grep -E -o '[0-9]{1,}' )
 +
 +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 '[0-9]{1,}' )
 +
 +if [ $STATS_TOTAL -ge $CRIT_THRESHOLD ]; then
 + STATE=2
 +elif [ $STATS_TOTAL -ge $WARN_THRESHOLD ]; then
 + STATE=1
 +else 
 + STATE=0
 +fi
 +
 +echo "${STATUS[$STATE]} - $STATS_TOTAL mail on queue|incoming=${STATS[0]} active=${STATS[1]} deferred=${STATS[2]} hold=${STATS[3]}"
 +exit $STATE
 +</code>
 +==== check_postfix_mailstats ====
 +<code>
 +#!/bin/bash
 +
 +OID="iso.3.6.1.4.1.8072.1.3.2.4.1.2.9.109.97.105.108.103.114.97.112.104"
 +STATE_OK=0          # define the exit code if status is OK
 +STATE_WARNING=1     # define the exit code if status is Warning
 +STATE_CRITICAL=2    # define the exit code if status is Critical
 +STATE_UNKNOWN=3     # define the exit code if status is Unknown
 +STATE=""
 +STATUS=(OK WARNING CRITICAL UNKNOWN)
 +
 +set -e
 +
 +# Process user-provided parameters
 +while getopts "v:H:C:w:c:" OPT;
 +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 "Please use options -H for hostname, -C for SNMP community, -t for type,"
 +        echo "-w for warning threshold and -c for critical threshold."
 +        echo ""
 +        exit ${STATE_UNKNOWN}
 +        ;;
 +    esac
 +done
 +set -x
 +
 +if [ -z "$WARN_THRESHOLD" ]; then
 + WARN_THRESHOLD=250
 +fi
 +
 +if [ -z "$CRIT_THRESHOLD" ]; then
 + CRIT_THRESHOLD=500
 +fi
 +
 +if [ -z "$SNMP_COMMUNITY" ]; then
 + SNMP_COMMUNITY='public'
 +fi
 +
 +if [ -z "$SNMP_VERSION" ]; then
 + SNMP_VERSION='2C'
 +fi
 +
 +STATS[0]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.1 | grep -E -o '[0-9]{1,}' )
 +STATS[1]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.2 | grep -E -o '[0-9]{1,}' )
 +STATS[2]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.3 | grep -E -o '[0-9]{1,}' )
 +STATS[3]=$( snmpget -Ov -v $SNMP_VERSION -c $SNMP_COMMUNITY $SNMP_HOST ${OID}.4 | grep -E -o '[0-9]{1,}' )
 +
 +if [ ${STATS[0]} -eq '9999' ]; then
 + echo "${STATUS[$STATE]} - Mailgraph process not running"
 +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 "${STATUS[$STATE]} - $STATS_TOTAL mail rencently handled|Sent=${STATS[0]} Received=${STATS[1]} Bounced=${STATS[2]} Rejected=${STATS[3]}"
 +exit $STATE
 +</code>
 +==== check_simple_oid ====
 +<code>
 +#!/bin/bash
 +# 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 '{print $NF}')
 +
 +# Si critique
 +if [[ "$RESULT" -gt "$CRIT" ]]
 +then
 +echo "Value is Critical: $RESULT"
 +exit 2
 +fi
 +
 +# Si warning
 +if [[ "$RESULT" -gt "$WARN" ]]
 +then
 +echo "Value is Warning: $RESULT"
 +exit 1
 +
 +# Si OK
 +else
 +echo "Value is OK: $RESULT"
 +exit 0
 +fi
 +</code>
 +==== check_simple_oid_perfo ====
 +<code>
 +#!/bin/bash
 +# 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:-0}
 +MAX=${7:-15000}
 +
 +# La variable si dessous recupere le dernier champ de la requète
 +RESULT=$(snmpwalk -c $COMM -v 2c $HOST $OID | awk '{print $NF}')
 +
 +# Si critique
 +if [[ "$RESULT" -gt "$CRIT" ]]
 +  then
 +    state=Critical
 +    output=2
 +# Si warning
 +elif [[ "$RESULT" -gt "$WARN" ]]
 +  then
 +    state=Warning
 +    output=1
 +# Si OK
 +else
 +  state=OK
 +  output=0
 +fi
 +
 +echo "Value is $state: $RESULT|connections=$RESULT;$WARN;$CRIT;$MIN;$MAX;"
 +exit $output
 +</code>
 +==== check_sla_dispo_process_Linux.sh ====
 +<code>
 +#!/bin/bash
 +####################################################
 +# 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::hrSWRunName | grep -w "$3" | awk -F '[.=]' '{print $2}')
 +WARN=${4:-1}
 +CRIT=${5:-0}
 +FICHIER+=($(snmpwalk -c $COMM -v 2c $HOST HOST-RESOURCES-MIB::hrSWRunStatus | grep "$SERV" | cut -d ":" -f4))
 +done
 +RESULT=$(printf "%s\n" "${FICHIER[@]}" | grep "runn" | wc -l)
 +
 +# Remontee des alertes
 +# Si critique
 +if [[ "$RESULT" = $CRIT ]]
 + then
 +  echo "Critique: aucuns services $3 ne tourne pour la HA"
 + exit 2
 +fi
 +
 +# Si warning
 +if [[ "$RESULT" < "$WARN" ]]
 + then
 +  echo "Warning: moins de $WARN services $3 ne tourne pour la HA"
 + exit 1
 +
 +# Si OK
 +else
 + echo "OK: $RESULT services: $3 'UP'"
 +exit 0
 +fi
 +</code>
 +==== check_sla_dispo_services_windows.sh ====
 +<code>
 +#!/bin/bash
 +####################################################
 +# 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:-1}
 +CRIT=${5:-0}
 +FICHIER+=($(snmpwalk -c $COMM -v 2c $HOST 1.3.6.1.4.1.77.1.2.3.1.1 | grep "$SERV" | cut -d ":" -f4 | wc -l))
 +done
 +RESULT=$(printf '%s\n' ${FICHIER[@]} | grep 1 | wc -l)
 +# Remontee des alertes
 +# Si critique
 +if [[ "$RESULT" = "$CRIT" ]]
 + then
 +  echo "Critique: aucuns services $SERV ne tourne pour la HA"
 + exit 2
 +fi
 +
 +# Si warning
 +if [[ "$RESULT" < "$WARN" ]]
 + then
 +  echo "Warning: moins de $WARN services $SERV ne tourne pour la HA: $RESULT"
 + exit 1
 +
 + Si OK
 +else
 + echo "OK: $RESULT services: $SERV 'UP'"
 +exit 0
 +fi
 +</code>
 +==== check_snmp_dell_equalogic ====
 +<code>
 +#!/bin/bash
 +# /etc/zabbix/scripts/dell/check_snmp_dell_equallogic.sh -H 172.17.15.205 -C $1 -n $2 -t volume -v $3
 +# check_snmp_dell_equallogic
 +# Description : Check the status of Dell EqualLogic storage
 +# Version : 1.5
 +# Author : Yoann LAMY
 +# Licence : GPLv2
 +
 +# Commands
 +CMD_BASENAME="/bin/basename"
 +CMD_SNMPGET="/usr/bin/snmpget"
 +CMD_SNMPWALK="/usr/bin/snmpwalk"
 +CMD_AWK="/bin/awk"
 +CMD_GREP="/bin/grep"
 +CMD_BC="/usr/bin/bc"
 +CMD_EXPR="/usr/bin/expr"
 +
 +# Script name
 +SCRIPTNAME=`$CMD_BASENAME $0`
 +
 +# Version
 +VERSION="1.5"
 +
 +# Plugin return codes
 +STATE_OK=0
 +STATE_WARNING=1
 +STATE_CRITICAL=2
 +STATE_UNKNOWN=3
 +
 +# 'eqlMemberName', EQLMEMBER-MIB
 +OID_MEMBER_ID=".1.3.6.1.4.1.12740.2.1.1.1.9"
 +
 +# 'eqlControllerBatteryStatus', EQLMEMBER-MIB
 +OID_BATTERY_STATUS=".1.3.6.1.4.1.12740.4.1.1.1.5.1"
 +
 +# 'eqlMemberModel', EQLMEMBER-MIB
 +OID_MODEL=".1.3.6.1.4.1.12740.2.1.11.1.1.1"
 +
 +# 'eqlMemberSerialNumber', EQLMEMBER-MIB
 +OID_SERIALNUMBER=".1.3.6.1.4.1.12740.2.1.11.1.2.1"
 +
 +# 'eqlMemberNumberOfControllers', EQLMEMBER-MIB
 +OID_NUMBERCONTROLLERS=".1.3.6.1.4.1.12740.2.1.11.1.3.1"
 +
 +# 'eqlMemberNumberOfDisks', EQLMEMBER-MIB
 +OID_NUMBERDISKS=".1.3.6.1.4.1.12740.2.1.11.1.4.1"
 +
 +# 'eqlMemberNumberOfConnections', EQLMEMBER-MIB
 +OID_CONNECTIONS_ISCSI=".1.3.6.1.4.1.12740.2.1.12.1.1"
 +
 +# 'eqlMemberHealthDetailsFanName', EQLMEMBER-MIB
 +OID_FAN_NAME=".1.3.6.1.4.1.12740.2.1.7.1.2.1"
 +
 +# 'eqlMemberHealthDetailsFanValue', EQLMEMBER-MIB
 +OID_FAN_VALUE=".1.3.6.1.4.1.12740.2.1.7.1.3.1"
 +
 +# 'eqlMemberHealthStatus', EQLMEMBER-MIB
 +OID_HEALTH_STATUS=".1.3.6.1.4.1.12740.2.1.5.1.1.1"
 +
 +# 'eqlMemberReadOpCount', EQLMEMBER-MIB
 +OID_IO_READ=".1.3.6.1.4.1.12740.2.1.12.1.6.1"
 +
 +# 'eqlMemberWriteOpCount', EQLMEMBER-MIB
 +OID_IO_WRITE=".1.3.6.1.4.1.12740.2.1.12.1.7.1"
 +
 +# 'eqlMemberReadAvgLatency', EQLMEMBER-MIB
 +OID_LATENCY_READ=".1.3.6.1.4.1.12740.2.1.12.1.4.1"
 +
 +# 'eqlMemberWriteAvgLatency', EQLMEMBER-MIB
 +OID_LATENCY_WRITE=".1.3.6.1.4.1.12740.2.1.12.1.5.1"
 +
 +# 'eqlControllerPrimaryOrSecondary', EQLCONTROLLER-MIB
 +OID_CONTROLLER_PRIMSEC=".1.3.6.1.4.1.12740.4.1.1.1.9.1"
 +
 +# 'eqlDiskId', EQLDISK-MIB
 +OID_DISK_ID=".1.3.6.1.4.1.12740.3.1.1.1.10.1"
 +
 +# 'eqlDiskTypeEnum', EQLDISK-MIB
 +OID_DISK_TYPE=".1.3.6.1.4.1.12740.3.1.1.1.12.1"
 +
 +# 'eqlDiskSize', EQLDISK-MIB
 +OID_DISK_TOTAL=".1.3.6.1.4.1.12740.3.1.1.1.6.1"
 +
 +# 'eqlDiskStatus', EQLDISK-MIB
 +OID_DISK_STATUS=".1.3.6.1.4.1.12740.3.1.1.1.8.1"
 +
 +# 'eqlIpAdEntIfName', EQLIPADDR-MIB
 +OID_NETWORK_NAME=".1.3.6.1.4.1.12740.9.1.1.2.1"
 +
 +# 'ifDescr', IF-MIB
 +OID_NETWORK_ID=".1.3.6.1.2.1.2.2.1.2"
 +
 +# 'ifMtu', IF-MIB
 +OID_NETWORK_MTU=".1.3.6.1.2.1.2.2.1.4"
 +
 +# 'ifSpeed', IF-MIB
 +OID_NETWORK_SPEED=".1.3.6.1.2.1.2.2.1.5"
 +
 +# 'ifOperStatus', IF-MIB
 +OID_NETWORK_STATUS=".1.3.6.1.2.1.2.2.1.8"
 +# 'eqlMemberHealthDetailsPowerSupplyName', EQLMEMBER-MIB
 +OID_POWERSUPPLY_NAME=".1.3.6.1.4.1.12740.2.1.8.1.2.1"
 +
 +# 'eqlMemberHealthDetailsPowerSupplyCurrentState', EQLMEMBER-MIB
 +OID_POWERSUPPLY_STATUS=".1.3.6.1.4.1.12740.2.1.8.1.3.1"
 +
 +# 'eqlMemberStatusRaidStatus', EQLMEMBER-MIB
 +OID_RAID_STATUS=".1.3.6.1.4.1.12740.2.1.13.1.1.1"
 +
 +# 'eqlMemberHealthDetailsTemperatureName', EQLMEMBER-MIB
 +OID_TEMPERATURE_NAME=".1.3.6.1.4.1.12740.2.1.6.1.2.1"
 +
 +# 'eqlMemberHealthDetailsTemperatureValue', EQLMEMBER-MIB
 +OID_TEMPERATURE_VALUE=".1.3.6.1.4.1.12740.2.1.6.1.3.1"
 +
 +# 'eqlMemberTotalStorage', EQLMEMBER-MIB
 +OID_USAGE_TOTAL=".1.3.6.1.4.1.12740.2.1.10.1.1.1"
 +
 +# 'eqlMemberUsedStorage', EQLMEMBER-MIB
 +OID_USAGE_USED=".1.3.6.1.4.1.12740.2.1.10.1.2.1"
 +
 +# 'eqlMemberSnapStorage', EQLMEMBER-MIB
 +OID_USAGE_SNAPSHOTS=".1.3.6.1.4.1.12740.2.1.10.1.3.1"
 +
 +# 'eqlMemberReplStorage', EQLMEMBER-MIB
 +OID_USAGE_REPLICAS=".1.3.6.1.4.1.12740.2.1.10.1.4.1"
 +
 +# 'eqliscsiVolumeName', EQLVOLUME-MIB
 +OID_VOLUME_NAME=".1.3.6.1.4.1.12740.5.1.7.1.1.4"
 +
 +# 'eqliscsiVolumeAdminStatus', EQLVOLUME-MIB
 +OID_VOLUME_STATUS=".1.3.6.1.4.1.12740.5.1.7.1.1.9"
 +
 +# 'eqliscsiVolumeSize', EQLVOLUME-MIB
 +OID_VOLUME_TOTAL=".1.3.6.1.4.1.12740.5.1.7.1.1.8"
 +
 +# 'eqliscsiVolumeStatusAllocatedSpace', EQLVOLUME-MIB
 +OID_VOLUME_USED=".1.3.6.1.4.1.12740.5.1.7.7.1.13"
 +
 +# 'eqliscsiVolumeStoragePoolIndex', EQLVOLUME-MIB
 +OID_VOLUME_STORAGEPOOL_ID=".1.3.6.1.4.1.12740.5.1.7.1.1.22"
 +
 +# 'eqlStoragePoolName', EQLSTORAGEPOOL-MIB
 +OID_STORAGEPOOL_NAME=".1.3.6.1.4.1.12740.16.1.1.1.3.1"
 +
 +# Default variables
 +DESCRIPTION="Unknown"
 +STATE=$STATE_UNKNOWN
 +CODE=0
 +
 +# Default options
 +COMMUNITY="public"
 +HOSTNAME="127.0.0.1"
 +NAME=""
 +TYPE="info"
 +NETWORK="eth0"
 +MTU=9000
 +SPEED=1000
 +DISK=1
 +VOLUME="vss-control"
 +WARNING=0
 +CRITICAL=0
 +
 +# Option processing
 +print_usage() {
 +  echo "Usage: ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t redundancy"
 +  echo "  $SCRIPTNAME -H ADDRESS"
 +  echo "  $SCRIPTNAME -C STRING"
 +  echo "  $SCRIPTNAME -n STRING"
 +  echo "  $SCRIPTNAME -t STRING"
 +  echo "  $SCRIPTNAME -i STRING"
 +  echo "  $SCRIPTNAME -m INTEGER"
 +  echo "  $SCRIPTNAME -s INTEGER"
 +  echo "  $SCRIPTNAME -d INTEGER"
 +  echo "  $SCRIPTNAME -v STRING"
 +  echo "  $SCRIPTNAME -w INTEGER"
 +  echo "  $SCRIPTNAME -c INTEGER"
 +  echo "  $SCRIPTNAME -h"
 +  echo "  $SCRIPTNAME -V"
 +}
 +
 +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 "   Name or IP address of host (default: 127.0.0.1)"
 +  echo "-C STRING"
 +  echo "   Community name for the host's SNMP agent (default: public)"
 +  echo "-n STRING"
 +  echo "   Member name"
 +  echo "-t STRING"
 +  echo "   Check type (battery, connection, controller, disk, fan, health, info, io, latency, network, redundancy, temperature, usage, raid, volume) (default: info)"
 +  echo "-i STRING"
 +  echo "   Network interface (default: eth0)"
 +  echo "-m INTEGER"
 +  echo "   MTU size (default: 9000)"
 +  echo "-s INTEGER"
 +  echo "   Network interface speed (default: 1000)"
 +  echo "-d INTEGER"
 +  echo "   Disk number (default: 1)"
 +  echo "-v STRING"
 +  echo "   Volume name (default: vss-control)"
 +  echo "-w INTEGER"
 +  echo "   Warning level (default: 0)"
 +  echo "-c INTEGER"
 +  echo "   Critical level (default: 0)"
 +  echo "-h"
 +  echo "   Print this help screen"
 +  echo "-V"
 +  echo "   Print version and license information"
 +  echo ""
 +  echo ""
 +  echo "This plugin uses the 'snmpget' command and the 'snmpwalk' command included with the NET-SNMP package."
 +  echo "This plugin support performance data output (connection, fan, io, latency, temperature, usage, volume)."
 +}
 +
 +while getopts H:C:n:t:i:m:s:d:v:w:c:hV OPT
 +do
 +  case $OPT in
 +    H) HOSTNAME="$OPTARG" ;;
 +    C) COMMUNITY="$OPTARG" ;;
 +    n) NAME="$OPTARG" ;;
 +    t) TYPE="$OPTARG" ;;
 +    i) NETWORK="$OPTARG" ;;
 +    m) MTU=$OPTARG ;;
 +    s) SPEED=$OPTARG ;;
 +    d) DISK=$OPTARG ;;
 +    v) VOLUME="$OPTARG" ;;
 +    w) WARNING=$OPTARG ;;
 +    c) CRITICAL=$OPTARG ;;
 +    h)
 +      print_help
 +      exit $STATE_UNKNOWN
 +      ;;
 +    V)
 +      print_version
 +      exit $STATE_UNKNOWN
 +      ;;
 +   esac
 +done
 +
 +# Plugin processing
 +size_convert() {
 +  if [ $VALUE -ge 1099511627776 ]; then
 +    VALUE=`echo "scale=2 ; ( ( ( $VALUE / 1024 ) / 1024 ) / 1024 ) / 1024" | $CMD_BC`
 +    VALUE="$VALUE TB"
 +  elif [ $VALUE -ge 1073741824 ]; then
 +    VALUE=`echo "scale=2 ; ( ( $VALUE / 1024 ) / 1024 ) / 1024" | $CMD_BC`
 +    VALUE="$VALUE GB"
 +  elif [ $VALUE -ge 1048576 ]; then
 +    VALUE=`echo "scale=2 ; ( $VALUE / 1024 ) / 1024" | $CMD_BC`
 +    VALUE="$VALUE MB"
 +  else
 +    VALUE=`echo "scale=2 ; $VALUE / 1024" | $CMD_BC`
 +    VALUE="$VALUE Bytes"
 +  fi
 +}
 +
 +if [ -n "$NAME" ]; then
 +  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 "." '{print $NF}'`
 +
 +  if [ -n "$MEMBER_ID" ]; then
 +
 +    if [ $TYPE = "battery" ]; then
 +      # Check battery status (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t battery)
 +      DESCRIPTION="Member '${NAME}' - Battery status :"
 +      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="$DESCRIPTION cache battery in controller $CONTROLLER_ID is fully functional${COMMA}"
 +            STATE=$STATE_OK
 +          ;;
 +          2)
 +            DESCRIPTION="$DESCRIPTION cache battery failure in controller $CONTROLLER_ID"
 +            STATE=$STATE_CRITICAL
 +            break
 +          ;;
 +          3)
 +            DESCRIPTION="$DESCRIPTION cache battery in controller $CONTROLLER_ID is charging"
 +            STATE=$STATE_WARNING
 +            break
 +          ;;
 +          4)
 +            DESCRIPTION="$DESCRIPTION cache battery in controller $CONTROLLER_ID voltage is low"
 +            STATE=$STATE_CRITICAL
 +            break
 +          ;;
 +          5)
 +            DESCRIPTION="$DESCRIPTION cache battery in controller $CONTROLLER_ID voltage is low and is charging"
 +            STATE=$STATE_CRITICAL
 +            break
 +          ;;
 +          6)
 +            DESCRIPTION="$DESCRIPTION Missing cache battery in controller $CONTROLLER_ID"
 +            STATE=$STATE_CRITICAL
 +            break
 +          ;;
 +          *)
 +            DESCRIPTION="$DESCRIPTION cache battery in controller $CONTROLLER_ID status unknown"
 +            STATE=$STATE_UNKNOWN
 +            break
 +          ;;
 +        esac
 +        COMMA=""
 +      done
 +    elif [ $TYPE = "connection" ]; then
 +      # Number of connection (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t connection -w 15 -c 20)
 +      CONNECTIONS_ISCSI=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_CONNECTIONS_ISCSI}.${MEMBER_ID}`
 +      if [ -n "$CONNECTIONS_ISCSI" ]; then
 +        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="Member '${NAME}' - Number of iSCSI connections : ${CONNECTIONS_ISCSI} | con_iscsi=${CONNECTIONS_ISCSI};$WARNING;$CRITICAL;0"
 +      fi
 +    elif [ $TYPE = "controller" ]; then
 +      # Controllers status (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t controllers)
 +      CONTROLLER_NUMBER=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_CONTROLLER_PRIMSEC}.${MEMBER_ID} | wc -l`
 +      DESCRIPTION="Member '${NAME}' - Controllers status :"
 +      if [ $CONTROLLER_NUMBER = 2 ]; then
 +        DESCRIPTION="$DESCRIPTION Both controllers are fully functional"
 +        STATE=$STATE_OK
 +      else
 +        DESCRIPTION="$DESCRIPTION A controller has failed"
 +        STATE=$STATE_WARNING
 +      fi
 +    elif [ $TYPE = "disk" ]; then
 +      # Disks storage status (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t disk -d 1)
 +      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="SATA"
 +        ;;
 +        2)
 +          DISK_TYPE_TEXT="SAS"
 +        ;;
 +        *)
 +          DISK_TYPE_TEXT="Inconnu"
 +        ;;
 +      esac
 +      VALUE=$DISK_TOTAL
 +      size_convert
 +      DISK_TOTAL=$VALUE
 +      DESCRIPTION="Member '${NAME}' - Disk ${DISK} (slot ${DISK_SLOT}) status (type : ${DISK_TYPE_TEXT} and size ${DISK_TOTAL} ) :"
 +      case $DISK_STATUS in
 +        1)
 +          DESCRIPTION="$DESCRIPTION Disk is online. RAID is fully functional"
 +          STATE=$STATE_OK
 +        ;;
 +        2)
 +          DESCRIPTION="$DESCRIPTION Spare disk"
 +          STATE=$STATE_OK
 +        ;;
 +        3)
 +          DESCRIPTION="$DESCRIPTION Disk failures"
 +          STATE=$STATE_CRITICAL
 +        ;;
 +        4)
 +          DESCRIPTION="$DESCRIPTION Disk is offline"
 +          STATE=$STATE_WARNING
 +        ;;
 +        5)
 +          DESCRIPTION="$DESCRIPTION Disk failures"
 +          STATE=$STATE_WARNING
 +        ;;
 +        6)
 +          DESCRIPTION="$DESCRIPTION Disk is too small"
 +          STATE=$STATE_CRITICAL
 +        ;;
 +        7)
 +          DESCRIPTION="$DESCRIPTION Disk failure : cannot be converted to spare"
 +          STATE=$STATE_CRITICAL
 +        ;;
 +        8)
 +          DESCRIPTION="$DESCRIPTION Disk is unsupported. cannot be converted to spare"
 +          STATE=$STATE_CRITICAL
 +        ;;
 +        *)
 +          DESCRIPTION="$DESCRIPTION Disk : status unknown"
 +          STATE=$STATE_UNKNOWN
 +        ;;
 +      esac
 +    elif [ $TYPE = "fan" ]; then
 +      # Check fans RPM (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t fan)
 +      DESCRIPTION="Member '${NAME}' - Fan speed :"
 +      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 "." '{print $NF}'`; do
 +        FAN_NAME=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_FAN_NAME}.${MEMBER_ID}.${FAN_ID} | $CMD_AWK -F '"' '{print $2}'`
 +        FAN_VALUE=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_FAN_VALUE}.${MEMBER_ID}.${FAN_ID}`
 +        DESCRIPTION="$DESCRIPTION '${FAN_NAME}' : ${FAN_VALUE} rpm, "
 +        PERFORMANCE_DATA="$PERFORMANCE_DATA '${FAN_NAME}'=${FAN_VALUE};0;0;0"
 +      done
 +      DESCRIPTION="$DESCRIPTION | $PERFORMANCE_DATA"
 +      STATE=$STATE_OK
 +    elif [ $TYPE = "health" ]; then
 +      # Check global system status (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t health)
 +      HEALTH_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_HEALTH_STATUS}.${MEMBER_ID}`
 +      DESCRIPTION="Member '${NAME}' - Global system status : "
 +      case $HEALTH_STATUS in
 +        1)
 +          DESCRIPTION="$DESCRIPTION OK"
 +          STATE=$STATE_OK
 +        ;;
 +        2)
 +          DESCRIPTION="$DESCRIPTION Warning"
 +          STATE=$STATE_WARNING
 +        ;;
 +        3)
 +          DESCRIPTION="$DESCRIPTION Critical"
 +          STATE=$STATE_CRITICAL
 +        ;;
 +        *)
 +          DESCRIPTION="$DESCRIPTION Unknown"
 +          STATE=$STATE_UNKNOWN
 +        ;;
 +      esac
 +    elif [ $TYPE = "info" ]; then
 +      # Information (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t info)
 +      MODEL=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_MODEL}.${MEMBER_ID} | $CMD_AWK -F '"' '{print $2}'`
 +      SERIALNUMBER=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_SERIALNUMBER}.${MEMBER_ID} | $CMD_AWK -F '"' '{print $2}'`
 +      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="Member '${NAME}' - Info : Storage Array Dell EqualLogic '${MODEL}' (${SERIALNUMBER}) has $CONTROLLERS controllers and $DISKS hard drives"
 +      STATE=$STATE_OK
 +    elif [ $TYPE = "io" ]; then
 +      # Check I/O performance (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t io)
 +      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="Member '${NAME}' -  I/O Operations per second : Read counter's value is ${IO_READ} and write counter's value is $IO_WRITE | read=${IO_READ}c;0;0;0 write=${IO_WRITE}c;0;0;0"
 +      STATE=$STATE_OK
 +    elif [ $TYPE = "latency" ]; then
 +      # Check average latency (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t latency)
 +      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="Member '${NAME}' - Reading average latency value is : $LATENCY_READ ms, writing average latency value is $LATENCY_WRITE ms | read=${LATENCY_READ};0;0;0 write=${LATENCY_WRITE};0;0;0"
 +      STATE=$STATE_OK
 +    elif [ $TYPE = "network" ]; then
 +      # Network interface status (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t network -i eth0 -m 9000 -s 1000)
 +      NETWORK_IP=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_NETWORK_NAME}.${MEMBER_ID} | $CMD_GREP -i $NETWORK | $CMD_AWK '{print $1}' | $CMD_AWK -F "${MEMBER_ID}." '{print $2}'`
 +      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 "." '{print $NF}'`
 +      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="Member '${NAME}' - Network interface '${NETWORK}' (${NETWORK_IP}) status :"
 +      if [ $NETWORK_STATUS = "up" ] && [ $MTU -eq $NETWORK_MTU ] && [ $SPEED -le $NETWORK_SPEED ]; then
 +        DESCRIPTION="$DESCRIPTION Network interface is fully functional"
 +        STATE=$STATE_OK
 +      else
 +        DESCRIPTION="$DESCRIPTION Network interface failure"
 +        STATE=$STATE_CRITICAL
 +      fi
 +      DESCRIPTION="$DESCRIPTION (MTU of $NETWORK_MTU and Speed of $NETWORK_SPEED)"
 +    elif [ $TYPE = "redundancy" ]; then
 +      # Power supply status (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t redundancy)
 +      DESCRIPTION="Member '${NAME}' - Power supply status :"
 +      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 '"' '{print $2}'`
 +        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="$DESCRIPTION '${POWERSUPPLY_NAME}' is fully functional${COMMA}"
 +            STATE=$STATE_OK
 +          ;;
 +          2)
 +            DESCRIPTION="$DESCRIPTION '${POWERSUPPLY_NAME}' power cord is missing"
 +            STATE=$STATE_WARNING
 +            break
 +          ;;
 +          3)
 +            DESCRIPTION="$DESCRIPTION '${POWERSUPPLY_NAME}' failure"
 +            STATE=$STATE_CRITICAL
 +            break
 +          ;;
 +          *)
 +            DESCRIPTION="$DESCRIPTION '${POWERSUPPLY_NAME}' status unknown"
 +            STATE=$STATE_UNKNOWN
 +            break
 +          ;;
 +        esac
 +        COMMA=""
 +      done
 +    elif [ $TYPE = "raid" ]; then
 +      # RAID status (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t raid)
 +      RAID_STATUS=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_RAID_STATUS}.${MEMBER_ID}`
 +      DESCRIPTION="Member '${NAME}' - RAID status :"
 +      case $RAID_STATUS in
 +        1)
 +          DESCRIPTION="$DESCRIPTION RAID is fully functional"
 +          STATE=$STATE_OK
 +        ;;
 +        2)
 +          DESCRIPTION="$DESCRIPTION RAID is running in degraded mode"
 +          STATE=$STATE_CRITICAL
 +        ;;
 +        3)
 +          DESCRIPTION="$DESCRIPTION Verifying integrity of RAID drives"
 +          STATE=$STATE_WARNING
 +        ;;
 +        4)
 +          DESCRIPTION="$DESCRIPTION RAID is rebuilding"
 +          STATE=$STATE_WARNING
 +        ;;
 +        5)
 +          DESCRIPTION="$DESCRIPTION RAID failure"
 +          STATE=$STATE_CRITICAL
 +        ;;
 +        6)
 +          DESCRIPTION="$DESCRIPTION RAID failure"
 +          STATE=$STATE_CRITICAL
 +        ;;
 +        7)
 +          DESCRIPTION="$DESCRIPTION RAID is resizing"
 +          STATE=$STATE_WARNING
 +        ;;
 +        *)
 +          DESCRIPTION="$DESCRIPTION RAID is in unknown state"
 +          STATE=$STATE_UNKNOWN
 +        ;;
 +      esac
 +    elif [ $TYPE = "temperature" ]; then
 +      # Check temperature (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t temperature)
 +      DESCRIPTION="Member '${NAME}' - Temperatures :"
 +      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 "." '{print $NF}'`; do
 +        TEMPERATURE_NAME=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_TEMPERATURE_NAME}.${MEMBER_ID}.${TEMPERATURE_ID} | $CMD_AWK -F '"' '{print $2}'`
 +        TEMPERATURE_VALUE=`$CMD_SNMPGET -t 2 -r 2 -v 1 -c $COMMUNITY -Ovq $HOSTNAME ${OID_TEMPERATURE_VALUE}.${MEMBER_ID}.${TEMPERATURE_ID}`
 +        DESCRIPTION="$DESCRIPTION '${TEMPERATURE_NAME}' : ${TEMPERATURE_VALUE} Degres Celcius, "
 +        PERFORMANCE_DATA="$PERFORMANCE_DATA '${TEMPERATURE_NAME}'=${TEMPERATURE_VALUE};0;0;0"
 +      done
 +      DESCRIPTION="$DESCRIPTION | $PERFORMANCE_DATA"
 +      STATE=$STATE_OK
 +    elif [ $TYPE = "usage" ]; then
 +      # Disk usage (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t usage -w 90 -c 95)
 +      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="Member '${NAME}' - Used disk space : $USAGE_USED_FORMAT with a total disk space of $USAGE_TOTAL_FORMAT (${USAGE_USED_POURCENT}%) with ${USAGE_SNAPSHOTS_POURCENT}% for snapshots and ${USAGE_REPLICAS_POURCENT}% for replication | total=${USAGE_TOTAL}B;$PERFDATA_WARNING;$PERFDATA_CRITICAL;0 used=${USAGE_USED}B;0;0;0 snapshots=${USAGE_SNAPSHOTS}B;0;0;0 replicas=${USAGE_REPLICAS}B;0;0;0"
 +      fi
 +    elif [ $TYPE = "volume" ]; then
 +      # Volume status (Usage : ./check_snmp_dell_equallogic -H 127.0.0.1 -C public -n BAIE01 -t volume -v volume01 -w 90 -c 95)
 +      VOLUME_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_VOLUME_NAME} | $CMD_GREP -i $VOLUME | $CMD_AWK '{print $1}' | $CMD_AWK -F "." '{print $NF}'`
 +   VOLUME_MEMBER_ID=`$CMD_SNMPWALK -t 2 -r 2 -v 1 -c $COMMUNITY $HOSTNAME ${OID_VOLUME_NAME} | $CMD_GREP -i $VOLUME | $CMD_AWK '{print $1}' | $CMD_AWK -F "." '{print $(NF-1)}'`
 +      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 '"' '{print $2}'`
 +      case $VOLUME_STATUS in
 +        1)
 +          VOLUME_STATUS_DESC="online"
 +        ;;
 +        2)
 +          VOLUME_STATUS_DESC="offline"
 +        ;;
 +        3)
 +          VOLUME_STATUS_DESC="online, lost blocks"
 +        ;;
 +        4)
 +          VOLUME_STATUS_DESC="online, lost and ignored blocks"
 +        ;;
 +        5)
 +          VOLUME_STATUS_DESC="offline, lost and ignored blocks"
 +        ;;
 +        *)
 +          VOLUME_STATUS_DESC="unknown"
 +        ;;
 +      esac
 +      DESCRIPTION="Member '${NAME}' - Volume '${VOLUME}' (${VOLUME_STATUS_DESC}) in RAID group '${VOLUME_STORAGEPOOL_NAME}' :"
 +      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="$DESCRIPTION $VOLUME_USED_FORMAT used on $VOLUME_TOTAL_FORMAT (${VOLUME_USED_POURCENT}%) | volume_used=${VOLUME_USED}B;$PERFDATA_WARNING;$PERFDATA_CRITICAL;0"
 +      fi
 +    fi
 +  fi
 +fi
 +
 +echo $DESCRIPTION
 +exit $STATE
 +</code>
 +==== check_snmp_dell_vrtx ====
 +<code>
 +#! /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, NAME-BATT, STATE-BATT, NAME-PSU, STATE-PSU, NAME-FAN, STATE-FAN, NAME-CDISK, STATE-CDISK, NAME-TEMP, STATE-TEMP
 +
 +COM=$2
 +IP=$1
 +CHECK=$3
 +
 +###################################
 +#1. Device Info
 +###################################
 +if [[ $CHECK == "INFO" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.1.3.12.0 | grep -oE 'STRING:.*' | cut -d ':' -f2 && snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.1.3.18.0 | grep -oE 'STRING:.*' | cut -d ':' -f2 && snmpwalk -c $COM -v 2c $IP .1.3.6.1.4.1.674.10892.5.1.3.6.0 | grep -oE 'STRING:.*' | cut -d ':' -f2
 +fi
 +
 +###################################
 +#2. Check CPU
 +###################################
 +if [[ $CHECK == "CPU" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.200.10.1.50.1 | grep -oE 'INTEGER:.*' | awk '{print $2}'
 +fi
 +
 +###################################
 +#3. Memory Detail
 +###################################
 +if [[ $CHECK == "DET-MEM" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.1100.50.1.14.1 | grep -oE 'INTEGER:.*' |  awk '{$2=$2/(1024^2);print "TOTAL:",$2,"GB"}'
 +elif [[ $CHECK == "STATE-MEM" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.200.10.1.27.1 | grep -oE 'INTEGER:.*' | awk '{print $2}'
 +fi
 +
 +###################################
 +#4. Check Physical Disk
 +###################################
 +if [[ $CHECK == "NAME-DISK" ]]
 +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 'STRING:.*' | cut -d ':' -f2
 +elif [[ $CHECK == "STATE-DISK" ]]
 +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 'INTEGER:.*' |  tr '\n' ' ' | awk '{print $2,$4,$6}'
 +fi
 +
 +###################################
 +#5. Check Virtual Disk
 +###################################
 +if [[ $CHECK == "NAME-VDISK" ]]
 +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 'STRING:.*' | cut -d ':' -f2
 +elif [[ $CHECK == "STATE-VDISK" ]]
 +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 'INTEGER:.*' |  tr '\n' ' ' | awk '{print $2,$4,$6}'
 +fi
 +
 +###################################
 +#6. Battery Detail
 +###################################
 +if [[ $CHECK == "NAME-BATT" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.600.50.1.7.1 | grep -oE 'STRING:.*' | cut -d ':' -f2
 +elif [[ $CHECK == "STATE-BATT" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.600.50.1.5.1 | grep -oE 'INTEGER:.*' | awk '{print $2}'
 +fi
 +
 +###################################
 +#7. Power Supply Detail
 +###################################
 +if [[ $CHECK == "NAME-PSU" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.600.12.1.15.1 | grep -oE 'STRING:.*' | cut -d ':' -f2
 +elif [[ $CHECK == "STATE-PSU" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.600.50.1.5.1 | grep -oE 'INTEGER:.*' |  tr '\n' ' ' | awk '{print $2,$4,$6}'
 +fi
 +
 +###################################
 +#8. Fan Detail
 +###################################
 +if [[ $CHECK == "NAME-FAN" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.600.12.1.15.1 | grep -oE 'STRING:.*' | cut -d ':' -f2
 +elif [[ $CHECK == "STATE-FAN" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.600.50.1.5.1 | grep -oE 'INTEGER:.*' |  tr '\n' ' ' | awk '{print $2,$4,$6}'
 +elif [[ $CHECK == "SPEED-FAN" ]]
 +then
 +snmpwalk -c $COM -v 2c $IP  .1.3.6.1.4.1.674.10892.5.4.700.12.1.6.1 | grep -oE 'INTEGER:.*' |  tr '\n' ' ' | awk '{print $2,$4,$6}'
 +fi
 +
 +###################################
 +#9. Check Disk Controller
 +###################################
 +if [[ $CHECK == "NAME-CDISK" ]]
 +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 'STRING:.*' | cut -d ':' -f2
 +elif [[ $CHECK == "STATE-CDISK" ]]
 +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 'INTEGER:.*' |  tr '\n' ' ' | awk '{print $2,$4,$6}'
 +fi
 +
 +###################################
 +#10. Temperature Celsius
 +###################################
 +if [[ $CHECK == "NAME-TEMP" ]]
 +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 'STRING:.*' | cut -d ':' -f2
 +elif [[ $CHECK == "STATE-TEMP" ]]
 +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 'INTEGER:.*' |  tr '\n' ' ' | awk '{print $2,$4,$6}'
 +fi
 +</code>
 +==== check_bdd_on_cluster ====
 +<code>
 +#!/bin/bash
 +############################################
 +# Script pour verifier les BDD en cluster
 +# Qu'elle BDD tourne sur quel cluster
 +# By adex036137
 +############################################
 +
 +# Vous pouvez decommanter la ligne ci-dessous si vous voulez voir le deroulement du script (debug)
 +#set -x
 +
 +# On suprime l'ancien fichier texte si il existe
 +rm -f '/usr/lib64/nagios/plugins/MSSQL-CLUSTER/'$4'.txt'
 +
 +# Les variables
 +WARN=$1
 +for VAR in $3
 +do
 +BDD=$VAR
 +COMM=$2
 +HOST1=$4
 +HOST2=${5:-Defaut}
 +HOST3=${6:-Defaut}
 +HOST4=${7:-Defaut}
 +HOST5=${8:-Defaut}
 +
 +# Recherche BDD sur 1ere machine
 +RESULT=`snmpwalk -c $COMM -v 2c $HOST1 HOST-RESOURCES-MIB::hrSWRunParameters | grep  -oE "i $BDD"`
 +# Recherche BDD sur 2eme machine
 +RESULT2=`snmpwalk -c $COMM -v 2c  $HOST2 HOST-RESOURCES-MIB::hrSWRunParameters | grep  -oE "i $BDD"`
 +# Recherche BDD sur 3eme machine
 +RESULT3=`snmpwalk -c $COMM -v 2c $HOST3 HOST-RESOURCES-MIB::hrSWRunParameters | grep  -oE "i $BDD"`
 +# Recherche BDD sur 4eme machine
 +RESULT4=`snmpwalk -c $COMM -v 2c  $HOST4 HOST-RESOURCES-MIB::hrSWRunParameters | grep  -oE "i $BDD"`
 +# Recherche BDD sur 5eme machine
 +RESULT5=`snmpwalk -c $COMM -v 2c $HOST5 HOST-RESOURCES-MIB::hrSWRunParameters | grep  -oE "i $BDD"`
 +
 +# Check des resultats
 +if [[ "$RESULT" =~ (i $BDD) ]]
 +then
 +echo "Service SQL Server $BDD is UP ON $HOST1" >> /usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt
 +elif [[ "$RESULT2" =~ (i $BDD) ]]
 +then
 +echo "Service SQL Server $BDD is UP ON $HOST2" >> /usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt
 +elif [[ "$RESULT3" =~ (i $BDD) ]]
 +then
 +echo "Service SQL Server $BDD is UP ON $HOST3" >> /usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt
 +elif [[ "$RESULT4" =~ (i $BDD) ]]
 +then
 +echo "Service SQL Server $BDD is UP ON $HOST4" >> /usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt
 +elif [[ "$RESULT5" =~ (i $BDD) ]]
 +then
 +echo "Service SQL Server $BDD is UP ON $HOST5" >> /usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt
 +# Autres resultats
 +else
 +echo "CRITICAL SQL Server $BDD is DOWN on all nodes" >> /usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt
 +fi
 +done
 +
 +# Tri des resultats et remonte des alertes
 +TRI=$(cat /usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt)
 +DUPL=`cat /usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt | awk '{print $8}' | sort -u | wc -l`
 +if [[ "$TRI" =~ (CRITICAL) ]]
 +then
 +sort -u "/usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt"
 +exit 2
 +elif [[ "$DUPL" < $WARN ]]
 +then
 +echo "WARNING more than one instances running on a node" && sort -u "/usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt"
 +exit 1
 +else
 +sort -u "/usr/lib64/nagios/plugins/MSSQL-CLUSTER/$HOST1.txt"
 +exit 0
 +fi
 +</code>
 +==== backup_veeam ====
 +<code>
 +#!/bin/bash
 +set -x
 +
 +
 +cd /usr/lib64/nagios/plugins
 +
 +HOST=$1
 +CHECK=$2
 +TIME=$3
 +
 +RESULT=$( ./check_centreon_nrpe3 -2 -t 60 -H $HOST -p 5666 -c check_veeam_backup -a "$CHECK" $TIME | grep -Eo 'finished with Success|OK:' )
 +# Si OK
 +if [[ $RESULT = 'OK:' ]] || [[ $RESULT = 'finished with Success' ]]
 +then
 +echo "OK au moins 1 backup lors des 48 dernieres heures"
 +exit 0
 +fi
 +
 +RESULT=$( ./check_centreon_nrpe3 -2 -t 60 -H $HOST -p 5666 -c check_veeam_backup -a "$CHECK" $TIME | egrep -o 'Warning:' | tail -n1 )
 +# Si Warning
 +if [[  $RESULT = 'Warning:' ]]
 +then
 +echo "Warning backup en alerte depuis 48h"
 +exit 1
 +fi
 +
 +RESULT=$( ./check_centreon_nrpe3 -2 -t 60 -H $HOST -p 5666 -c check_veeam_backup -a "$CHECK" $TIME | egrep -o 'failed:' | tail -n1 )
 +# Si critique
 +if [[  $RESULT = 'failed:' ]]
 +then
 +echo "KO aucun backup depuis plus de 48h"
 +exit 2
 +fi
 +</code>
 +==== backup_veeam2 ====
 +<code>
 +#!/bin/bash
 +#set -x
 +
 +
 +cd /usr/lib64/nagios/plugins
 +
 +HOST=$1
 +CHECK=$2
 +TIME=$3
 +
 +
 +RESULT=$( ./check_centreon_nrpe3 -2 -t 60 -H $HOST -p 5666 -c check_veeam_backup_copy -a "*\\$CHECK" $TIME | egrep -o 'OK:' | tail -n1 )
 +# Si OK
 +if [[ $RESULT = 'OK:' ]]
 +then
 +echo "OK au moins 1 backup lors des 48 dernieres heures"
 +exit 0
 +fi
 +
 +RESULT=$( ./check_centreon_nrpe3 -2 -t 60 -H $HOST -p 5666 -c check_veeam_backup_copy -a "*\\$CHECK" $TIME | egrep -o "failed:" | tail -n1 )
 +# Si critique
 +if [[  $RESULT = "failed:" ]]
 +then
 +echo "KO aucun backup depuis plus de 48h"
 +fi
 +exit 2
 +
 +
 +RESULT=$( ./check_centreon_nrpe3 -2 -t 60 -H $HOST -p 5666 -c check_veeam_backup_copy -a "*\\$CHECK" $TIME | egrep -o 'Warning:' | tail -n1 )
 +# Si Warning
 +if [[  $RESULT = 'Warning:' ]]
 +then
 +echo "Warning backup en alerte depuis 48h"
 +exit 1
 +fi
 +</code>
 +==== check_vs-certif_f5 ====
 +<code>
 +#!/bin/bash
 +# set -x
 +# Variable
 +HOST=$1
 +URL=${2:-.*}
 +COM=${3:-public}
 +VER=${4:-2c}
 +
 +
 +# On recupere l'id de l'url
 +OID=$(snmpwalk -c $COM -v $VER $HOST .1.3.6.1.4.1.3375.2.1.15.1.2.1.1 | grep $2 | awk '{print $1}' | cut -d '.' -f10-)
 +
 +# 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 '{print $4}')
 +
 +# Calcul entre la date actuelle et la date du certif. RESULT= date unix convertie en date lisible.
 +TODAY=$(date +%s)
 +RESULT=$(date -d @$TMP +'%Y-%m-%d')
 +DIFF=$(echo "($TMP-$TODAY)/86400" | bc)
 +
 +# Si pas de retour
 +if [[ -z $OID ]]
 +then
 +echo "L'url ou le F5 ne sont pas bien renseigne"
 +exit 3
 +
 +# Si moins de 15 jours
 +elif [[ "$DIFF" -lt "15" ]]
 +then
 +echo "Critique $URL expire le $RESULT dans moins de $DIFF jours"
 +exit 2
 +fi
 +
 +# Si moins de 30 jours
 +if [[ "$DIFF" -lt "30" ]]
 +then
 +echo "Alerte $URL expire le $RESULT dans moins de $DIFF jours"
 +exit 1
 +
 +# Si OK
 +else
 +echo "OK $URL expire le $RESULT"
 +exit 0
 +fi
 +</code>
centreon/scripts-linux.1688553192.txt.gz · Dernière modification : 2024/12/27 06:28 (modification externe)