Dima Kuznetsov has uploaded a new change for review. Change subject: core: Add boot time to the getVdsStats API ......................................................................
core: Add boot time to the getVdsStats API Calculate boot time from /proc/uptime and encode ISO8601 string with the assumed boot time Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1070348 Change-Id: I319e619cdaecac2f86d0154e3adbb3beda9c57d6 Signed-off-by: Dima Kuznetsov <[email protected]> --- M vdsm/sampling.py M vdsm_api/vdsmapi-schema.json 2 files changed, 17 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/77/25877/1 diff --git a/vdsm/sampling.py b/vdsm/sampling.py index 6ff0641..62fb57c 100644 --- a/vdsm/sampling.py +++ b/vdsm/sampling.py @@ -32,6 +32,7 @@ import logging import errno import ethtool +import datetime from vdsm import utils from vdsm import netinfo @@ -194,6 +195,17 @@ self.thpState = s[s.index('[') + 1:s.index(']')] except: self.thpState = 'never' + + # Calculate boot time + # Maybe we should do it only once?? + try: + with file('/proc/uptime') as f: + uptime = float(f.read().split()[0]) + bootTime = (datetime.datetime.utcnow() - + datetime.timedelta(seconds=uptime)) + self.bootTime = bootTime.strftime('%FT%T GMT') + except: + pass class AdvancedStatsFunction(object): @@ -449,6 +461,8 @@ stats['diskStats'] = hs1.diskStats stats['thpState'] = hs1.thpState + if hasattr(hs1, 'bootTime'): + stats['bootTime'] = hs1.bootTime return stats def _getInterfacesStats(self): diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json index 4f7cc58..de25ad8 100644 --- a/vdsm_api/vdsmapi-schema.json +++ b/vdsm_api/vdsmapi-schema.json @@ -1690,6 +1690,8 @@ # @haStatus: The current status of the Hosted Engine HA system # (new in version 4.14.0) # +# @bootTime: The boot time of the host in UTC format (new in ???) +# # Since: 4.10.0 ## {'type': 'HostStats', @@ -1708,7 +1710,7 @@ 'dateTime': 'str', 'ksmState': 'bool', 'ksmPages': 'int', 'ksmCpu': 'float', 'netConfigDirty': 'bool', 'generationID': 'UUID', 'momStatus': 'MOMStatus', '*haScore': 'int', - 'haStatus': 'HostedEngineStatus'}} + 'haStatus': 'HostedEngineStatus', 'bootTime': 'str'}} ## # @Host.getStats: -- To view, visit http://gerrit.ovirt.org/25877 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I319e619cdaecac2f86d0154e3adbb3beda9c57d6 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dima Kuznetsov <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
