public void SNMPupTime(string ip)
{
try
{
arrSNMP[3] = string.Empty;
OctetString community = new OctetString("public");
AgentParameters param = new AgentParameters(community);
param.Version = SnmpVersion.Ver1;
IpAddress agent = new IpAddress(ip);//IP address
UdpTarget target = new UdpTarget((System.Net.IPAddress)agent, 161, 2000, 1);
Pdu pdu = new Pdu(PduType.Get);
pdu.VbList.Add("1.3.6.1.2.1.1.3.0"); //Время работы принтера
SnmpV1Packet result = (SnmpV1Packet)target.Request(pdu, param);
if (result != null)
{
if (result.Pdu.ErrorStatus != 0)
{
}
else
{
arrSNMP[3] = (result.Pdu.VbList[0].Value.ToString());//Время работы принтера
}
}
target.Close();
}
catch (Exception)
{ }
}
Для работы вам понадобится библиотека:SnmpSharpNet.dll
0.00 (0%) 0 votes










