[EMAIL PROTECTED] have developed a small Trap-Agent (dynamic loadable)
with the net-snmp API V 5.1.2 under Linux Redhat 4.
The Agent sends each 2 seconds one Integer.

But if I use "./snmptrapd -f -Le" to catch the traps, the snmptrapd needs > 20 
seconds per trap to get it!!

example:

./snmptrapd -f -Le
2007-07-24 13:41:14 NET-SNMP version 5.1.2 Started.
2007-07-24 13:41:15 192.168.103.104(via 192.168.103.104) TRAP, SNMP v1, 
community public
        TRAPTEST-MIB::traptestTraps Enterprise Specific Trap (1) Uptime: 
0:00:24.34
        TRAPTEST-MIB::trapObject1.0 = INTEGER: 12
2007-07-24 13:41:59 192.168.103.104(via 192.168.103.104) TRAP, SNMP v1, 
community public
        TRAPTEST-MIB::traptestTraps Enterprise Specific Trap (1) Uptime: 
0:00:26.34
        TRAPTEST-MIB::trapObject1.0 = INTEGER: 13
2007-07-24 13:42:43 192.168.103.104(via 192.168.103.104) TRAP, SNMP v1, 
community public
        TRAPTEST-MIB::traptestTraps Enterprise Specific Trap (1) Uptime: 
0:00:28.35
        TRAPTEST-MIB::trapObject1.0 = INTEGER: 14
2007-07-24 13:43:27 192.168.103.104(via 192.168.103.104) TRAP, SNMP v1, 
community public
        TRAPTEST-MIB::traptestTraps Enterprise Specific Trap (1) Uptime: 
0:00:30.35
        TRAPTEST-MIB::trapObject1.0 = INTEGER: 15
2007-07-24 13:44:11 192.168.103.104(via 192.168.103.104) TRAP, SNMP v1, 
community public
        TRAPTEST-MIB::traptestTraps Enterprise Specific Trap (1) Uptime: 
0:00:32.35
        TRAPTEST-MIB::trapObject1.0 = INTEGER: 16
2007-07-24 13:44:55 192.168.103.104(via 192.168.103.104) TRAP, SNMP v1, 
community public
        TRAPTEST-MIB::traptestTraps Enterprise Specific Trap (1) Uptime: 
0:00:34.35


There u can see, that the uptime has got an intervall of 2 seconds,
BUT the realtime delay is much higher!

compare for example:
2007-07-24 13:43:27  AND 2007-07-24 13:44:11


What I have done wrong ? I want to have realtime Notification. If the Agent 
sends a
trap, it should directly printed out by snmptrapd.


..but I think the snmptrapd works correctly, because if I send a trap with
a command like 

"snmptrap -v 1 -c public localhost '' localhost 6 1 ''"


then the trap is directly printed by snmptrapd!!

Only the traps sended by my programmed agent have the heavy delay, if I want 
catch
them with snmptrapd!


Can someone plz look at my agent code, it is really small:


Here is it:

//------------------------------------------------------------
//                           traptest.c
//-----------------------------------------------------------

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "traptest.h"
#include <stdio.h>
#include <stdlib.h>

#define TRAP_SEND_INTERVALL 2

static int retVal=0;

void init_traptest(void)
{
                                  
    snmp_alarm_register(TRAP_SEND_INTERVALL, SA_REPEAT, traphandler, NULL);
}

