On Tue, Sep 10, 2013 at 12:15:53PM +0200, Alfonso Camacho wrote: > Saludos: > > Estoy currando en un script alojado en un servidor Debian Squeeze cuya misión > es capturar información de uso de disco y volumenes de servidores Windows y > cabinas NetApp mediante SNMP (se usan checks de Nagios para lanzar estas > consultas). > > El problemas es que como la red de la cual obtener estos datos es bastante > grande se tiene que lanzar de manera recursiva para todos los hosts, unidades > y volumenes que hay definidos en varios ficheros de configuración, para lo > cual se ha creado una rutina for para cada check: > > > # ------------- DECLARACION DE VARIABLES ------------- > PATHBASE="/usr/local/bin/reports/capacitat" > TMPBASE="$PATHBASE/tmp" > INCBASE="$PATHBASE/incoming" > CONFBASE="$PATHBASE/etc" > VOLCONF=`cat $CONFBASE/volumes.conf` > EXCLUDECONF="$CONFBASE/exclude.conf" > STORAGEWINBIN="$PATHBASE/bin/check_snmp_storage.pl" > STORAGENETAPPBIN="$PATHBASE/bin/check_netapp_du.pl" > HOSTBIN="$PATHBASE/bin/dynhosts/run.sh" > SNMP="LT1" > WARN_LEVEL="80" > CRIT_LEVEL="95" > > > ########################################################## > ## Extraccion y generacion de reports servidores Windows # > ########################################################## > > # Comprobacion de la existencia de fichero de configuracion 'hosts.conf'. > if [[ -s $CONFBASE/hosts-win_$DATE.conf ]] ; then > echo "OK. Fichero de configuracion 'hosts-win_$DATE.conf' encontrado" > else > $HOSTBIN > HOSTSWIN=`cat $CONFBASE/hosts-win_$DATE.conf` > fi > > # Creacion de reports temporales por volumen > for MULTIHOSTSWIN in $HOSTSWIN > do > $STORAGEWINBIN -H $MULTIHOSTSWIN -C $SNMP -w $WARN_LEVEL -c > $CRIT_LEVEL -m ^[C]: | cut -f4 -d ':' | xargs echo $MULTIHOSTSWIN:C: >> > $TMPBASE/c.txt > $STORAGEWINBIN -H $MULTIHOSTSWIN -C $SNMP -w $WARN_LEVEL -c > $CRIT_LEVEL -m ^[D]: | cut -f4 -d ':' | xargs echo $MULTIHOSTSWIN:D: >> > $TMPBASE/d.txt > $STORAGEWINBIN -H $MULTIHOSTSWIN -C $SNMP -w $WARN_LEVEL -c > $CRIT_LEVEL -m ^[E]: | cut -f4 -d ':' | xargs echo $MULTIHOSTSWIN:E: >> > $TMPBASE/e.txt > $STORAGEWINBIN -H $MULTIHOSTSWIN -C $SNMP -w $WARN_LEVEL -c > $CRIT_LEVEL -m ^[F]: | cut -f4 -d ':' | xargs echo $MULTIHOSTSWIN:F: >> > $TMPBASE/f.txt > $STORAGEWINBIN -H $MULTIHOSTSWIN -C $SNMP -w $WARN_LEVEL -c > $CRIT_LEVEL -m ^[G]: | cut -f4 -d ':' | xargs echo $MULTIHOSTSWIN:G: >> > $TMPBASE/g.txt > $STORAGEWINBIN -H $MULTIHOSTSWIN -C $SNMP -w $WARN_LEVEL -c > $CRIT_LEVEL -m ^[H]: | cut -f4 -d ':' | xargs echo $MULTIHOSTSWIN:H: >> > $TMPBASE/h.txt > $STORAGEWINBIN -H $MULTIHOSTSWIN -C $SNMP -w $WARN_LEVEL -c > $CRIT_LEVEL -m ^[I]: | cut -f4 -d ':' | xargs echo $MULTIHOSTSWIN:I: >> > $TMPBASE/i.txt > done > > > ###################################################### > ## Extraccion y generacion de reports cabinas NetApp # > ###################################################### > > # Comprobacion de la existencia de fichero de configuracion 'hosts.conf'. > if [[ -s $CONFBASE/hosts-netapp_$DATE.conf ]] ; then > echo "OK. Fichero de configuracion 'hosts-netapp_$DATE.conf' > encontrado" > else > $HOSTBIN > HOSTSNETAPP=`cat $CONFBASE/hosts-netapp_$DATE.conf` > fi > > # Creacion de reports temporales por volumen > for MULTIHOSTSNETAPP in $HOSTSNETAPP ; do for MULTIVOLNETAPP in $VOLCONF > do > $STORAGENETAPPBIN -H $MULTIHOSTSNETAPP -w $WARN_LEVEL -c $CRIT_LEVEL > -v $MULTIVOLNETAPP | xargs echo $MULTIHOSTSNETAPP : >> $TMPBASE/netapp.txt > done > done > > Lo raro del caso es que solo se ejecuta el primer for que encuentra en el > script, pasando de ejecutar el que encuentra en segundo lugar. Incluso se > partido el script en scripts independientes haciendo las llamadas desde el > script principal y el comportamiento es el mismo. > > Alguna idea o sugerencia? Alguien ve lo que estoy haciendo mal? > > Muchas gracias. > >
El segundo for no lleva el punto y coma. Ahora no puedo mirarlo con más detalle, pero bash tiene peculiaridades de este estilo. Mira tambien de ejecutarlo con sh -x o bien poniendo echos a modo de depuración para saber el recorrido de la rutina. -- Adrià García-Alzórriz ad...@fsfe.org GPG Key: 09494C14 Cada situación es el mejor axioma para progresar en el camino. -- Kalfried Durkhei.
signature.asc
Description: Digital signature