Any help would be appreciated.
Thanks!
Brad.
I'm not sure you can recieve traps with the snmp component, but here's a
code example for sending a trap:
with SNMP.Tram do begin
Clear;
Host := m_szHost;
GenTrap := snmptrapEnterpriseSpecific;
Community := m_szCommunityName;
SpecTrap := cTrapTypeNumArray[AlarmType];
Enterprise := CTrapProcessControlOID; //for example :
'1.3.6.1.4.1.5271.2.1.1.2'
MIBAdd('ProcessId', '110', ASN1_INT);
MIBAdd('ProcessName', 'test');
MIBAdd('ProcessType', '');
MIBAdd('ApplicationName', 'AppName');
MIBAdd('ProcessDescription', 'AppName');
MIBAdd('StateID', IntToStr(cTrapTypeNumArray[AlarmType]));
Trap.MIBAdd('StateDescription', Alarm.AlarmText);
MIBAdd('StatePropableCause', cTrapStrStatePropableCause[AlarmType]);
MIBAdd('EventTime', DateTimeToStr(Now));
MIBAdd('PercievedSeverity', 'Cleared');
MIBAdd('CpuUsages', '', ASN1_INT);
MIBAdd('MemoryUsages', IntToStr(ProcessData.LastMemCount), ASN1_INT);
MIBAdd('AdditionalText', '');
end;
AgentOrange.SendTrap;
"Bradley Plett" <ple...@elegantlogic.com> wrote in message
news:eaevvukaqc9ca5sh9...@4ax.com...
>
> I'm not sure you can recieve traps with the snmp component, but
> here's a code example for sending a trap:
You can receive traps with the Indy SNMP component - but you probably
don't want to.
The problem is that you can only have one thing looking out for SNMP
traps - and by default that's the Microsoft SNMP Trap Service. there
are APIs that you can use to attach your application to this service so
that it sends you the traps. The advantage of doing it this way is
that other trap-detecting applications will still work!
If you really want to use Indy to do it, here's a very simple example.
first disable the Microsoft SNMP Trap service - then start a new app,
and drop a TidSNMP component and a Button and a Listbox on the main
form. Make the button's OnClick handler look like this...
procedure TForm1.Button1Click(Sender: TObject);
begin
IdSNMP1.ReceiveTimeout := -2;
IdSNMP1.Binding.Port := 162;
IdSNMP1.Binding.Bind;
if IdSNMP1.ReceiveTrap <> 0 then
ListBox1.Items.Add(IdSNMP1.Trap.ValueOID [0]);
end;
Run your app and press the button. The app will wait until a trap is
received - than it's details will be added to the listbox.
--
Colin
e-mail :co...@wilsonc.demon.co.uk
web: http://www.wilsonc.demon.co.uk/delphi.htm
Posted with XanaNews 1.12.5.2
Does the ms SNMP service actually perform trap detection? I thought that it
only sent traps and handled queries. Anyway, on my xp machine, with the
SNMP service running, your suggested code works. So, either ms doesn't have
an ear out for traps, or it doesn't do it by default.
<guit...@cox.net> wrote in message news:3E00EA...@cox.net...
> Colin was referring to the "SNMP Trap Service", not the "SNMP Service".
> When the "SNMP Trap Service" is running, it listens for traps, and you
> can use Windows API calls to be notified when traps are received. It
> listens on UDP port 162.
Brad.
On 18 Dec 2002 09:30:38 -0800, "Colin Wilson"
<co...@wilsonc.demon.co.uk> wrote:
>Eyal Matzlavi wrote:
>
>>
>> I'm not sure you can recieve traps with the snmp component, but
>> here's a code example for sending a trap:
>
>You can receive traps with the Indy SNMP component - but you probably
>don't want to.
>
>The problem is that you can only have one thing looking out for SNMP
>traps - and by default that's the Microsoft SNMP Trap Service. there
>are APIs that you can use to attach your application to this service so
>that it sends you the traps. The advantage of doing it this way is
>that other trap-detecting applications will still work!
>
>If you really want to use Indy to do it, here's a very simple example.
>first disable the Microsoft SNMP Trap services.yihen start a new app,