using System;
using System.Collections.Generic;
using System.Text;
using OLEPRNLib;
namespace MrFu
{
public class SimpleSnmp
{
private String hostIp;
private String oid;
private String communityString;
int retries = 1;
int timeout = 3000;
SNMP snmp = new SNMP();
public SimpleSnmp(String hostIp, String communityString, String oid)
{
this.hostIp = hostIp;
this.communityString = communityString;
this.oid = oid;
try
{
snmp.Open(this.hostIp, this.communityString, this.retries, this.timeout);
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}
public String getValue() {
try
{
uint result = snmp.GetAsByte(this.oid);
return result.ToString();
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
return null;
}
}
}
}
參考於: http://www.mr-fu.net/2008/10/communicatng-with-snmp-using-c-very.html
沒有留言:
張貼留言