configuration file introduced

This commit is contained in:
Wolfgang Hottgenroth 2015-10-13 23:16:10 +02:00
parent 653291ea1a
commit f847f4abf6
2 changed files with 5 additions and 2 deletions

View File

@ -5,5 +5,6 @@
</startup>
<appSettings>
<add key="DbConnStr" value="SERVER=localhost; DATABASE=statsdb; UID=statsuser; PASSWORD=test123;"/>
<add key="Verbose" value="true"/>
</appSettings>
</configuration>

View File

@ -31,6 +31,8 @@ namespace Snmp2Mysql
}
bool verbose = verboseStr.ToUpper().Equals ("TRUE");
if (verbose)
Console.WriteLine ("Database connection to {0}", dbConnStr);
DatabaseLink dbLink = new DatabaseLink(dbConnStr);
using (DataCollector dc = dbLink.DataCollector)
using (DeviceProvider dp = dbLink.DeviceProvider)
@ -55,12 +57,12 @@ namespace Snmp2Mysql
SnmpGetterResultProvider res = snmpGetter.Exec();
foreach (SnmpGetterResult r in res)
{
Console.WriteLine("{0} {1} {2}: {3}", r.Index, r.Oid, r.Type, r.Value);
if (verbose) Console.WriteLine("{0} {1} {2}: {3}", r.Index, r.Oid, r.Type, r.Value);
dc.add((int)r.Index, r.Value);
}
}
catch (SnmpGetterException e) {
Console.WriteLine ("no result: {0}", e.Message);
if (verbose) Console.WriteLine ("no result: {0}", e.Message);
}
}
}