Hi all,
I am a new SNMP developer.
I have a "little" problem related to e-mail subject.
I know that other developers done the same question but until now, in the e-mails of the mailing list, I haven't found the answer.
So, I will try to explain my problem.
I'm writing a sub-agent for a proprietary system. I am using the snmpd demon as master agent. The snmp library release used is net-snmp-5.1 with OS Linux RedHat 7.2.
Supposing that it's possible to send trap from a sub-agent, when I send a trap (like Cold Start), using send_easy_trap I receive, on stderr, the following error message:
snmpd: send_trap: Unknown PDU type
So, I tried using send_v2trap, defining a TRAP on my MIB as following shown:
nextGeneral OBJECT IDENTIFIER ::= { next 1 }
...
nextTraps OBJECT IDENTIFIER ::= { next 3 }
...
...
idMessage OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION ""
DEFVAL { -1 }
::= { nextGeneral 11 }
...
...
systemTrap TRAP-TYPE
STATUS current
ENTERPRISE nextTraps
VARIABLES { idMessage }
DESCRIPTION ""
::= 1
and, using the utility mib2c as following: mib2c -c mib2c.notify.conf systemTrap
the following code has been created :
...
static oid snmptrap_oid[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
int send_systemTrap_trap(int idMsg)
{
netsnmp_variable_list *var_list = NULL;
oid systemTrap_oid[] = { 1, 3, 6, 1, 4, 1, 9999, 1, 3, 0, 1 };
oid idMessage_oid[] = { 1, 3, 6, 1, 4, 1, 9999, 1, 1, 11, 0 };
/* Set the snmpTrapOid.0 value */
snmp_varlist_add_variable(&var_list,
snmptrap_oid,
OID_LENGTH(snmptrap_oid),
ASN_OBJECT_ID,
systemTrap_oid,
sizeof(systemTrap_oid));
/* Add any objects from the trap definition */
snmp_varlist_add_variable(&var_list,
idMessage_oid,
OID_LENGTH(idMessage_oid),
ASN_INTEGER,
(u_char *)&idMsg,
sizeof(idMsg));
/* Send the trap to the list of configured destinations and clean up */
send_v2trap(var_list);
snmp_free_varbind(var_list);
return SNMP_ERR_NOERROR;
}
but the problem still remains (on stderr, I have: snmpd: send_trap: Unknown PDU type)
A last information:
Using the following command: snmptrap -c public -v 2c <host_name> '' NEXT-MIB::nextTraps NEXT-MIB::startSystem i 1
the snmptrapd process receives correctly:
2004-09-23 16:17:57 <host_name> [host_ip_address]:
SNMPv2-MIB::sysUpTime.0 = Timeticks: (562751281) 65 days, 3:11:52.81 SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.9999.1.3 SNMPv2-SMI::enterprises.9999.1.1.1 = INTEGER: 1
There is someone could help me?
Thanks a lot,
Vincenzo Ponticiello
Atos Origin
Technical Architect
System Integration
Via Antiniana, 2/A - 80078 Pozzuoli (Na) - Italy
