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 12:26] – michel | centreon:scripts-linux [2024/12/27 06:28] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 429: | Ligne 429: | ||
exit 3 | exit 3 | ||
fi | 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 ==== | ||
+ | < | ||
+ | #!/bin/bash | ||
+ | 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 ==== | ==== check_netapp_lun_size ==== | ||
Ligne 529: | Ligne 645: | ||
else | else | ||
echo " | 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 ==== | ||
+ | < | ||
+ | #!/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=/ | ||
+ | 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 | fi | ||
</ | </ | ||
Ligne 751: | Ligne 1019: | ||
echo "Value is $state: $RESULT|connections=$RESULT; | echo "Value is $state: $RESULT|connections=$RESULT; | ||
exit $output | exit $output | ||
+ | </ | ||
+ | ==== check_sla_dispo_process_Linux.sh ==== | ||
+ | < | ||
+ | #!/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:: | ||
+ | WARN=${4: | ||
+ | CRIT=${5: | ||
+ | FICHIER+=($(snmpwalk -c $COMM -v 2c $HOST HOST-RESOURCES-MIB:: | ||
+ | done | ||
+ | RESULT=$(printf " | ||
+ | |||
+ | # Remontee des alertes | ||
+ | # Si critique | ||
+ | if [[ " | ||
+ | then | ||
+ | echo " | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si warning | ||
+ | if [[ " | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | |||
+ | # Si OK | ||
+ | else | ||
+ | echo "OK: $RESULT services: $3 ' | ||
+ | exit 0 | ||
+ | fi | ||
+ | </ | ||
+ | ==== check_sla_dispo_services_windows.sh ==== | ||
+ | < | ||
+ | #!/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: | ||
+ | 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 [[ " | ||
+ | then | ||
+ | echo " | ||
+ | exit 2 | ||
+ | fi | ||
+ | |||
+ | # Si warning | ||
+ | if [[ " | ||
+ | then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | |||
+ | Si OK | ||
+ | else | ||
+ | echo "OK: $RESULT services: $SERV ' | ||
+ | exit 0 | ||
+ | fi | ||
</ | </ | ||
==== check_snmp_dell_equalogic ==== | ==== check_snmp_dell_equalogic ==== | ||
Ligne 1617: | Ligne 1974: | ||
fi | fi | ||
</ | </ | ||
+ | ==== backup_veeam ==== | ||
+ | < | ||
+ | #!/bin/bash | ||
+ | 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 ==== | ||
+ | < | ||
+ | #!/bin/bash | ||
+ | #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 ==== | ||
+ | < | ||
+ | #!/bin/bash | ||
+ | # set -x | ||
+ | # Variable | ||
+ | HOST=$1 | ||
+ | URL=${2: | ||
+ | COM=${3: | ||
+ | VER=${4: | ||
+ | |||
+ | |||
+ | # 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 ' | ||
+ | |||
+ | # 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 | ||
+ | </ |