Removed dependency to org id

This commit is contained in:
2016-03-22 20:56:21 +01:00
parent 9fdaabbc29
commit 1438a6553b
4 changed files with 30 additions and 19 deletions
+1 -1
View File
@@ -25,7 +25,7 @@
<LangVersion>4</LangVersion> <LangVersion>4</LangVersion>
<Externalconsole>true</Externalconsole> <Externalconsole>true</Externalconsole>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Commandlineparameters>~/code/ntpa/example/ntpa.stat.conf</Commandlineparameters> <Commandlineparameters>--config ~/code/ntpa/example/ntpa.graph.conf --temp /tmp/</Commandlineparameters>
<AssemblyName>ntpa</AssemblyName> <AssemblyName>ntpa</AssemblyName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Server|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Server|AnyCPU' ">
+17 -16
View File
@@ -120,17 +120,16 @@ namespace Ntp.Analyzer.Data.File
if (ip == null) { if (ip == null) {
try { try {
ip = Dns.GetHostAddresses (address) [0]; ip = Dns.GetHostAddresses (address) [0];
} catch (Exception exception) { } catch (Exception e) {
Debug.WriteLine (exception); Log.WriteLine (e, Severity.Trace);
return null;
} }
} else { } else {
try { try {
IPHostEntry hostEntry = Dns.GetHostEntry (ip); IPHostEntry hostEntry = Dns.GetHostEntry (ip);
name = hostEntry.HostName; name = hostEntry.HostName;
} catch (Exception exception) { } catch (Exception e) {
Debug.WriteLine (exception); Log.WriteLine (e, Severity.Trace);
return null; name = ip.ToString ();
} }
} }
@@ -139,17 +138,19 @@ namespace Ntp.Analyzer.Data.File
int orgPos = l.IndexOf ("#", StringComparison.Ordinal); int orgPos = l.IndexOf ("#", StringComparison.Ordinal);
if (orgPos != -1) { if (orgPos != -1) {
string org = l.Substring (orgPos + 1).Trim (); try {
orgPos = org.IndexOf (" ", StringComparison.Ordinal); string org = l.Substring (orgPos + 1).Trim ();
org = org.Substring (0, orgPos).Trim (); orgPos = org.IndexOf (" ", StringComparison.Ordinal);
org = org.Substring (0, orgPos).Trim ();
int realOrgId; int realOrgId;
if (Int32.TryParse (org, out realOrgId)) {
// Nullable not fully supported by NTP Analyzer. orgId = realOrgId;
if (!Int32.TryParse (org, out realOrgId)) }
return null; } catch {
// TODO: Make a more secure implementation
orgId = realOrgId; orgId = null;
}
} }
return new NtpConfEntry (role, ip, name, orgId); return new NtpConfEntry (role, ip, name, orgId);
@@ -64,7 +64,7 @@ namespace Ntp.Analyzer.Process.Description
foreach (NtpConfEntry entry in DataFace.Instance.NtpConfigCache[config.ConfigFile]) foreach (NtpConfEntry entry in DataFace.Instance.NtpConfigCache[config.ConfigFile])
{ {
IEnumerable<Peer> peers = DataFace.Instance.Peers.Where(p => p.OrgId == entry.OrgId.Value); IEnumerable<Peer> peers = DataFace.Instance.Peers.Where(p => p.Ip == entry.Address.ToString());
if (peers.Count() == 0) if (peers.Count() == 0)
{ {
+11 -1
View File
@@ -4,9 +4,19 @@
# Connection parameters to MySQL database instance. # Connection parameters to MySQL database instance.
Database { Database {
# Address of sql server
Host 127.0.0.1 Host 127.0.0.1
# Port of sql server. Leave empty to use default.
#Port 2567
# Name of database
Name ntpa Name ntpa
# Database username
User ntpau User ntpau
# Password for the user
Pass xxxx Pass xxxx
} }
@@ -35,7 +45,7 @@ Server {
ConfigFile /opt/ntpa/config/ntp.conf ConfigFile /opt/ntpa/config/ntp.conf
# Base path for generated files # Base path for generated files
FilePath graphs/ FilePath /usr/local/www/
# Base URL for generated files # Base URL for generated files
WebPath / WebPath /