NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Import.NtpctlImporter< T > Class Template Reference
Inheritance diagram for Ntp.Analyzer.Import.NtpctlImporter< T >:
Collaboration diagram for Ntp.Analyzer.Import.NtpctlImporter< T >:

Protected Member Functions

 NtpctlImporter (int hostId, LogBase log)
 
AssociationEntry ParseLines (string peer, string stats)
 
- Protected Member Functions inherited from Ntp.Analyzer.Import.Importer< T >
 Importer (LogBase log)
 
virtual void Initialize ()
 
abstract void ReadFromStream ()
 

Protected Attributes

override string Arguments => "-sp"
 
override string Command => "ntpctl"
 
- Protected Attributes inherited from Ntp.Analyzer.Import.Importer< T >
IList< T > Entries => entries
 

Static Private Member Functions

static int CalcPoll (string pollString)
 

Private Attributes

readonly int hostId
 

Additional Inherited Members

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

Detailed Description

Definition at line 28 of file NtpctlImporter.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Import.NtpctlImporter< T >.NtpctlImporter ( int  hostId,
LogBase  log 
)
inlineprotected

Definition at line 30 of file NtpctlImporter.cs.

31  : base(log)
32  {
33  this.hostId = hostId;
34  }

Member Function Documentation

static int Ntp.Analyzer.Import.NtpctlImporter< T >.CalcPoll ( string  pollString)
inlinestaticprivate

Definition at line 78 of file NtpctlImporter.cs.

79  {
80  char pollUnit = pollString.Substring(pollString.Length - 1, 1)[0];
81  string pollValue = pollString.Substring(0, pollString.Length - 1).Trim();
82 
83  switch (pollUnit)
84  {
85  case 's':
86  return Convert.ToInt32(pollValue);
87  case 'm':
88  return Convert.ToInt32(pollValue)*60;
89  case 'h':
90  return Convert.ToInt32(pollValue)*60*60;
91  case 'd':
92  return Convert.ToInt32(pollValue)*60*60*24;
93  case '-':
94  return -1;
95  default:
96  return Convert.ToInt32(pollString);
97  }
98  }
AssociationEntry Ntp.Analyzer.Import.NtpctlImporter< T >.ParseLines ( string  peer,
string  stats 
)
inlineprotected

Definition at line 42 of file NtpctlImporter.cs.

43  {
44  double result;
45 
46  char state = stats[1];
47  char weight = stats[4];
48  int trustlevel = Convert.ToInt32(stats.Substring(6, 2).Trim());
49  int stratus = Convert.ToInt32(stats.Substring(9, 2).Trim().Replace("-", "15"));
50  int lastPoll = CalcPoll(stats.Substring(11, 6));
51  int pollFrequency = CalcPoll(stats.Substring(17, 6));
52 
53  string value = stats.Substring(31, 10).Trim().Replace("ms", string.Empty);
54  double offset = double.TryParse(value, out result)
55  ? result
56  : 0.0;
57 
58  value = stats.Substring(41, 10).Trim().Replace("ms", string.Empty);
59  double delay = double.TryParse(value, out result)
60  ? result
61  : 0.0;
62 
63  value = stats.Substring(51, stats.Length - 51).Trim().Replace("ms", string.Empty);
64  double jitter = double.TryParse(value, out result)
65  ? result
66  : 0.0;
67 
68  string remote = peer.Substring(0, peer.IndexOf(" ", StringComparison.Ordinal)).Trim();
69 
70  var entry = new AssociationEntry(
71  hostId, state, remote, null, stratus, weight,
72  lastPoll, pollFrequency, trustlevel,
73  delay, offset, jitter);
74 
75  return entry;
76  }
static int CalcPoll(string pollString)

Member Data Documentation

override string Ntp.Analyzer.Import.NtpctlImporter< T >.Arguments => "-sp"
protected

Definition at line 40 of file NtpctlImporter.cs.

override string Ntp.Analyzer.Import.NtpctlImporter< T >.Command => "ntpctl"
protected

Definition at line 38 of file NtpctlImporter.cs.

readonly int Ntp.Analyzer.Import.NtpctlImporter< T >.hostId
private

Definition at line 36 of file NtpctlImporter.cs.


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