[英]C# SNMP programming
我嘗試編寫一些代碼來檢索objectID,結果為2B-06-01-04-01-82-31-01-03-01-01
。 這個值不正確嗎?
// Send a SysObjectId SNMP request
response = conn.get("get", argv[0], argv[1], "1.3.6.1.2.1.1.2.0");
if (response[0] == 0xff)
{
Console.WriteLine("No response from {0}", argv[0]);
return;
}
// Get the community and MIB lengths of the response
commlength = Convert.ToInt16(response[6]);
miblength = Convert.ToInt16(response[23 + commlength]);
// Extract the MIB data from the SNMp response
datatype = Convert.ToInt16(response[24 + commlength + miblength]);
datalength = Convert.ToInt16(response[25 + commlength + miblength]);
datastart = 26 + commlength + miblength;
output= BitConverter.ToString(response, datastart, datalength);
Console.WriteLine(" sysObjectId - Datatype: {0}, Value: {1}",
datatype, output);
conn.get("get", argv[0], argv[1], "1.3.6.1.2.1.1.2.0")
意味着僅執行get協議嗎? 怎么樣?
真的,如果您想在C#中使用SNMP,請嘗試使用此程序集SNMPSharpNet 。 非常有用
您將在此StackOverflow答案中找到一個使用它的一種方式(高級)的示例。
但是請看文檔。 您可以通過兩種方式使用此程序集:
去嘗試一下。
J.P
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.