Hi All I am using net-snmp to implement the alarm notifications using SNMPv2 traps. I intend to send the alarm generated in the system as SNMPv2 traps. In order to send SNMPv2 traps using net-snmp, I have followed the below mentioned steps.
Queries: ------------ 1. Please refer the steps mentioned below and let me know whether I am doing anything unnecessary/wrong here. 2. When I run this program for the first time, everything is going fine and the SNMPv2 trap is sent properly to the trap receiver. But it fails to send the trap afterward. That is, the trap can be sent only once After investigation, I found out that snmp_add (in step 9 below) is returning NULL in the failed cases. It throws an error "*No support for any checked transport domain*". Can anyone let me know why this error is being thrown? I am sure that netsnmp_transport_open_client() is failing, but not able to figure out why. Also please suggest any solution (may be any procedure call to initialize the transport domain? ) for this problem. Steps followed to send the SNMPv2 trap: ------------------------------------------------------------ Function: send_alarm_using_trap() 1. // Initialize session to default values netsnmp_session session; snmp_sess_init(&session); 2. // Set the directory from where additional mibs have to be read netsnmp_get_mib_directory(); /* prepare the default directories */ netsnmp_set_mib_directory("+/home/admin/mibs"); // Set the directory where mibs are stored 3. // Set the snmp version: session->version = SNMP_VERSION_2c; 4. // Disable all logginng: shutdown_snmp_logging(); netsnmp_log_handler *log_h; int priority = 7; // LOG_DEBUG int pri_max = 0; // LOG_EMERG log_h = netsnmp_register_loghandler(NETSNMP_LOGHANDLER_NONE, priority); if (log_h) { log_h->pri_max = pri_max; } 5. // read in MIB database and initialize the snmp library init_snmp("snmpapp"); 6. // Set the trap receiver IP address session->peername = trap_receiver; 7. // Set the community string session->community = some_community_string; session->community_len = strlen(some_community_string); 8. session.callback = NULL; session.callback_magic = NULL; 9. // Open a SNMP session ss = snmp_add(&session,netsnmp_transport_open_client("snmptrap", session.peername), NULL, NULL); 10. // Create the SNMPv2 trap PDU pdu = snmp_pdu_create(SNMP_MSG_TRAP2); 11. // Add sysUpTime.0 to the trap PDU snmp_add_var(pdu, objid_sysuptime, sizeof(objid_sysuptime) / sizeof(oid), 't', trap); 12. // Add alarm oid to the trap PDU and similarly add other VarBind pairs snmp_add_var(pdu, objid_snmptrap, sizeof(objid_snmptrap) / sizeof(oid),'o', argv[arg]) ... ... 13. // Send the trap snmp_send(ss, pdu); 9. // Close the session snmp_close(ss); 10. // Shutdown the SNMP application snmp_shutdown("snmpapp"); Note: send_alarm_using_trap() function is called from my application whenever an alarm is generated. System details: ---------------------- Intel core 2 Duo PC running Fedora core 10. Net-SNMP version: 5.4.2.1 Packages installed in the system: --------------------------------- net-snmp-libs-5.4.2.1-4.fc10.i386 perl-SNMP_Session-1.12-1.fc10.noarch net-snmp-utils-5.4.2.1-4.fc10.i386 net-snmp-5.4.2.1-4.fc10.i386 net-snmp-devel-5.4.2.1-4.fc10.i386 Thanks Goutham B G
------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev
_______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders