Networking

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • how can I send linkUp trap in my code

    6 answers - 1465 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi,
    How can I add auto linkUp trap in my code?
    What I did is as following:
    oid if_index_oid[] = {1,3,6,1,2,1,2,2,1,1,1};
    oid link_up_oid[] = { 1,3,6,1,6,3,1,1,5, 4 };
    oid snmptrap_oid[] = { 1,3,6,1,6,3,1,1,4, 1, 0 };
    int i;
    netsnmp_variable_list *linktrap_vars=NULL;
    snmptrap_oid_len = ID_LENGTH(snmptrap_oid);
    link_up_oid_len = ID_LENGTH(link_up_oid);
    if_index_oid_len = ID_LENGTH(if_index_oid);
    netsnmp_variable_list *linktrap_vars=NULL;
    for (i=0; i<MAX; i++) { // MAX is the total number of interface
    ret_linktrap_ifindex = i+1; // ret_linktrap_ifindex is
    a global int
    snmp_varlist_add_variable(&linktrap_vars,snmptrap_oid, snmptrap_oid_len,
    ASNBJECT_ID, (u_char *) link_up_oid, link_up_oid_len * sizeof(oid));
    snmp_varlist_add_variable(&linktrap_vars,if_index_oid, if_index_oid_len,
    ASN_INTEGER,(u_char *)&ret_linktrap_ifindex, sizeof(ret_linktrap_ifindex));
    send_v2trap(linktrap_vars);
    snmp_free_varbind(linktrap_vars);
    }
    Am I right? unfortunately, it doesn't work, please help me , thanks!
    Using Tomcat but need to do more? Need to support web services, security?
    Get stuff done quickly with pre-integrated technology to make your job easier
    Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
    Net-snmp-coders mailing list
    Net-snmp-coders (AT) lists (DOT) sourceforge.net
  • No.1 | | 1222 bytes | |

    22/08/06, Li Gan <li.gan (AT) mapleworks (DOT) comwrote:
    How can I add auto linkUp trap in my code?

    Which version of the agent are you using?
    For recent releases, please see the snmpd.conf(5) man page, and the
    description of the
    "linkUpDownNotifications" directive.

    What I did is as following:
    [snip]
    Am I right?

    I haven't looked closely, but that looks pretty much right for sending
    a linkUp trap.

    unfortunately, it doesn't work, please help me , thanks!

    The main thing that you haven't said is how you are triggering this code.
    What decides when to send this trap?
    What code have you written for monitoring the status of each interface?

    Please note the FAQ entry:
    How can I get the agent to generate a trap (or inform)?
    (and particularly the second half of this entry).

    Dave

    Using Tomcat but need to do more? Need to support web services, security?
    Get stuff done quickly with pre-integrated technology to make your job easier
    Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

    Net-snmp-coders mailing list
    Net-snmp-coders (AT) lists (DOT) sourceforge.net
  • No.2 | | 491 bytes | |

    "LG" == Li Gan <li.gan (AT) mapleworks (DOT) comwrites:

    LGAm I right? unfortunately, it doesn't work, please help me ,
    LGthanks!

    It's unclear where the code is being executed? It won't work during
    the init_XXX() phases of your code, but if you set an snmp_alarm and
    put it in a function for after the agent gets fully running you should
    be able to send notifications. However, make sure you configure the
    agent with a notification destination.
  • No.3 | | 1093 bytes | |

    22/08/06, Li Gan <li.gan (AT) mapleworks (DOT) comwrote:
    But when the program running into the second interface,
    by debugging, when arriving "snmp_varlist_add_variable", the program dumped.

    Ah. I see a problem.
    You're freeing the previous varbind list at the end of the loop, but
    the linktrap_vars
    variable is still pointing to this (now invalid) varbind structure.
    So following this chain may well trigger a crash.

    Try clearing the linktrap_vars variable immediately after freeing it.

    Another question: for the second interface, the if_index_oid is
    {1,3,6,1,2,1,2,2,1,1,1} or {1,3,6,1,2,1,2,2,1,1,2} ?
    ^^^ ^^^

    It'll be 1.3.6.1.2.1.2.2.1.1.2 (assuming that the index is 2)

    Dave

    Using Tomcat but need to do more? Need to support web services, security?
    Get stuff done quickly with pre-integrated technology to make your job easier
    Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

    Net-snmp-coders mailing list
    Net-snmp-coders (AT) lists (DOT) sourceforge.net
  • No.4 | | 1248 bytes | |

    22/08/06, Li Gan <li.gan (AT) mapleworks (DOT) comwrote:
    Another question about linkup trap, can I just use only 1 varbind list to
    send all the interfaces generated linkup trap? I mean by using
    "snmp_varlist_add_variable", bind all the interfaces into the same list one
    by one.

    Any trap *must* start with the varbinds listed in the MIB definition.
    For linkUp, this means { ifIndex, ifAdminStatus, Status }

    You can then append anything else you want to after this, but there's
    no guarantee that the trap receiver will necessarily do anything with
    them.

    So yes - you *could* report several linkUp events in the same trap,
    but you might find that the management system ignored everything bar
    the first. It's probably safer to report them individually.

    A lot depends on exactly what will be done with the traps when they arrive.

    Dave

    Using Tomcat but need to do more? Need to support web services, security?
    Get stuff done quickly with pre-integrated technology to make your job easier
    Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

    Net-snmp-coders mailing list
    Net-snmp-coders (AT) lists (DOT) sourceforge.net
  • No.5 | | 1066 bytes | |

    23/08/06, Li Gan <li.gan (AT) mapleworks (DOT) comwrote:
    I am in root, snmpwalk and snmptrap
    are all work fine, but if I type snmptrapd, the system told me "bash:
    snmptrapd: command not found", how to deal with that?

    What does
    echo $PATH
    display.

    Are there something missed in my system?

    The daemons (snmpd and snmptrapd) are often installed into 'sbin'
    rather than 'bin'.
    Now I'd expect this to be on a standard path for root (though not an
    ordinary user).
    How did you get to your root shell - logging in as root, or via 'su' ?

    What /S is this? If Linux, then try "locate snmptrapd" to find
    where the binary is.

    Dave

    Using Tomcat but need to do more? Need to support web services, security?
    Get stuff done quickly with pre-integrated technology to make your job easier
    Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

    Net-snmp-coders mailing list
    Net-snmp-coders (AT) lists (DOT) sourceforge.net
  • No.6 | | 739 bytes | |

    23/08/06, Li Gan <li.gan (AT) mapleworks (DOT) comwrote:
    For our embedded system, no .conf files are used, how can I set the ip
    address of the trap receiver in the code? Thanks.

    The easiest approach would probably be to hardcode a call to the
    relevant config directive handler - passing in the appropriate text
    string, as if it had been read from a config file.

    Dave

    Using Tomcat but need to do more? Need to support web services, security?
    Get stuff done quickly with pre-integrated technology to make your job easier
    Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

    Net-snmp-coders mailing list
    Net-snmp-coders (AT) lists (DOT) sourceforge.net

Re: how can I send linkUp trap in my code


max 4000 letters.
Your nickname that display:
In order to stop the spam: 8 + 7 =
QUESTION ON "Networking"

EMSDN.COM