Announcement

Collapse
No announcement yet.

Plugin check_snmp_link_error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Plugin check_snmp_link_error

    BOnjour, j'aimerais avoir quelques informations sur ce plugin svp :

    Plugin check_snmp_link_error

    En effet, je voudrais savoir si ce plugin conviendrait pour voir si une liaison entre 2 routeurs sont UP ou DOWN.



    Par exemple, je suis en A (nagios etc installé ici). Je voudrais savoir si la communication entre B et C est possible En effet, je peux "pinguer" B ou C pour voir si ils sont UP ==> AB = OK, AC = OK, mais ça ne me dit pas si BC = OK. ^^

    SI ce plugin n'est pas bon, avez-vous un plugin à me conseiller, et si éventuellement un tel plugin n'existe pas, est-ce possible de le "créer" ?

    Merci de vos réponses !

    Je trouve plus le lien du script, je colles donc le script ici :

    Code:
    #!/bin/sh
    #
    # v0.01 Created by MBr on 24-12-2005
    # version 0.19
    #
    # Checks, using SNMP, if there are any ingoing/outgoing link errors on Cisco switches.
    #
    CISCOERROR=0
    
    SWITCH=$1
    
    if [[ ! "$2" == "" ]]; then
        READ_COMMUNITY=$2
    else
        READ_COMMUNITY=public
    fi
    # FIXME: I really don't know how many errors/day are non-critical
    if [[ ! "$3" == "" ]]; then
        ERROR_TRESHOLD_IN=$3        # per day (minimum amount)
    else
        ERROR_TRESHOLD_IN=4
    fi
    # (limited to 500 in total now)
    if [[ ! "$4" == "" ]]; then
        ERROR_TRESHOLD_IN_MAX=$4 # upper-limit in total
    else
        ERROR_TRESHOLD_IN_MAX=500 #
    fi
    # In general, link OUT_ERRORS should not occur
    if [[ ! "$5" == "" ]]; then
        ERROR_TRESHOLD_OUT_MAX=$5   # in total
    else
        ERROR_TRESHOLD_OUT_MAX=1
    fi
    
    
    function check_cisco {
        # LINK=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex`
        # Somehow MIB entry fails on my system, trying numerical one
        LINK=`/usr/bin/snmpgetnext -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.2.2.1.1.1`
    
        if [[ "$LINK" == "" ]]; then
            CISCOERROR=1
            STATUS="Could not obtain first link interface using SNMP on $SWITCH! (SNMP read is enabled for $READ_COMMUNITY?!)"
        else
            NEXTTABLE=`/usr/bin/snmpgetnext -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.2.2.1.2`
            UPTIME=`/usr/bin/snmpgetnext -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.1.3`
            # UPTIME=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .iso.org.dod.internet.mgmt.mib-2.system.sysUpTime`
            UPTIME=`/usr/bin/snmpgetnext -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.1.3`
            UPDAYS=`echo $UPTIME|cut -d':' -f1`
            # FIXME: I really don't know how many errors/day are non-critical
            # ERROR TRESHOLD = previous ERROR TRESHOLD * (UPTIME DAYS + 1)
            # (otherwise it triggers on 0 errors the first day)
            ERROR_TRESHOLD_IN=`expr $ERROR_TRESHOLD_IN \* $(expr $UPDAYS + 1)`
            if [ $ERROR_TRESHOLD_IN -ge $ERROR_TRESHOLD_IN_MAX ];then
                ERROR_TRESHOLD_IN=$ERROR_TRESHOLD_IN_MAX
            fi
            # In general, link OUT_ERRORS should not occur
            # ERROR_TRESHOLD_OUT=`expr $ERROR_TRESHOLD_OUT \* $(expr $UPDAYS + 1)`
            ERROR_TRESHOLD_OUT=$ERROR_TRESHOLD_OUT_MAX
            SYSDESCR=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0|cut -d'(' -f3|grep ')'|cut -d')' -f1`
            # SYSDESCR=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.1.1.0|cut -d'(' -f3|cut -d')' -f1`
            # echo "SYSDESCR=$SYSDESCR"
            # exit 1
        fi
    #    echo "$LINK"
    
    #    while [[ "$LINK" != "$LINK_PREV" && "$LINK" != "$NEXTTABLE" ]]
        while [[ "$LINK" != "$LINK_PREV" && "$LINK" != "$NEXTTABLE" && "$LINK" != "" ]]
        do
            LINK_PREV=$LINK
    #       IN_ERRORS=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.2.2.1.14.$LINK`
            IN_ERRORS=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifInErrors.$LINK`
    #       OUT_ERRORS=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.2.2.1.20.$LINK`
            OUT_ERRORS=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifOutErrors.$LINK`
    
    #       if [[ "$IN_ERRORS" -ne 0 || "$OUT_ERRORS" -ne 0 ]];then
            if [[ "$IN_ERRORS" -ge $ERROR_TRESHOLD_IN || "$OUT_ERRORS" -ge $ERROR_TRESHOLD_OUT ]];then
    #           LINKNAME=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.2.2.1.2.$LINK`
                LINKNAME=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr.$LINK`
                # DESCR=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.4.1.9.2.2.1.1.28.$LINK|cut -d' ' -f1`
                DESCR=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .iso.org.dod.internet.private.enterprises.9.2.2.1.1.28.$LINK|cut -d' ' -f1`
    
                if [[ `echo $DESCR|cut -d'"' -f2` ]]; then
                    DESCR=' ''('$DESCR'"'')'
                else
                    DESCR=
                fi
                # FIXME: We don't need VLAN and NULL interfaces etc..
                # Often the IN_error value for VLAN is either the max value or '0'
                if [ `echo  $LINKNAME|grep -i -e"Ethernet"` ]; then
                    STATUS="${STATUS} $LINKNAME$DESCR: IN_ERRORS: $IN_ERRORS OUT_ERRORS: $OUT_ERRORS;"
                    CISCOERROR=1
                fi
            fi
            # LINK=`/usr/bin/snmpget -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex.$LINK`
            LINK=`/usr/bin/snmpgetnext -OvUq -v 1 -c $READ_COMMUNITY $SWITCH .1.3.6.1.2.1.2.2.1.1.$LINK`
            # echo "LINK=$LINK"
        done
    }
    
    check_cisco
    
    if [[ "$CISCOERROR" == "1" ]]; then
        echo "$SYSDESCR Uptime: $UPDAYS day(s):$STATUS  ERROR_TRESHOLD_IN=$ERROR_TRESHOLD_IN; ERROR_TRESHOLD_OUT=$ERROR_TRESHOLD_OUT"
        echo "CISCOERROR=$CISCOERROR"
        exit 2
    else
        echo "$SYSDESCR Uptime: $UPDAYS day(s): ERROR_TRESHOLD_IN=$ERROR_TRESHOLD_IN; ERROR_TRESHOLD_OUT=$ERROR_TRESHOLD_OUT; All link interfaces on $SWITCH are okay "
        exit 0
    fi
    
    exit 1
    Last edited by seb974; 18 July 2007, 13:32.

  • #2
    Up :rolleyes:

    Comment


    • #3
      up, pas d'idée ?

      Comment

      Working...
      X