diff options
-rw-r--r-- | sos/policies/__init__.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index 07e07970..bd9ea4b1 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -124,17 +124,22 @@ class InitSystem(object): """Returns the status for the given service name along with the output of the query command """ + _default = { + 'name': name, + 'status': 'missing', + 'output': '' + } + if name not in self.services: + return _default + if 'status' in self.services[name]: + # service status has been queried before, return existing info + return self.services[name] svc = self._query_service(name) if svc is not None: - return {'name': name, - 'status': self.parse_query(svc['output']), - 'output': svc['output'] - } - else: - return {'name': name, - 'status': 'missing', - 'output': '' - } + self.services[name]['status'] = self.parse_query(svc['output']) + self.services[name]['output'] = svc['output'] + return self.services[name] + return _default class SystemdInit(InitSystem): |