26 namespace Ntp.Analyzer.Import
36 this.address = address;
43 protected override string Command =>
"ntpq";
45 protected override string Arguments =>
"-np " + address;
55 while (Reader.Peek() != -1)
57 string line = Reader.ReadLine();
59 if (
string.IsNullOrWhiteSpace(line))
62 var entry = ParseLine(line);
69 string lastPollString = line.Substring(38, 4);
71 char lastPollUnit = lastPollString.Substring(lastPollString.Length - 1, 1)[0];
72 string lastPollValue = lastPollString.Substring(0, lastPollString.Length - 1).Trim();
77 return Convert.ToInt32(lastPollValue)*60;
79 return Convert.ToInt32(lastPollValue)*60*60;
81 return Convert.ToInt32(lastPollValue)*60*60*24;
85 return Convert.ToInt32(lastPollString);
92 string remote = line.Substring(1, 16).Trim();
93 string refid = line.Substring(17, 16).Trim();
94 int stratus = Convert.ToInt32(line.Substring(33, 2).Trim());
96 int lastPoll = CalcLastPoll(line);
97 int pollFrequency = Convert.ToInt32(line.Substring(43, 4).Trim());
98 int reach = Convert.ToInt32(line.Substring(49, 3).Trim());
99 double delay = Convert.ToDouble(line.Substring(53, 8).Trim());
100 double offset = Convert.ToDouble(line.Substring(61, 9).Trim());
101 double jitter = Convert.ToDouble(line.Substring(70, 8).Trim());
104 hostId, state, remote, refid, stratus, t,
105 lastPoll, pollFrequency, reach, delay, offset, jitter);
NtpqPeerImporter(string address, int hostId, LogBase log)
Ntpq mapper parses status importLines from ntpq into objects.
static int CalcLastPoll(string line)
AssociationEntry ParseLine(string line)
const string ImportPeerError
override void ReadFromStream()