C#通过SnmpSharpNet怎么获得整个CPU的占有率
2个回答
2015-07-06 · 知道合伙人软件行家
关注
展开全部
protected void Button1_Click(object sender, EventArgs e)
{
SimpleSnmp snmp = new SimpleSnmp("127.0.0.1", "WWW");
if (!snmp.Valid)
{
this.TextBox1.Text = "SNMP agent host name/ip address is invalid.";
return;
}
Dictionary<Oid, AsnType> result = snmp.Walk(SnmpVersion.Ver2, "1.3.6.1.2.1.25.3.3.1.2");
//Dictionary<Oid, AsnType> result = snmp.Walk(SnmpVersion.Ver2, "1.3.6.1.4.1.25506.2.6.1.1.1.1.6");
if (result == null)
{
this.TextBox1.Text = "No results received.";
return;
}
foreach (KeyValuePair<Oid, AsnType> kvp in result)
{
this.TextBox1.Text += string.Format("CPU使用率为:{0} {1} {2}", kvp.Key.ToString(),
SnmpConstants.GetTypeName(kvp.Value.Type),
kvp.Value.ToString() + "%" + "\r\n");
}
}
KeyValuePair相加/个数即可
{
SimpleSnmp snmp = new SimpleSnmp("127.0.0.1", "WWW");
if (!snmp.Valid)
{
this.TextBox1.Text = "SNMP agent host name/ip address is invalid.";
return;
}
Dictionary<Oid, AsnType> result = snmp.Walk(SnmpVersion.Ver2, "1.3.6.1.2.1.25.3.3.1.2");
//Dictionary<Oid, AsnType> result = snmp.Walk(SnmpVersion.Ver2, "1.3.6.1.4.1.25506.2.6.1.1.1.1.6");
if (result == null)
{
this.TextBox1.Text = "No results received.";
return;
}
foreach (KeyValuePair<Oid, AsnType> kvp in result)
{
this.TextBox1.Text += string.Format("CPU使用率为:{0} {1} {2}", kvp.Key.ToString(),
SnmpConstants.GetTypeName(kvp.Value.Type),
kvp.Value.ToString() + "%" + "\r\n");
}
}
KeyValuePair相加/个数即可
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
找找对应的oid
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询