Article

From:
To:
Nguyen Diep
Subject:
Re: Problem with IdSNMP Trap [Edit]
Newsgroup:
embarcadero.public.delphi.internet.winsock

Re: Problem with IdSNMP Trap [Edit]

> {quote:title=Nguyen Diep wrote:}{quote}
> I write a idsnmp trap receiver, it can receive trap v1 ok. It can receive v2c trap but the result is below
> My code is
> {code}
> var snmp: TIdSNMP;
>   if snmp.ReceiveTrap = 1 then
>   begin
>     Memo1.Lines.Add('Version: ' + InttoStr(snmp.Trap.Version) + 
>                 'RequestId: ' + InttoStr(snmp.Trap.ID) + 
>                 'ErrorStatus: ' + InttoStr(snmp.Trap.ErrorStatus) +
>                 'ErrorIndex: ' + InttoStr(snmp.Trap.ErrorIndex));
>     for i := 0 to snmp.Trap.ValueCount - 1 do
>     Memo1.Lines.Add('  ' + snmp.Trap.ValueOID[i] + '=' + snmp.Trap.Value[i]);
>   end;
> {code}

Well, I would really be very interested in knowing how you have managed to succefully receive traps with the idsnmp.receivetrap function !
Impossible for my part, with delphi7, windows XP and TIdSNMP component !

Note that the short code you've wrotten can't work as you don't use the idsnmp.create constructor...

By the way, does anyone can tell me he has been able to receive snmp traps with delphi and idsnmp ?

Because I've been searching all day long on the web, and expect lots of posts of unscuccessfully operation to do it, I've never seen yet someone telling (except here !) he had done it successfully !

Thanks.
.
.
.
NB : idsnmp works for getting snmp informations, I do it well, it's only receiving traps that really doesn't seem to work...
.
.
.
.
NB2 : I show you the way I'm trying to do it (I've used a timer and udp port is 162, and wireshark shows traps are well arriving on the port...) but receivetrap always returns 0...:
.
.
procedure TForm1.Timer1Timer(Sender: TObject);
var
  i : integer;
begin
  timer1.Enabled := false;
  label1.Caption := 'V__rification TRAP en cours...';

  StringGrid1.RowCount := StringGrid1.RowCount + 1;   i := StringGrid1.RowCount - 1;   StringGrid1.Cells[0,i] := 'Trap : ';   StringGrid1.Row := i;
  refresh;
  if IdSNMP1.ReceiveTrap = 1 then   begin     StringGrid1.Cells[1,i] := 'host = ' + IdSNMP1.Trap.Host;   end   else     StringGrid1.Cells[1,i] := '... rien ...';
  label1.Caption := '';   refresh;   timer1.Enabled := true; end;

("rien" means "nothing" in french...)
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Fri, 01 Nov 2024 04:28:01 UTC
Copyright © 2009-2024
HREF Tools Corp.