26 namespace Ntp.Analyzer.Import
38 protected override string Command =>
"ntpctl";
40 protected override string Arguments =>
"-sp";
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));
53 string value = stats.Substring(31, 10).Trim().Replace(
"ms",
string.Empty);
54 double offset =
double.TryParse(value, out result)
58 value = stats.Substring(41, 10).Trim().Replace(
"ms",
string.Empty);
59 double delay =
double.TryParse(value, out result)
63 value = stats.Substring(51, stats.Length - 51).Trim().Replace(
"ms",
string.Empty);
64 double jitter =
double.TryParse(value, out result)
68 string remote = peer.Substring(0, peer.IndexOf(
" ", StringComparison.Ordinal)).Trim();
71 hostId, state, remote, null, stratus, weight,
72 lastPoll, pollFrequency, trustlevel,
73 delay, offset, jitter);
80 char pollUnit = pollString.Substring(pollString.Length - 1, 1)[0];
81 string pollValue = pollString.Substring(0, pollString.Length - 1).Trim();
86 return Convert.ToInt32(pollValue);
88 return Convert.ToInt32(pollValue)*60;
90 return Convert.ToInt32(pollValue)*60*60;
92 return Convert.ToInt32(pollValue)*60*60*24;
96 return Convert.ToInt32(pollString);
static int CalcPoll(string pollString)
NtpctlImporter(int hostId, LogBase log)
AssociationEntry ParseLines(string peer, string stats)