DX NetOps

 View Only
  • 1.  Query an OID before generating an Event

    Posted Jun 16, 2014 10:17 AM

    Hello,

     

    I am currently receiving 'entPhysicalIndex (1.3.6.1.2.1.47.1.1.1.1.1)'  as part of the SNMP trap.

    Step 1) I would want to read the 'entPhysicalClass (1.3.6.1.2.1.47.1.1.1.1.5)' OID with the instance of entPhysicalIndex received.

    Step 2) Compare if it not equal to 2 (i.e. not a port)

    Step 3) Generate another event for further processing.

     

    i.e. I receive    1.3.6.1.2.1.47.1.1.1.1.1.7777    as part of the trap. Where 7777 is the index.

    I would want to query   1.3.6.1.2.1.47.1.1.1.1.5.7777 OID and check if the return value is not equal to 2 and then raise an alarm accordingly.

     

    Please note that, I would want to do this without a Catalog Update (i.e. without using Model Type Editor).

    Would like to keep it to EventDisp changes.

     

    Any pointers please.

    Thanks for your time.

     

    Regards

    Ramanan



  • 2.  Re: Query an OID before generating an Event

    Posted Jun 16, 2014 01:50 PM

    You'll need to find the Spectrum Attribute this is stored it, and read from it using an event procedure. In the following code an interface index sent in a trap (U 1) is used to read from the ifAlias (0x11f84) attribute list.

     

    I'm not sure if the one you're looking for is in a spectrum attribute by default.

     

      CreateEventWithVariables(                        \  
        {C CURRENT_MODEL},                             \  
        {H 0xfff00adf},                                \  
        SetEventVariable(                              \  
          GetEventVariableList(),                      \  
          {H 0x00012b4c},                              \  
          Append(                                      \  
            {S \"Secure MAC Violation on port: \"},    \  
            ToString(ReadAttributeInstance(            \  
              {C CURRENT_MODEL},                       \  
              {H 0x11f84},                             \  
              ToObjectId(GetEventVariable({U 1}))      \  
            ))                                         \  
          )                                            \  
        )                                              \  
      )
    


  • 3.  Re: Query an OID before generating an Event

    Posted Jun 17, 2014 03:10 PM

    Many thanks lutelewis, for the reply.

     

    Unfortunately, the Spectrum attribute was on a child model. I had to use 'GetModelsByRelationName' to get it done.

    I have explained it below (just for reference / information).

     

    • The trap comes into say....    'myDevice'.
    • It has 'entPhysicalIndex' on {U 2}.   (example Index = 7777)
    • I need to get the 'myDevice_EntityMIBApp' and then get to  entPhysicalClass's AttrID   under it.
    • I am storing the value of entPhysicalClass.7777  in a new event variable {U 7}

     

    $ ./show devices | grep myDevice

    0x1f2cc40   myDevice       0x3d0002    GnSNMPDev

    $

    $ ./show children rel=Manages mh=0x1f2cc40

    MHandle     MName                      MTypeHnd    MTypeName      Relation

    ...

    0x1f2cc4e   myDevice_Standard RMON     0x590006    RMONApp        Manages

    0x1f2cc47   myDevice_EntityMIBApp      0xc40055    RFC2737App     Manages

    $

    $ ./show attributes attr=0xc40aaf,iid=7777 mh=0x1f2cc47

    Id          Name                    Iid          Value

    0xc40aaf    entPhysicalClass        7777         8

     

    Where:

    0x10001  :   Modeltype_Handle's AttrID

    0xc40055 :   RFC2737App's MTypeHnd (myDevice_EntityMIBApp)

    0xc40aaf :   entPhysicalClass's AttrID   under RFC2737App

     

     

     

     

    My EventDisp looks as follows and is working fine.

    0xfff00046 E 20 P "ForEach( \

       GetModelsByRelationName({C CURRENT_MODEL}, {S \"Manages\"}, {C RELATION_SIDE_RIGHT}), \

       {Variable childMh}, {Variable notUsed}, {H 0}, \

          If ( Equals( {H 0xc40055} , ReadAttribute( {Variable childMh}, {H 0x10001}) ), \

             CreateEventWithVariables( {C CURRENT_MODEL}, {H 0xfff00040}, \

                SetEventVariable ( GetEventVariableList(), \

                  {U 7}, ReadAttributeInstance(  {Variable childMh}, {H 0xc40aaf}, ToObjectId( GetEventVariable({U 2}) ) ) \

                ) \

             ) \

          , Nil() ) \

       )"

     

     

    Explanation:

    "GetModelsByRelationName({C CURRENT_MODEL}, {S \"Manages\"}, {C RELATION_SIDE_RIGHT})"   is equal to "./show children rel=Manages mh=0x1f2cc40"

     

    "If ( Equals( {H 0xc40055} , ReadAttribute( {Variable childMh}, {H 0x10001}) )"  is to get the model id of 'myDevice_EntityMIBApp'.  Model Handle of  'myDevice_EntityMIBApp' will be stored in 'childMh'.

     

    I am then creating a new Event '0xfff00040' with all the existing variables (GetEventVariableList()), along with the new variable {U 7} which reads '0xc40aaf :   entPhysicalClass's AttrID' with instance '7777' ({U 2} of original event)    from  'childMh'   (which is 'myDevice_EntityMIBApp' )