Changeset 2332 in /cluster/svnroot


Ignore:
Timestamp:
Apr 13, 2010 11:27:34 AM (11 years ago)
Author:
fitz
Message:

Add timeout feature to allowall (#493)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bccd-ng/trunk/trees/bin/bccd-allowall

    r2322 r2332  
    11#!/bin/bash
     2
     3COUNT=5
     4INTERVAL=5
    25
    36write_key() {
     
    1720find_keys() {
    1821        DIR=$1
    19         for HOST in `find /tmp/bccd/ -mindepth 1 -maxdepth 1 -type d|sed -e 's!/tmp/bccd/!!g'`; do
    20                 NUMKEYS=`snmpget -Ls d -OQv -c public -v 1 $HOST .1.3.6.1.4.1.2021.83.3.1.3.12.115.115.104.95.107.101.121.95.108.105.115.116 2> /dev/null`
     22
     23        for HOST in `find $DIR -mindepth 1 -maxdepth 1 -type d|sed -e "s|$DIR/*||g"`; do
     24                UR="$DIR/$HOST/count"
     25
     26                NUMKEYS=`snmpget -Lsd -OQv -c public -v 1 $HOST .1.3.6.1.4.1.2021.83.3.1.3.12.115.115.104.95.107.101.121.95.108.105.115.116 2> /dev/null`
     27
     28                # Test success of snmpget, reset unreachable count if successful
    2129                if test $? -ne 0; then
    2230                        NUMKEYS=0
     31                        echo >> $UR
     32                else
     33                        echo -n > $UR
    2334                fi
     35
    2436                for((i=1;i<=$NUMKEYS;i++)); do
    25                         KEY=`snmpget -Ls d -OQv -c public -v 1 $HOST .1.3.6.1.4.1.2021.83.4.1.2.8.115.115.104.95.107.101.121.115.$i|sed -e 's!"!!g' 2> /dev/null`
     37                        KEY=`snmpget -Lsd -OQv -c public -v 1 $HOST .1.3.6.1.4.1.2021.83.4.1.2.8.115.115.104.95.107.101.121.115.$i|sed -e 's!"!!g' 2> /dev/null`
    2638                        write_key "$KEY"
    2739                done
     40
     41                # if unreachable for $COUNT attempts, stop trying
     42                if test `wc -l $UR | awk '{print $1}'` -eq $COUNT; then
     43                        rm -fr $DIR/$HOST
     44                fi
    2845        done
    2946}
     
    4360done
    4461
    45 #if automode is selected, then we keep ourselves running every 5 sec
     62#if automode is selected, then we keep ourselves running every $INTERVAL sec
    4663if $AUTO ; then
    47         sleep 5
     64        sleep $INTERVAL
    4865        while true ; do
    49                 sleep 5
     66                sleep $INTERVAL
    5067                if test -d /tmp/$USER; then
    5168                        find_keys /tmp/$USER
Note: See TracChangeset for help on using the changeset viewer.