这是用C#语言实现的简单网络管理协议SNMP库,支持的版本包括1/2/3
示例代码
stringhost="localhost";stringcommunity="public";SimpleSnmpsnmp=newSimpleSnmp(host,community);if(!snmp.Valid){Console.WriteLine("SNMPagenthostname/ipaddressisinvalid.");return;}Dictionaryresult=snmp.Get(SnmpVersion.Ver1,newstring[]{".1.3.6.1.2.1.1.1.0"});if(result==null){Console.WriteLine("Noresultsreceived.");return;}foreach(KeyValuePairkvpinresult){Console.WriteLine("{0}:{1}{2}",kvp.Key.ToString(),SnmpConstants.GetTypeName(kvp.Value.Type),kvp.Value.ToString());}
评论