Merge pull request #35 from bashclub/testing

v1.0.5
This commit is contained in:
Thorsten Spille 2023-05-31 16:29:25 +02:00 committed by GitHub
commit 871096371f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@
## * smartdisk - install the mkp from https://github.com/bashclub/checkmk-smart plugins os-smart ## * smartdisk - install the mkp from https://github.com/bashclub/checkmk-smart plugins os-smart
## * squid - install the mkp from https://exchange.checkmk.com/p/squid and forwarder -> listen on loopback active ## * squid - install the mkp from https://exchange.checkmk.com/p/squid and forwarder -> listen on loopback active
__VERSION__ = "1.0.2" __VERSION__ = "1.0.5"
import sys import sys
import os import os
@ -63,13 +63,17 @@ from socketserver import TCPServer,StreamRequestHandler
SCRIPTPATH = os.path.abspath(__file__) SCRIPTPATH = os.path.abspath(__file__)
SYSHOOK_METHOD = re.findall("rc\.syshook\.d\/(start|stop)/",SCRIPTPATH) SYSHOOK_METHOD = re.findall("rc\.syshook\.d\/(start|stop)/",SCRIPTPATH)
BASEDIR = "/usr/local/checkmk_agent" BASEDIR = "/usr/local/check_mk_agent"
CHECKMK_CONFIG = "/usr/local/etc/checkmk.conf" CHECKMK_CONFIG = "/usr/local/etc/checkmk.conf"
MK_CONFDIR = os.path.dirname(CHECKMK_CONFIG) MK_CONFDIR = os.path.dirname(CHECKMK_CONFIG)
LOCALDIR = os.path.join(BASEDIR,"local") LOCALDIR = os.path.join(BASEDIR,"local")
PLUGINSDIR = os.path.join(BASEDIR,"plugins") PLUGINSDIR = os.path.join(BASEDIR,"plugins")
SPOOLDIR = os.path.join(BASEDIR,"spool") SPOOLDIR = os.path.join(BASEDIR,"spool")
os.environ["MK_CONFDIR"] = MK_CONFDIR
os.environ["MK_LIBDIR"] = BASEDIR
os.environ["MK_VARDIR"] = BASEDIR
class object_dict(defaultdict): class object_dict(defaultdict):
def __getattr__(self,name): def __getattr__(self,name):
return self[name] if name in self else "" return self[name] if name in self else ""
@ -217,7 +221,10 @@ class checkmk_checker(object):
except: except:
_cachetime = 0 _cachetime = 0
try: try:
if _cachetime > 0:
_lines.append(self._run_cache_prog(_plugin_file,_cachetime)) _lines.append(self._run_cache_prog(_plugin_file,_cachetime))
else:
_lines.append(self._run_prog(_plugin_file))
except: except:
_errors.append(traceback.format_exc()) _errors.append(traceback.format_exc())
@ -241,7 +248,10 @@ class checkmk_checker(object):
except: except:
_cachetime = 0 _cachetime = 0
try: try:
if _cachetime > 0:
_lines.append(self._run_cache_prog(_local_file,_cachetime)) _lines.append(self._run_cache_prog(_local_file,_cachetime))
else:
_lines.append(self._run_prog(_local_file))
except: except:
_errors.append(traceback.format_exc()) _errors.append(traceback.format_exc())
@ -952,7 +962,7 @@ class checkmk_checker(object):
_required_phase2 = len(list(filter(lambda x: x.get("ikeid") == _ikeid,_phase2config))) _required_phase2 = len(list(filter(lambda x: x.get("ikeid") == _ikeid,_phase2config)))
if _phase2_up == _required_phase2: if _phase2_up >= _required_phase2:
_ret.append("{status} \"IPsec Tunnel: {remote-name}\" if_in_octets={bytes-received}|if_out_octets={bytes-sent}|lifetime={life-time} {state} {local-id} - {remote-id}({remote-host})".format(**_con)) _ret.append("{status} \"IPsec Tunnel: {remote-name}\" if_in_octets={bytes-received}|if_out_octets={bytes-sent}|lifetime={life-time} {state} {local-id} - {remote-id}({remote-host})".format(**_con))
elif _phase2_up == 0: elif _phase2_up == 0:
if _condata.keys(): if _condata.keys():