Hello.
I have a gasoline generator that has the ability to report its status via the SNMP protocol. If I use a third-party app, I can get a response from querying "1.3.6.1.2.1.1.1.0" and "1.3.6.1.4.1.28634.6.2551906584.2.8206" and it works well. When I tried to write it myself, I notice that the first request is successful but on the second one I get a "NoSuchName" error.
ps.
Windows 10 x64
RAD Studio XE6
Indy 10.6.0
Here is my simple code:
This also doesn't work:
In the first case, I have a positive result: (oid=1.3.6.1.2.1.1.1.0)
In the second case I have an error:
If I use a third-party program (MIBViewer), everything works fine:
Can anyone tell me what the problem is? I will be very grateful for the information
I have a gasoline generator that has the ability to report its status via the SNMP protocol. If I use a third-party app, I can get a response from querying "1.3.6.1.2.1.1.1.0" and "1.3.6.1.4.1.28634.6.2551906584.2.8206" and it works well. When I tried to write it myself, I notice that the first request is successful but on the second one I get a "NoSuchName" error.
ps.
Windows 10 x64
RAD Studio XE6
Indy 10.6.0
Here is my simple code:
Code:
procedure TForm2.Button2Click(Sender: TObject);
var
i: Integer;
begin
SNMP.Host := '172.17.40.243';
SNMP.Port := 161;
SNMP.Community := 'public';
SNMP.Query.Clear;
SNMP.Query.Version := 0;
try
if not SNMP.Connected then
begin
SNMP.Connect;
Memo1.Lines.Add('Connected');
end
else
Memo1.Lines.Add('Already connected');
except
on E: Exception do
begin
Memo1.Lines.Add('Error on connect: ' + E.Message);
Exit;
end;
end;
try
SNMP.Query.PDUType := PDUGetRequest;
SNMP.Query.MIBAdd(Edit1.Text, '');
if SNMP.SendQuery then
begin
Memo1.Lines.Add('Value received: ' + SNMP.Reply.Value[0]);
end
else
begin
Memo1.Lines.Add('Error: ' + IntToStr(SNMP.Reply.ErrorStatus));
end;
SNMP.Disconnect;
except
on E: Exception do
begin
Memo1.Lines.Add('Error: ' + E.Message);
end;
end;
end;
This also doesn't work:
Code:
procedure TForm2.Button5Click(Sender: TObject);
var
SNMP: TIdSNMP;
dn, PLevel, SRate: string;
p: Extended;
begin
SNMP := TIdSNMP.Create(nil);
try
SNMP.Host := '172.17.40.243';
SNMP.Community := 'public';
SNMP.Query.Version := 6;
SNMP.ReceiveTimeout := 3000;
if SNMP.QuickSend('1.3.6.1.2.1.1.1.0', SNMP.Community, SNMP.Host, dn) then
Memo1.Lines.Add(dn);
if SNMP.QuickSend('1.3.6.1.4.1.28634.6.2551906584.2.8206',
SNMP.Community, SNMP.Host, SRate) then
Memo1.Lines.Add(SRate);
Memo1.Lines.Add('');
finally
SNMP.Free;
end;
end;
In the first case, I have a positive result: (oid=1.3.6.1.2.1.1.1.0)
Code:
Connected
Value received: IB-Lite
In the second case I have an error:
Code:
Connected
Error: 2 (NoSuchName)
If I use a third-party program (MIBViewer), everything works fine:
Code:
Send snmp get request to 172.17.40.243:161
.1.3.6.1.2.1.1.1.0 (not in loaded mib files) --> IB-Lite
Send snmp get request to 172.17.40.243:161
.1.3.6.1.4.1.28634.6.2551906584.2.8213.0 (not in loaded mib files) --> 261
Can anyone tell me what the problem is? I will be very grateful for the information