From 45f892798387f89ec3cf2976a1a2d0fca9f98498 Mon Sep 17 00:00:00 2001 From: Thomas Widhalm Date: Thu, 7 Nov 2019 16:02:06 +0100 Subject: [PATCH] Change check for version to Icinga 2 internal version check from using package manager helps with #93 --- icinga-diagnostics.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/icinga-diagnostics.py b/icinga-diagnostics.py index 7c08616..2ac7407 100644 --- a/icinga-diagnostics.py +++ b/icinga-diagnostics.py @@ -46,9 +46,12 @@ def __init__(self): class Icingainstance: def __init__(self): try: - self.version = str(subprocess.check_output(["rpm","-q","icinga2"])) + versionoutput = subprocess.check_output(["icinga2","--version"]).splitlines() + for line in versionoutput: + if "Icinga 2 network monitoring daemon" in line: + self.version = str(line.split(':')[1].split('-')[0]) except: - print("Icinga 2 is not installed") + self.version = "Not installed" # print header @@ -86,7 +89,4 @@ def __init__(self): icingacore = Icingainstance() -try: - print("Icinga 2: " + icingacore.version) -except AttributeError: - print("Icinga2 not installed") +print("Icinga 2: " + icingacore.version)