net-snmp and bash - SNMP

This is a discussion on net-snmp and bash - SNMP ; I have been working on a bash script to work with net-snmp . That will do a snmpget on a list of oids and run off a list of ips for our network these devices are all the same oids ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: net-snmp and bash

  1. net-snmp and bash

    I have been working on a bash script to work with net-snmp . That will do a
    snmpget on a list of oids and run off a list of ips for our network these
    devices are all the same oids just different ip addy. The following explains
    a little I guess.
    #!/bin/bash
    iplist=/tmp/ip.list # list of IP addresses
    log=/var/log/snmp.log # log file
    oids="1.3.6.1.4.1.664.2.444.1.1.1.1.1"
    community=public # password

    while read addr
    do
    for oid in $oids
    do
    snmpget "$addr" "$community" "$oid"
    done
    done < "$iplist" > "$log"


    adtran_get: 22 lines, 730 characters.

    su-2.05b# ./adtran_get
    snmpget: Unknown host (Message too long)
    snmpget: Unknown host (Message too long)
    snmpget: Unknown host (Message too long)
    snmpget: Unknown host
    snmpget: Unknown host
    #############
    Those are some errors but the main thing I want to do is access the ip.list
    and a list of different oids
    Example:
    1. OBJECT = DS0 STATUS
    2.OID = 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    3.WHAT WE WANT TO KNOW VIA EMAIL =
    IF ("A" + "N" + "E" + "T") > 600



    I want it to output to a snmp.log and some how filter and send out mail on
    certain changes in trap events.
    I read over and over net-snmp and since I am somewhat a newb to perl and
    snmp some of it is greek but I know the traptoemail has capabilities of
    doing this and filtering out via #traphandles and sending this out. Just
    need a kick in the right direction.




  2. Re: net-snmp and bash

    Which version of net-snmp are you using?
    Are you sure that the command line for snmpget tool is correct?
    The latest version of net-snmp wants the options in the form:
    snmpget -c [community] [hostname[ort]] [OID]
    with the [OID] that begins with a '.' (if it is an absolute OID]
    (for example ".1.3.6.1.4.1.664.2.444.1.1.1.1.1")

    G. Torrielli


  3. Re: net-snmp and bash

    It is the latest version. Also inteh script when I use snmpget I get the
    following.
    su-2.05b# snmpget -v 1 -c public 172.18.60.246:161
    1.3.6.1.4.1.664.2.444.1.1.1.1.1
    Error in packet
    Reason: (noSuchName) There is no such variable name in this MIB.
    Failed object: SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1
    ### But however when I do a walk
    su-2.05b# snmpwalk -v 1 -c public 172.18.60.246:161
    1.3.6.1.4.1.664.2.444.1.1.1.1.1
    SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.4 = STRING:
    "------------------------"
    SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.5 = STRING:
    "------------------------"
    SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.6 = STRING:
    "------------------------"
    SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.7 = STRING:
    "------------------------"
    I start getting the information I need . I was wondering what was going on.
    I would like this script to check many oids from the certain enterprise
    device and this device is located in many of our markets and has multiple
    ips that need to be checked as well. So If I get this to run at certain time
    at night via cron this script and somehow have the log filter out certain
    changes in trap events and email those to a certain address this would rock
    but I have reached a stalemate in my net-snmp project to make all this come
    together . Any kickstart would help thanks
    "Ramblyn" wrote in message
    news:ixXib.283606$R32.9318187@news2.tin.it...
    > Which version of net-snmp are you using?
    > Are you sure that the command line for snmpget tool is correct?
    > The latest version of net-snmp wants the options in the form:
    > snmpget -c [community] [hostname[ort]] [OID]
    > with the [OID] that begins with a '.' (if it is an absolute OID]
    > (for example ".1.3.6.1.4.1.664.2.444.1.1.1.1.1")
    >
    > G. Torrielli
    >




  4. Re: net-snmp and bash


    Monster wrote:
    > It is the latest version. Also inteh script when I use snmpget I get the
    > following.
    > su-2.05b# snmpget -v 1 -c public 172.18.60.246:161
    > 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    > Error in packet
    > Reason: (noSuchName) There is no such variable name in this MIB.
    > Failed object: SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1
    > ### But however when I do a walk
    > su-2.05b# snmpwalk -v 1 -c public 172.18.60.246:161
    > 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.4 = STRING:
    > "------------------------"
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.5 = STRING:
    > "------------------------"
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.6 = STRING:
    > "------------------------"
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.7 = STRING:
    > "------------------------"
    > I start getting the information I need . I was wondering what was going on.
    > I would like this script to check many oids from the certain enterprise
    > device and this device is located in many of our markets and has multiple
    > ips that need to be checked as well. So If I get this to run at certain time
    > at night via cron this script and somehow have the log filter out certain
    > changes in trap events and email those to a certain address this would rock
    > but I have reached a stalemate in my net-snmp project to make all this come
    > together . Any kickstart would help thanks
    > "Ramblyn" wrote in message
    > news:ixXib.283606$R32.9318187@news2.tin.it...
    >
    >>Which version of net-snmp are you using?
    >>Are you sure that the command line for snmpget tool is correct?
    >>The latest version of net-snmp wants the options in the form:
    >>snmpget -c [community] [hostname[ort]] [OID]
    >>with the [OID] that begins with a '.' (if it is an absolute OID]
    >>(for example ".1.3.6.1.4.1.664.2.444.1.1.1.1.1")
    >>
    >>G. Torrielli


    Dan-

    Did you figure this as a FAQ?

    The OID you've used is likely identical to the object type definition in
    the MIB module. To retrieve an INSTANCE of an object type using an SNMP
    Get request, you've got to append the instance (or index) to the object
    type OID. BTW, scalars take an istance of ".0".

    Anyway, you're likely onto a better algorithm- using the snmpwalk
    operation. This operation starts with the passed OID as the subtree
    under which all object instances will be retrieved using iterations of
    the SNMP GetNext request. In this case, you've asked for all instances
    of your object name.

    Seems to do the job you need?

    Regards,

    Mark


  5. Re: net-snmp and bash

    Monster wrote:
    > su-2.05b# snmpget -v 1 -c public 172.18.60.246:161 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    > Error in packet
    > Reason: (noSuchName) There is no such variable name in this MIB.
    > Failed object: SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1
    > ### But however when I do a walk
    > su-2.05b# snmpwalk -v 1 -c public 172.18.60.246:161
    > 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.4 = STRING: "------------------------"


    Note, that when you do the snmpwalk you get the value for
    SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.4 but that is not the value
    you try to snmpget ...

    /Niels

    --
    Niels Baggesen -- @home -- Århus -- Denmark -- niels@baggesen.net
    The purpose of computing is insight, not numbers -- R W Hamming

  6. Re: net-snmp and bash

    The OID you are using is a table column, not an instance, so that is why the
    Get doesn't find it. The walk reveals that there are multiple instances of
    that column starting at ifIndex 4 in your case. So if you want to get a
    specific instance use snmpget -v 1 -c public 172.18.60.246
    1.3.6.1.4.1.664.1.1.1.1.1.4

    HTH,
    Phil

    "Monster" wrote in message
    news:vot4ekhi061410@corp.supernews.com...
    > It is the latest version. Also inteh script when I use snmpget I get the
    > following.
    > su-2.05b# snmpget -v 1 -c public 172.18.60.246:161
    > 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    > Error in packet
    > Reason: (noSuchName) There is no such variable name in this MIB.
    > Failed object: SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1
    > ### But however when I do a walk
    > su-2.05b# snmpwalk -v 1 -c public 172.18.60.246:161
    > 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.4 = STRING:
    > "------------------------"
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.5 = STRING:
    > "------------------------"
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.6 = STRING:
    > "------------------------"
    > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.7 = STRING:
    > "------------------------"
    > I start getting the information I need . I was wondering what was going

    on.
    > I would like this script to check many oids from the certain enterprise
    > device and this device is located in many of our markets and has multiple
    > ips that need to be checked as well. So If I get this to run at certain

    time
    > at night via cron this script and somehow have the log filter out certain
    > changes in trap events and email those to a certain address this would

    rock
    > but I have reached a stalemate in my net-snmp project to make all this

    come
    > together . Any kickstart would help thanks
    > "Ramblyn" wrote in message
    > news:ixXib.283606$R32.9318187@news2.tin.it...
    > > Which version of net-snmp are you using?
    > > Are you sure that the command line for snmpget tool is correct?
    > > The latest version of net-snmp wants the options in the form:
    > > snmpget -c [community] [hostname[ort]] [OID]
    > > with the [OID] that begins with a '.' (if it is an absolute OID]
    > > (for example ".1.3.6.1.4.1.664.2.444.1.1.1.1.1")
    > >
    > > G. Torrielli
    > >

    >
    >





  7. Re: net-snmp and bash


    Mark Ellison & Ramblyn seemed to make this clear. Did it help? They both
    made specific suggestions which make sense and run the way you were hoping.
    I duplicated your prototype with their suggestions for using snmpwalk
    instead of snmpget since this is a table of instances, and made the OID
    absolute with a preceding period.

    From your netsnmp output it looks like you don't have the enterprise MIBs
    loaded. Netsnmp will accept OID names and interpret your output if you put
    them in the MIBs directory, but for your application, the numeric values are
    efficient, but error prone if you have to use a lot..

    Phil




  8. Re: net-snmp and bash

    Yes it is correct I loaded mibs and I am going to try that should the mibs
    be txt? lik mymib.mib.txt?


    "Phil Bergstresser" wrote in message
    news:1066399602.311154@cache3...
    > The OID you are using is a table column, not an instance, so that is why

    the
    > Get doesn't find it. The walk reveals that there are multiple instances of
    > that column starting at ifIndex 4 in your case. So if you want to get a
    > specific instance use snmpget -v 1 -c public 172.18.60.246
    > 1.3.6.1.4.1.664.1.1.1.1.1.4
    >
    > HTH,
    > Phil
    >
    > "Monster" wrote in message
    > news:vot4ekhi061410@corp.supernews.com...
    > > It is the latest version. Also inteh script when I use snmpget I get the
    > > following.
    > > su-2.05b# snmpget -v 1 -c public 172.18.60.246:161
    > > 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    > > Error in packet
    > > Reason: (noSuchName) There is no such variable name in this MIB.
    > > Failed object: SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1
    > > ### But however when I do a walk
    > > su-2.05b# snmpwalk -v 1 -c public 172.18.60.246:161
    > > 1.3.6.1.4.1.664.2.444.1.1.1.1.1
    > > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.4 = STRING:
    > > "------------------------"
    > > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.5 = STRING:
    > > "------------------------"
    > > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.6 = STRING:
    > > "------------------------"
    > > SNMPv2-SMI::enterprises.664.2.444.1.1.1.1.1.7 = STRING:
    > > "------------------------"
    > > I start getting the information I need . I was wondering what was going

    > on.
    > > I would like this script to check many oids from the certain enterprise
    > > device and this device is located in many of our markets and has

    multiple
    > > ips that need to be checked as well. So If I get this to run at certain

    > time
    > > at night via cron this script and somehow have the log filter out

    certain
    > > changes in trap events and email those to a certain address this would

    > rock
    > > but I have reached a stalemate in my net-snmp project to make all this

    > come
    > > together . Any kickstart would help thanks
    > > "Ramblyn" wrote in message
    > > news:ixXib.283606$R32.9318187@news2.tin.it...
    > > > Which version of net-snmp are you using?
    > > > Are you sure that the command line for snmpget tool is correct?
    > > > The latest version of net-snmp wants the options in the form:
    > > > snmpget -c [community] [hostname[ort]] [OID]
    > > > with the [OID] that begins with a '.' (if it is an absolute OID]
    > > > (for example ".1.3.6.1.4.1.664.2.444.1.1.1.1.1")
    > > >
    > > > G. Torrielli
    > > >

    > >
    > >

    >
    >
    >




+ Reply to Thread