Hi,
I have been able to send traps from within the agent module but I =
am receiving the same trap twice at the trap daemon.....Cant figure out =
whats wrong......
This is the section of the MIB tree where I have defined the =
traps.......
mytrialSSSimpleString OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-write
STATUS current
DESCRIPTION
::=3D { mytrialScalarSet 1 }
mytrialSSSimpleData OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
. ::=3D { mytrialScalarSet 2 }
mytrialtrapString NOTIFICATION-TYPE
OBJECTS { mytrialSSSimpleString,mytrialSSSimpleData }
STATUS current
::=3D { mytrialMIBObjects 2 }
This is the code that I have added in the implementation.......
static oid enterprise[] =3D {1,3,6,1,4,1,18,1,2};
static oid oid1[] =3D {1,3,6,1,4,1,18,1,1,1};
static oid oid2[] =3D {1,3,6,1,4,1,18,1,1,2};
=20
strnlngth =3D sprintf(defstring, "Outgoing Data1");
oid_length1=3Dsizeof(oid1)/sizeof(oid);
if (snmp_varlist_add_variable(&var_trap, oid1,oid_length1,
ASN_OCTET_STR, (u_char *) defstring, (strnlngth =
+ 1))=3D=3DNULL)
{ =20
flag=3D1;
}
=20
oid_length2=3Dsizeof(oid2)/sizeof(oid);
int_ret=3D50;
if (snmp_varlist_add_variable(&var_trap, oid2, oid_length2,
ASN_INTEGER, (u_char *) =
&int_ret,sizeof(int_ret))=3D=3DNULL)
{
flag=3D1;
}
if(flag=3D=3D0)
{
enterprise_length=3Dsizeof(enterprise)/sizeof(oid);
printf("trying to send a trap\n");
send_enterprise_trap_vars (SNMP_TRAP_ENTERPRISESPECIFIC, =
2,
enterprise, enterprise_length, var_trap);
}
snmp_free_varbind(var_trap);
=20
I have added this code under the case of =
MYTRIALSSSIMPLESTRING so that when I issue a snmpget for it,I should =
receive the traps......I am receiving the traps correctly as can be seen =
below ........only problem is I am receiving them twice ......
Received 124 bytes from 127.0.0.1:1034
0000: 30 7A 02 01 01 04 0D 64 65 6D 6F 63 6F 6D 6D 75 =
0z.....democommu
0016: 6E 69 74 79 A7 66 02 04 21 1C 1D 3F 02 01 00 02 =
nity.f..!..?....
0032: 01 00 30 58 30 0E 06 08 2B 06 01 02 01 01 03 00 =
..0X0...+.......
0048: 43 02 13 D3 30 18 06 0A 2B 06 01 06 03 01 01 04 =
C...0...+.......
0064: 01 00 06 0A 2B 06 01 04 01 12 01 02 00 02 30 1C =
....+.........0.
0080: 06 09 2B 06 01 04 01 12 01 01 01 04 0F 4F 75 74 =
..+..........Out
0096: 67 6F 69 6E 67 20 44 61 74 61 31 00 30 0E 06 09 going =
Data1.0...
0112: 2B 06 01 04 01 12 01 01 02 02 01 32 +..........2
2002-04-30 15:21:18 localhost.localdomain [127.0.0.1]:
system.sysUpTime.0 =3D Timeticks: (5075) 0:00:50.75 =
.iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.=
snmpTrapOID.0 =3D OID: enterprises.18.1.2.0.2 enterprises.18.1.1.1 =
=3D Hex: 4F 75 74 67 6F 69 6E 67 20 44 61 74 61 31 00 =
enterprises.18.1.1.2 =3D 50
Received 96 bytes from 127.0.0.1:1033
0000: 30 5E 02 01 00 04 0D 64 65 6D 6F 63 6F 6D 6D 75 =
0^.....democommu
0016: 6E 69 74 79 A4 4A 06 08 2B 06 01 04 01 12 01 02 =
nity.J..+.......
0032: 40 04 C0 A8 01 03 02 01 06 02 01 02 43 02 13 D3 =
@...........C...
0048: 30 2E 30 1C 06 09 2B 06 01 04 01 12 01 01 01 04 =
0.0...+.........
0064: 0F 4F 75 74 67 6F 69 6E 67 20 44 61 74 61 31 00 .Outgoing =
Data1.
0080: 30 0E 06 09 2B 06 01 04 01 12 01 01 02 02 01 32 =
0...+..........2
2002-04-30 15:21:18 nexia.cellcloud.com [192.168.1.3] (via =
localhost.localdomain [127.0.0.1]) TRAP, SNMP v1, community =
democommunity
enterprises.18.1.2 Enterprise Specific Trap (2) Uptime: =
0:00:50.75
enterprises.18.1.1.1 =3D Hex: 4F 75 74 67 6F 69 6E 67 20 44 61 =
74 61 31 00 enterprises.18.1.1.2 =3D 50
=20
=20
Why does this happen?=20
=20
Thanks in advance,
Yamini
=20
=20
=20
|