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

Ntpq host importer. More...

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

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 kerninfo -c sysinfo " + address
 
override string Command => "ntpq"
 
override string ErrorMessage => LogMessage.ImportHostError
 
- Protected Attributes inherited from Ntp.Analyzer.Import.Importer< HostReading >
IList< T > Entries
 

Package Functions

 NtpqHostImporter (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

Ntpq host importer.

Definition at line 34 of file NtpqHostImporter.cs.

Constructor & Destructor Documentation

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

Definition at line 36 of file NtpqHostImporter.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.NtpqHostImporter.CreateEntry ( string  peerIp,
double  offset,
double  jitter,
double  frequency,
double  stability 
)
inlineprivate

Definition at line 112 of file NtpqHostImporter.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.NtpqHostImporter.Initialize ( )
inlineprotectedvirtual

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

Definition at line 55 of file NtpqHostImporter.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.NtpqHostImporter.ReadFromStream ( )
inlineprotectedvirtual

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

Definition at line 65 of file NtpqHostImporter.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, 19).Replace(":", string.Empty).TrimEnd();
81  string value = line.Substring(19).Trim();
82 
83  switch (name)
84  {
85  case "system peer":
86  peerIp = value.Replace(":123", string.Empty).Trim();
87  break;
88  case "pll offset":
89  offset = Convert.ToDouble(value.Replace("s", string.Empty).Trim());
90  break;
91  case "pll frequency":
92  frequency = Convert.ToDouble(value.Replace("ppm", string.Empty).Trim());
93  break;
94  case "clock jitter":
95  jitter = Convert.ToDouble(value.Replace("s", string.Empty).Trim());
96  break;
97  case "clock wander":
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.NtpqHostImporter.address
private

Definition at line 44 of file NtpqHostImporter.cs.

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

Definition at line 51 of file NtpqHostImporter.cs.

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

Definition at line 45 of file NtpqHostImporter.cs.

override string Ntp.Analyzer.Import.NtpqHostImporter.Command => "ntpq"
protected

Definition at line 49 of file NtpqHostImporter.cs.

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

Definition at line 53 of file NtpqHostImporter.cs.

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

Definition at line 46 of file NtpqHostImporter.cs.

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

Definition at line 47 of file NtpqHostImporter.cs.


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