void traphandler(unsigned int clientreg, void *clientarg)
{
    //iso(1).org(3).dod(6).internet(1).experimental(3).
    //traptest(7777).traptestObjects(1).trapObject1(1).0
    oid trapObject1_oid[]  = { 1, 3, 6, 1, 3, 7777, 1, 1, 0};
  
    //iso(1).org(3).dod(6).internet(1).experimental(3).
    //traptest(7777).agent4comTraps(2).numberOfActiveOutboundCalls(2)
    oid  trap1_oid[] = { 1, 3, 6, 1, 3, 7777, 2, 1};

    //iso(1).org(3).dod(6).internet(1).snmpV2(6).snmpModules(3).
    //snmpMIB(1).snmpMIBObjects(1).snmpTrap(4).snmpTrapOID(1).0
    oid  objid_snmptrap[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; 

    netsnmp_variable_list *trap_var_list1 = NULL;
                             
   
    snmp_varlist_add_variable(&trap_var_list1,
                              objid_snmptrap, OID_LENGTH(objid_snmptrap),
                              ASN_OBJECT_ID,
                              (u_char *) trap1_oid,
                              OID_LENGTH(trap1_oid) * sizeof(oid));
    retVal++;
        
    snmp_varlist_add_variable(&trap_var_list1,
                              trapObject1_oid, OID_LENGTH(trapObject1_oid),
                              ASN_INTEGER,
                              (u_char *) &retVal,
                              sizeof(retVal));
                              
    char deb[32];
    sprintf(deb, "sending vals:%i\n", retVal); 
    DEBUGMSGTL(("traptest", deb)); 
    
    send_v2trap(trap_var_list1); 
    snmp_free_varbind(trap_var_list1);                       
}


//------------------------------------------------------------
//                           traptest.h
//-----------------------------------------------------------
#ifndef TRAPTEST_H
#define TRAPTEST_H

SNMPAlarmCallback traphandler;
void init_traptest(void);

#endif 

//------------------------------------------------------------
//                           TRAPTEST-MIB.txt
//-----------------------------------------------------------
TRAPTEST-MIB DEFINITIONS ::= BEGIN

IMPORTS
    MODULE-IDENTITY, OBJECT-TYPE,
    Integer32, experimental FROM SNMPv2-SMI
    DisplayString FROM SNMPv2-TC;

traptest MODULE-IDENTITY
    LAST-UPDATED "200707180000Z"
    ORGANIZATION "4Com"
    CONTACT-INFO "NO CONTACT"
    DESCRIPTION  "4Com Security Agent V1.0"
    ::= { experimental 7777 }

traptestObjects     OBJECT IDENTIFIER  ::= { traptest 1 }
traptestTraps       OBJECT IDENTIFIER  ::= { traptest 2 }

trapObject1 OBJECT-TYPE
    SYNTAX      Integer32
    MAX-ACCESS  accessible-for-notify
    STATUS      current
    DESCRIPTION "Test Trap-Objekt 1"
::= { traptestObjects 1 }

trap1 NOTIFICATION-TYPE
    OBJECTS     { trapObject1 }
    STATUS      current
    DESCRIPTION "testtrap"
::= { traptestTraps 1 }
END



//------------------------------------------------------------
//                           Makefile
//-----------------------------------------------------------
CC=gcc

CFLAGS=-I. `net-snmp-config --cflags`
BUILDLIBS=`net-snmp-config --libs`
BUILDAGENTLIBS=`net-snmp-config --agent-libs`

# shared library flags (assumes gcc)
DLFLAGS=-fPIC -shared

traptest.so: traptest.c Makefile
    $(CC) $(CFLAGS) $(DLFLAGS) -c -o traptest.o traptest.c
    $(CC) $(CFLAGS) $(DLFLAGS) -o traptest.so traptest.o




//------------------------------------------------------------
//                           snmpd.conf
//-----------------------------------------------------------
com2sec notConfigUser  default       public

group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c          notConfigUser

view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
view    systemview    included   .1.3.6.1.3

access  notConfigGroup ""      any       noauth    exact  systemview systemview 
systemview 

trapcommunity public
trapsink 192.168.103.104 public 162

dlmod traptest /home/scsa/project1/traptest.so



//------------------------------------------------------------
//                           Starting
//-----------------------------------------------------------


#One Terminal:

MIBS=ALL; export MIBS
./snmpd -f -L -Dtraptest


#Other Terminal:

MIBS=ALL; export MIBS
./snmptrapd -f -Le




It would be great I someone could find the error. 


Greetz

fbrjogl



       
---------------------------------
Beginnen Sie den Tag mit den neuesten Nachrichten. Machen Sie Yahoo! zu Ihrer 
Startseite!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to