[Git][NTPsec/ntpsec][21C08-stat-duality] WIP DRAFT ntpq: If sysstat duality fails do not drop to singleton ...
James Browning
gitlab at mg.gitlab.com
Mon Mar 8 17:46:24 UTC 2021
James Browning pushed to branch 21C08-stat-duality at NTPsec / ntpsec
Commits:
b215f493 by James Browning at 2021-03-08T09:44:15-08:00
WIP DRAFT ntpq: If sysstat duality fails do not drop to singleton ...
Instead print out annoying '???' and crawl forward on stumps.
- - - - -
1 changed file:
- ntpclients/ntpq.py
Changes:
=====================================
ntpclients/ntpq.py
=====================================
@@ -415,7 +415,7 @@ usage: timeout [ msec ]
items.append((name, (value, rawvalue)))
except ntp.packet.ControlException as e:
if ntp.control.CERR_UNKNOWNVAR == e.errorcode:
- items.append((var, "???"))
+ items.append((var, ("???", None)))
continue
raise e
queried = ntp.util.OrderedDict(items)
@@ -437,17 +437,22 @@ usage: timeout [ msec ]
value2 = queried[name + '_r'][0]
rawvalue2 = queried[name + '_r'][1]
if fmt in (NTP_UINT, NTP_INT, NTP_FLOAT):
- if self.showunits:
- displayvalue = ntp.util.unitifyvar(rawvalue, name)
- displayvalue2 = ntp.util.unitifyvar(rawvalue2, name)
+ if self.showunits and isinstance(rawvalue, (int, float)):
+ display = ntp.util.unitifyvar(rawvalue, name)
else:
- displayvalue = value
- displayvalue2 = value2
- self.say("%13s \t%9d\t%9d\n" %
- (legend, displayvalue, displayvalue2))
+ display = value
+ if self.showunits and isinstance(rawvalue2, (int, float)):
+ display2 = ntp.util.unitifyvar(rawvalue2, name)
+ else:
+ display2 = value2
+ self.say("%13s \t%9s\t%9s\n" %
+ (legend, display, display2))
elif fmt == NTP_UPTIME:
- self.say("%13s %s\t%s\n" % (legend, ntp.util.prettyuptime(
- value), ntp.util.prettyuptime(value2)))
+ self.say("%13s %s\t%s\n" % (legend,
+ value if not isinstance(value, int) else
+ ntp.util.prettyuptime(value),
+ value2 if not isinstance(value2, int) else
+ ntp.util.prettyuptime(value2)))
else:
self.warn("unexpected vc type %s for %s, value %s"
% (fmt, name, value, value2))
@@ -1543,10 +1548,7 @@ usage: kerninfo
("ss_processed", "processed for time: ", NTP_INT),
)
self.collect_display(associd=0, variables=sysstats, decodestatus=False)
- try:
- self.collect_display2(variables=sysstats2)
- except:
- self.collect_display(associd=0, variables=sysstats2, decodestatus=False)
+ self.collect_display2(variables=sysstats2)
def help_sysstats(self):
self.say("""\
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/b215f493f6d120ab1338a2edae8a3422b701e625
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/b215f493f6d120ab1338a2edae8a3422b701e625
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20210308/4a7a6643/attachment-0001.htm>
More information about the vc
mailing list