0

別々のネットワークで SnmpSharpNet を使用して複数の SNMP エージェント (タイムティック) を監視しようとしています。以下のコードは単一の IP アドレスで動作しますが、2 番目の IP アドレスに接続しようとするとコードが失敗します。これを非同期で実行しようとしていますが、SnmpSharpNet では複数からデータを受信できないようです。エージェント。

これは、この問題にアプローチする正しい方法ですか? SmnpSharpNet に代わるより良い方法はありますか?

community = new OctetString("public");
// Define agent parameters class
param = new AgentParameters(community);
// Set SNMP version to 1 (or 2)
param.Version = SnmpVersion.Ver1;

for (int i = 0; i < sendsqldatalist.Count(); i++)
{
    agent = new IpAddress(sendsqldatalist[i].ip);
    target = new UdpTarget((IPAddress)agent, 161, 2000, 1);

    // Make SNMP request        
    resultlist.Add(result = (SnmpV1Packet)target.Request(pdu, param));

    // If result is null then agent didn't reply or we couldn't parse the reply.r
    if (resultlist[i] != null)
    {
        // ErrorStatus other then 0 is an error returned by 
        // the Agent - see SnmpConstants for error definitions
        if (resultlist[i].Pdu.ErrorStatus != 0)
        {
            Console.WriteLine("error on - " + sendsqldatalist[i].oid + "    " + sendsqldatalist[i].ip);
            // agent reported an error with the request
            //- Error status found here http://www.docs.snmpsharpnet.com/docs-0-9-1/
            MessageBox.Show("Error in SNMP reply from " + target.Address.ToString() + Environment.NewLine + "Error status " + result.Pdu.ErrorStatus.GetType() + Environment.NewLine + "Error Index " + result.Pdu.ErrorIndex.ToString(), "WARNING!");
        }
        else
        {
            Console.WriteLine("ConnectSNMP() CONNECTED - " + sendsqldatalist[i].oid + "  -  " + sendsqldatalist[i].ip);                           
        }                    
    }
}

前もって感謝します!

4

0 に答える 0