configuration file introduced
This commit is contained in:
@ -5,5 +5,6 @@
|
|||||||
</startup>
|
</startup>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="DbConnStr" value="SERVER=localhost; DATABASE=statsdb; UID=statsuser; PASSWORD=test123;"/>
|
<add key="DbConnStr" value="SERVER=localhost; DATABASE=statsdb; UID=statsuser; PASSWORD=test123;"/>
|
||||||
|
<add key="Verbose" value="true"/>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -31,6 +31,8 @@ namespace Snmp2Mysql
|
|||||||
}
|
}
|
||||||
bool verbose = verboseStr.ToUpper().Equals ("TRUE");
|
bool verbose = verboseStr.ToUpper().Equals ("TRUE");
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
Console.WriteLine ("Database connection to {0}", dbConnStr);
|
||||||
DatabaseLink dbLink = new DatabaseLink(dbConnStr);
|
DatabaseLink dbLink = new DatabaseLink(dbConnStr);
|
||||||
using (DataCollector dc = dbLink.DataCollector)
|
using (DataCollector dc = dbLink.DataCollector)
|
||||||
using (DeviceProvider dp = dbLink.DeviceProvider)
|
using (DeviceProvider dp = dbLink.DeviceProvider)
|
||||||
@ -55,12 +57,12 @@ namespace Snmp2Mysql
|
|||||||
SnmpGetterResultProvider res = snmpGetter.Exec();
|
SnmpGetterResultProvider res = snmpGetter.Exec();
|
||||||
foreach (SnmpGetterResult r in res)
|
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);
|
dc.add((int)r.Index, r.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SnmpGetterException e) {
|
catch (SnmpGetterException e) {
|
||||||
Console.WriteLine ("no result: {0}", e.Message);
|
if (verbose) Console.WriteLine ("no result: {0}", e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user