-merge
This commit is contained in:
@ -1,11 +1,15 @@
|
|||||||
<Properties StartupItem="Snmp2Mysql/Snmp2Mysql.csproj">
|
<Properties StartupItem="Snmp2Mysql/Snmp2Mysql.csproj">
|
||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release" />
|
||||||
|
<<<<<<< local
|
||||||
|
<MonoDevelop.Ide.Workbench />
|
||||||
|
=======
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="Snmp2Mysql/Program.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="Snmp2Mysql/Program.cs">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="Snmp2Mysql/DatabaseLink.cs" Line="1" Column="1" />
|
<File FileName="Snmp2Mysql/DatabaseLink.cs" Line="1" Column="1" />
|
||||||
<File FileName="Snmp2Mysql/Program.cs" Line="12" Column="6" />
|
<File FileName="Snmp2Mysql/Program.cs" Line="12" Column="6" />
|
||||||
</Files>
|
</Files>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
|
>>>>>>> other
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
<BreakpointStore />
|
<BreakpointStore />
|
||||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
@ -3,4 +3,7 @@
|
|||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
</startup>
|
</startup>
|
||||||
|
<appSettings>
|
||||||
|
<add key="DbConnStr" value="SERVER=localhost; DATABASE=statsdb; UID=statsuser; PASSWORD=test123;"/>
|
||||||
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
@ -3,26 +3,41 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
namespace Snmp2Mysql
|
namespace Snmp2Mysql
|
||||||
{
|
{
|
||||||
|
class Snmp2MysqlException : Exception
|
||||||
|
{
|
||||||
|
public Snmp2MysqlException(string msg) : base(msg) {}
|
||||||
|
public Snmp2MysqlException(string msg, Exception rootCause) : base(msg, rootCause) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
string dbConnStr = "SERVER=localhost;" +
|
//string loc = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
||||||
"DATABASE=statsdb;" +
|
//Console.WriteLine ("loc: {0}", loc);
|
||||||
"UID=statsuser;" +
|
|
||||||
"PASSWORD=test123;";
|
string dbConnStr = ConfigurationManager.AppSettings["DbConnStr"];
|
||||||
|
if (dbConnStr == null || "".Equals (dbConnStr)) {
|
||||||
|
throw new Snmp2MysqlException ("dbConnStr not found in configuration");
|
||||||
|
}
|
||||||
|
string verboseStr = ConfigurationManager.AppSettings ["Verbose"];
|
||||||
|
if (verboseStr == null || "".Equals (verboseStr)) {
|
||||||
|
throw new Snmp2MysqlException ("Verbose not found in configuration");
|
||||||
|
}
|
||||||
|
bool verbose = verboseStr.ToUpper().Equals ("TRUE");
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
foreach (DeviceTuple dt in dp)
|
foreach (DeviceTuple dt in dp)
|
||||||
{
|
{
|
||||||
// Console.WriteLine("dt: {0}, {1}", dt.DeviceAddress, dt.Community);
|
if (verbose) Console.WriteLine("dt: {0}, {1}", dt.DeviceAddress, dt.Community);
|
||||||
|
|
||||||
using (SnmpGetter snmpGetter = new SnmpGetter(dt.Community, dt.DeviceAddress))
|
using (SnmpGetter snmpGetter = new SnmpGetter(dt.Community, dt.DeviceAddress))
|
||||||
{
|
{
|
||||||
@ -30,7 +45,7 @@ namespace Snmp2Mysql
|
|||||||
{
|
{
|
||||||
foreach (DeviceDataItemTuple ddit in dt.DeviceDataItemProvider)
|
foreach (DeviceDataItemTuple ddit in dt.DeviceDataItemProvider)
|
||||||
{
|
{
|
||||||
// Console.WriteLine(" ddit: {0}, {1}", ddit.Id, ddit.Oid);
|
if (verbose) Console.WriteLine(" ddit: {0}, {1}", ddit.Id, ddit.Oid);
|
||||||
snmpGetter.AddOid(ddit.Id, ddit.Oid);
|
snmpGetter.AddOid(ddit.Id, ddit.Oid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,12 +55,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}: {4}", dt.Description, r.Index, r.Oid, r.Type, r.Value);
|
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) {
|
catch (SnmpGetterException e) {
|
||||||
// Console.WriteLine ("{0}, no result: {1}", dt.Description, e.Message);
|
Console.WriteLine ("no result: {0}", e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
<Reference Include="SnmpSharpNet">
|
<Reference Include="SnmpSharpNet">
|
||||||
<HintPath>dependencies\SnmpSharpNet.dll</HintPath>
|
<HintPath>dependencies\SnmpSharpNet.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DatabaseLink.cs" />
|
<Compile Include="DatabaseLink.cs" />
|
||||||
|
Reference in New Issue
Block a user