Vous êtes ici:

Menu

Amélioration du plugin Quota Tree

Voici une petite amélioration de notre plugin Quota Tree pour un Nas NS 42 G d’EMC, suite à un retour d’expérience. En effet, nous n’avions pas géré la date d’expiration du soft Limit. Etant donné le nombre limité d’état dans Nagios, nous avons décidé de mettre à l’état critique l’événement Soft Limit quand sa date d’expiration est dépassée. Une correction a été apportée au total de quota utilisé et au nombre de quota à l’état OK. Ce qui donne le script suivant
#!/bin/bash
# réalisé le 06/04/2010
# script pour retourner le nb de Quota tree ainsi que le nombre de soft limite et hard limite
# paramètre $1 : nom du File System

# variable d'environement pour la commande nas_quota
NAS_DB=/nas
export NAS_DB

# pourcentage à atteindre pour la valeur critique
quotaHard=97

LUsed=`/nas/bin/nas_quotas -report -tree -fs $1 | grep "|#" | cut -d "|" -f3`
LSoft=`/nas/bin/nas_quotas -report -tree -fs $1 | grep "|#" | cut -d "|" -f4`
LHard=`/nas/bin/nas_quotas -report -tree -fs $1 | grep "|#" | cut -d "|" -f5`
LExpire=`/nas/bin/nas_quotas -report -tree -fs $1 | grep "|#" | cut -d "|" -f6`
indice=0
for i in $LUsed
do
let indice=$indice+1
TabUsed[$indice]=$i
# echo ${TabUsed[$indice]}
done
indice=0
for i in $LSoft
do
let indice=$indice+1
TabSoft[$indice]=$i
# echo ${TabSoft[$indice]}
done
indice=0
for i in $LHard
do
let indice=$indice+1
TabHard[$indice]=$i
# echo ${TabHard[$indice]}
done
indiceExpire=0
for i in $LExpire
do
let indiceExpire=$indiceExpire+1
TabExpire[$indiceExpire]=$i
# echo ${TabExpire[$indiceExpire]}
done
# on récupère le nombre de quota utilisé
qteUsed=$indice
qteOk=0
qteSoft=0
qteHard=0

for j in `seq $indice` ; do
let limiteHard=$((quotaHard*TabHard[$j]/100))
if [ ${TabUsed[$j]} -gt $limiteHard ]
then
let qteHard=$qteHard+1
else
if [ ${TabUsed[$j]} -gt ${TabSoft[$j]} ]
then
let qteSoft=$qteSoft+1
else
let qteOk=$qteOk+1
fi
fi
done
# Si les soft limit arrivent à expiration passer en mode hard donc Critical
for j in `seq $indiceExpire` ; do
if [ ${TabExpire[$j]} = "EXPIRED" ]
then
let qteHard=$qteHard+1
fi
done
info="Erreur!"
if [ $qteHard -gt 0 ]
then
info="CRITICAL"
info_valeur=2
else
if [ $qteSoft -gt 0 ]
then
info="WARNING"
info_valeur=1
else
info="OK"
info_valeur=0
fi
fi

Voici un extrait de la commande nas_quotas
[nasadmin@NS42G ~]$ nas_quotas -tree -report -fs FILESYSTEM
Report for tree quotas on filesystem FS_GROUPE mounted on /FS_GROUPE
+------------+---------------------------------+-------------------------------+
| Tree | Bytes Used (1K) | Files |
+------------+--------+-------+-------+--------+--------+------+------+--------+
| | Used | Soft | Hard |Timeleft| Used | Soft | Hard |Timeleft|
+------------+--------+-------+-------+--------+--------+------+------+--------+
|#1 | 599976|1843200|2048000| | 222| 0| 0| |
|#2 |40793432|55296000|61440000| | 53564| 0| 0| |
......
|#7 | 5540720|5529600|6144000| 1.2days| 5209| 0| 0| |
|#8 | 3181488|5529600|6144000| | 11795| 0| 0| |
........
|#29 |26412200|27648000|30720000| | 4371| 0| 0| |
|#30 | 164840| 184320| 204800| | 857| 0| 0| |
|#31 | 16| 55296| 61440| | 5| 0| 0| |
|#32 | 188432| 184320| 204800| EXPIRED| 557| 0| 0| |
|#33 | 426000| 921600|1024000| | 203| 0| 0| |
|#34 | 5945648|9216000|10240000| | 20215| 0| 0| |
|#35 |72178608|92160000|102400000| | 100479| 0| 0| |
|#36 | 3028680|5529600|6144000| | 16383| 0| 0| |
+------------+--------+-------+-------+--------+--------+------+------+--------+
done

Ce qui donne pour le plugin Nagios
[nasadmin@NS42G ~]$ ./quotasNum1 FILESYSTEM
QuotaTree CRITICAL - Quota Tree sur FILESYSTEM sont CRITICAL TOTAL: 36 LIMITE SOFT: 2 LIMITE HARD: 1 | ok=34 soft=2 hard=1
blog comments powered by Disqus
 Vous êtes ici:

Nous utilisons des cookies pour nous permettre de mieux comprendre comment le site est utilisé. En continuant à utiliser ce site, vous acceptez cette politique.