Hello,
within my threading application i send every second a trap message to a
traphandler,
but after 1024 mesages i have got the following error lines''.
net-snmp: 2 error(s) in config file(s)
/etc/snmp/snmp.conf: line 0: Error: maximum conf file count (4096) exceeded
/var/net-snmp/libpbmoninsp_trap.conf: line 0: Error: maximum conf file
count (4096) exceeded
I cant't find out the problem, all sessions and its connection closed after
trap message was send.
Please check my code lines from the function.
int send_enterprise_trap(int trap_index, const char* peername,
int modentryid, int channel, int device) {
struct snmp_session session, *ss;
struct snmp_pdu *pdu;
in_addr_t *pdu_in_addr_t;
static long trapcount = 1;
int status = 0;
u_char *buff_sys_location = "My Location";
/* build the specific trap oid */
oid enterprise_trap[] = { 1, 3, 6, 1, 4, 1, 12345, trap_index, 0};
/* -------------- initialize session parameter ---------------------*/
/* Initialize the SNMP library */
init_snmp("libpbmoninsp_trap");
/* Initialize a "session" that defines who we're going to talk to */
snmp_sess_init(&session); /* set up defaults */
session.peername = (char*) peername;
/* set the SNMP version number */
session.version = SNMP_VERSION_1;
/* set the SNMPv1 community name used for authentication */
session.community = (u_char*) "public";
session.community_len = strlen(session.community);
/* windows32 specific initialization (is a noop on unix) */
SOCK_STARTUP;
/* -------------- add session ---------------------*/
ss = snmp_add(&session, netsnmp_transport_open_client("libpbmon_trap",
session.peername), NULL, NULL);
if (ss == NULL) {
/*
* diagnose netsnmp_transport_open_client and snmp_add errors with
* the input netsnmp_session pointer
*/
snmp_sess_perror("libpbmoninsp_trap", &session);
close_session(ss);
return -1;
}
/* Create the PDU for the data for our request. */
pdu = snmp_pdu_create(SNMP_MSG_TRAP);
/* agent self */
pdu_in_addr_t = (in_addr_t *) pdu->agent_addr;
*pdu_in_addr_t = get_myaddr();
/* set the enterprise specific trap oid */
pdu->enterprise = (oid *) malloc(sizeof(enterprise_trap));
memcpy(pdu->enterprise, enterprise_trap, sizeof(enterprise_trap));
pdu->enterprise_length = sizeof(enterprise_trap) / sizeof(oid);
pdu->trap_type = SNMP_TRAP_ENTERPRISESPECIFIC; // Enterprise specific
pdu->specific_type = 0; /* none specific type */
pdu->time = get_uptime();
/* add syslocation */
snmp_pdu_add_variable(pdu, objid_syslocation, sizeof(objid_syslocation)
/ sizeof(oid), ASN_OCTET_STR, (u_char*) buff_sys_location, strlen(
buff_sys_location));
/* add moduleEntryID */
snmp_pdu_add_variable(pdu, objid_modulentryid,
sizeof(objid_modulentryid) / sizeof(oid),
ASN_INTEGER,
(u_char*)&modentryid, sizeof(modentryid));
/* add channelIndex */
snmp_pdu_add_variable(pdu, objid_channelindex,
sizeof(objid_channelindex) / sizeof(oid),
ASN_INTEGER,
(u_char*)&channel, sizeof(channel));
/* add device */
snmp_pdu_add_variable(pdu, objid_stationaddr,
sizeof(objid_stationaddr) / sizeof(oid),
ASN_INTEGER,
(u_char*)&device, sizeof(device));
/* Send the Request out. */
status = snmp_send(ss, pdu) == 0;
if (status) {
snmp_sess_perror("libpbmoninsp_trap", ss);
snmp_free_pdu(pdu);
}
snmp_close(ss);
snmp_shutdown("libpbmoninsp_trap");
SOCK_CLEANUP;
printf("Trap %lu\n", trapcount++);
return status;
}
Norman
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users