NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Import.NtpdcImporter Class Reference

Ntpdc importer. More...

Inheritance diagram for Ntp.Analyzer.Import.NtpdcImporter:
Collaboration diagram for Ntp.Analyzer.Import.NtpdcImporter:

Protected Member Functions

override void Initialize ()
 
override void ReadFromStream ()
 
- Protected Member Functions inherited from Ntp.Analyzer.Import.Importer< HostReading >
 Importer (LogBase log)
 

Protected Attributes

override string Arguments => "-nc loopinfo -c sysinfo " + address
 
override string Command => "ntpdc"
 
override string ErrorMessage => LogMessage.ImportHostError
 
- Protected Attributes inherited from Ntp.Analyzer.Import.Importer< HostReading >
IList< T > Entries
 

Package Functions

 NtpdcImporter (string address, Host host, ReadingBulk bulk, LogBase log)
 

Private Member Functions

void CreateEntry (string peerIp, double offset, double jitter, double frequency, double stability)
 

Private Attributes

readonly string address
 
readonly ReadingBulk bulk
 
readonly Host host
 
List< Peerpeers
 

Additional Inherited Members

- Public Member Functions inherited from Ntp.Analyzer.Import.Importer< HostReading >
void Execute ()
 
IEnumerator< T > GetEnumerator ()
 
- Properties inherited from Ntp.Analyzer.Import.Importer< HostReading >
abstract string Arguments [get]
 
abstract string Command [get]
 
abstract string ErrorMessage [get]
 
LogBase Log [get]
 
StreamReader Reader [get, private set]
 

Detailed Description

Ntpdc importer.

Definition at line 34 of file NtpdcImporter.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Import.NtpdcImporter.NtpdcImporter ( string  address,
Host  host,
ReadingBulk  bulk,
LogBase  log 
)
inlinepackage

Definition at line 36 of file NtpdcImporter.cs.

37  : base(log)
38  {
39  this.address = address;
40  this.host = host;
41  this.bulk = bulk;
42  }

Member Function Documentation

void Ntp.Analyzer.Import.NtpdcImporter.CreateEntry ( string  peerIp,
double  offset,
double  jitter,
double  frequency,
double  stability 
)
inlineprivate

Definition at line 112 of file NtpdcImporter.cs.

References Ntp.Analyzer.Objects.NamedObject.Name.

113  {
114  IEnumerable<Peer> peerList = peers.Where(p => p.Ip == peerIp).ToList();
115 
116  Peer peer;
117 
118  switch (peerList.Count())
119  {
120  case 1:
121  peer = peerList.Single();
122  break;
123  case 0:
124  Log.PeerNotFound(host.Name, peerIp);
125  return;
126  default:
127  Log.MultiplePeersFound(host.Name, peerIp);
128  return;
129  }
130 
131  Log.Syncing(host.Name, peer.Name);
132 
133  var reading = new HostReading(host, peer, bulk, offset, jitter, frequency, stability);
134  Entries.Add(reading);
135  }
override void Ntp.Analyzer.Import.NtpdcImporter.Initialize ( )
inlineprotectedvirtual

Reimplemented from Ntp.Analyzer.Import.Importer< HostReading >.

Definition at line 55 of file NtpdcImporter.cs.

References Ntp.Analyzer.Data.DataFace.Instance, and Ntp.Analyzer.Data.DataFace.Peers.

56  {
57  base.Initialize();
58 
59  if (host == null)
60  return;
61 
62  peers = DataFace.Instance.Peers.ToList();
63  }
PeerDatabaseMapper Peers
Gets the peer mapper.
Definition: DataFace.cs:63
Singleton facade class used to access memory persistent data.
Definition: DataFace.cs:30
static DataFace Instance
Gets the Singleton instance.
Definition: DataFace.cs:51
override void Ntp.Analyzer.Import.NtpdcImporter.ReadFromStream ( )
inlineprotectedvirtual

Implements Ntp.Analyzer.Import.Importer< HostReading >.

Definition at line 65 of file NtpdcImporter.cs.

66  {
67  string peerIp = null;
68  double offset = 0;
69  double frequency = 0;
70  double jitter = 0;
71  double stability = 0;
72 
73  while (Reader.Peek() != -1)
74  {
75  string line = Reader.ReadLine();
76 
77  if (string.IsNullOrWhiteSpace(line) || line.Length < 24)
78  continue;
79 
80  string name = line.Substring(0, 22).Replace(":", string.Empty).TrimEnd();
81  string value = line.Substring(22).TrimEnd();
82 
83  switch (name)
84  {
85  case "system peer":
86  peerIp = value.Trim();
87  break;
88  case "offset":
89  offset = Convert.ToDouble(value.Replace("s", string.Empty).Trim());
90  break;
91  case "frequency":
92  frequency = Convert.ToDouble(value.Replace("ppm", string.Empty).Trim());
93  break;
94  case "jitter":
95  jitter = Convert.ToDouble(value.Replace("s", string.Empty).Trim());
96  break;
97  case "stability":
98  stability = Convert.ToDouble(value.Replace("ppm", string.Empty).Trim());
99  break;
100  }
101  }
102 
103  if (peerIp != null && peerIp.StartsWith("0.0.0.0"))
104  {
105  Log.NoSyncing(host.Name);
106  return;
107  }
108 
109  CreateEntry(peerIp, offset, jitter, frequency, stability);
110  }
void CreateEntry(string peerIp, double offset, double jitter, double frequency, double stability)

Member Data Documentation

readonly string Ntp.Analyzer.Import.NtpdcImporter.address
private

Definition at line 44 of file NtpdcImporter.cs.

override string Ntp.Analyzer.Import.NtpdcImporter.Arguments => "-nc loopinfo -c sysinfo " + address
protected

Definition at line 51 of file NtpdcImporter.cs.

readonly ReadingBulk Ntp.Analyzer.Import.NtpdcImporter.bulk
private

Definition at line 45 of file NtpdcImporter.cs.

override string Ntp.Analyzer.Import.NtpdcImporter.Command => "ntpdc"
protected

Definition at line 49 of file NtpdcImporter.cs.

override string Ntp.Analyzer.Import.NtpdcImporter.ErrorMessage => LogMessage.ImportHostError
protected

Definition at line 53 of file NtpdcImporter.cs.

readonly Host Ntp.Analyzer.Import.NtpdcImporter.host
private

Definition at line 46 of file NtpdcImporter.cs.

List<Peer> Ntp.Analyzer.Import.NtpdcImporter.peers
private

Definition at line 47 of file NtpdcImporter.cs.


The documentation for this class was generated from the following file: