Esempio n. 1
0
 public static void SNMPChecks()
 {
     foreach (SNMPDevice device in Config.LocalConfig.LocalPowerDevices.Select(x => x.SNMPDevice))
     {
         Console.WriteLine($"Connecting to SNMP device: {device.SNMPIdentifier} - {device.SNMPUsername}@{device.SNMPHost}");
         Net.SNMPConnectionOptions sNMPConnectionOptions = new Net.SNMPConnectionOptions
         {
             Authentication    = device.SNMPAuthType,
             Encryption        = device.SNMPEncType,
             SNMPEncryptionKey = device.SNMPEncryptionKey,
             SNMPHost          = device.SNMPHost,
             SNMPPass          = device.SNMPPassword,
             SNMPPort          = device.SNMPPort.ToString(),
             SNMPUser          = device.SNMPUsername
         };
         Console.WriteLine($"Auth Type is {device.SNMPAuthType.ToString()}, Encryption Type is {device.SNMPEncType.ToString()}");
         Net.SNMP snmp = new Net.SNMP(sNMPConnectionOptions);
         Console.WriteLine("Connection keys generated");
         List <Net.SNMPResult> results;
         Console.WriteLine("Checking OID Data...");
         foreach (SNMPOID oid in device.SNMPOIDs)
         {
             results = snmp.QuerySNMP(oid.OID);
             foreach (Net.SNMPResult result in results)
             {
                 Console.WriteLine($"{oid.Description}: {result.Data}");
             }
         }
         Console.WriteLine($"Done processing SNMP Device: {device.SNMPIdentifier}");
     }
 }
Esempio n. 2
0
 public SNMP(SNMPConnectionOptions Options)
 {
     //Store the options locally
     ConnectionOptions = Options;
     ConnectionOptions.PrivacyProvider = CreateKeys();
 }