Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working with SNMP in Delphi

Tags:

delphi

snmp

What is the best way to integrate SNMP V2 alerts functionality into an existing Delphi software?

Are there any well known Delphi libraries? Is it easier to integrate SNMP libraries built in some other language?

Thanks!

like image 781
Yoav Weiss Avatar asked Dec 22 '22 13:12

Yoav Weiss


2 Answers

Well, you can use the Indy-SNMP (delivered with Delphi) coponents. Here is a small example (console), this returns the sysDescr of the host:

    program snmptest;

    {$APPTYPE Console}

    uses
      SysUtils, IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient, IdSNMP;

    var
      Snmp: TIdSNMP;
      Idx: Integer;

    begin
      Snmp := TIdSNMP.Create(nil);
      try
        Snmp.Query.Host := 'Hostname or IP'; //insert your host here...
        Snmp.Query.Community := 'public';
        Snmp.Query.PDUType := PDUGetRequest;
        Snmp.Query.MIBAdd('1.3.6.1.2.1.1.1.0','');

        if Snmp.SendQuery then
        begin
          WriteLn('Replies: ' + IntToStr(Snmp.Reply.ValueCount));
          for Idx := 0 to Snmp.Reply.ValueCount - 1 do
            WriteLn(Snmp.Reply.Value[0]);
        end;
      finally
        Snmp.Free;
      end;
    end. 

There are more examples, if you google "Delphi SNMP"..

like image 61
Andreas Avatar answered Dec 29 '22 22:12

Andreas


Have a look at Synapse TCP/IP and serial library

http://synapse.ararat.cz/doku.php/download

This project is freeware and open source under modified BSD style license!

Description

SNMP client

Supports SNMPv1 include traps, SNMPv2c and SNMPv3 include authorization and privacy encryption.

Used RFC: RFC-1157, RFC-1901, RFC-3412, RFC-3414, RFC-3416, RFC-3826

Supported Authorization hashes: MD5, SHA1 Supported Privacy encryptions: DES, 3DES, AES

The library also supports many other protocols

like image 41
Charles Faiga Avatar answered Dec 30 '22 00:12

Charles Faiga