diff --git a/local/share/check_mk/agents/special/agent_hal9001 b/local/share/check_mk/agents/special/agent_hal9001 index d5f5890..67533bc 100644 --- a/local/share/check_mk/agents/special/agent_hal9001 +++ b/local/share/check_mk/agents/special/agent_hal9001 @@ -98,7 +98,7 @@ def debugLog(function): # write output to file if debugLogFilename != "": try: - with open(debugLogFilename, "a") as f: + with open(debugLogFilename, "a+") as f: f.write(f"{out1}{out2}{out3}\n") except: sys.stderr.write(f"Something went wrong when writing to file {debugLogFilename}\n") @@ -210,7 +210,7 @@ def calculateNewUserStorage(current_storage: float) -> float: return float(new_storage) #@debugLog -def calculateNewStorageCounters(ul_bytes: float, dl_bytes: float) -> tuple: +def calculateNewStorageCounters(ul_bytes: float, dl_bytes: float) -> tuple[float, float]: # let the chance that no change occured be at 2% no_change = random.randint(1, 100) if no_change > 98: @@ -300,7 +300,7 @@ def doCmkHalStoragesOutput(storages: dict, hostname: str) -> None: print(f"{storage};{realname};{new_ul_bytes};{new_dl_bytes}") #@debugLog -def getStatus() -> tuple: +def getStatus() -> tuple[str, str]: # randomly set one of the three available states status_index = random.randint(1,100) if status_index <= 5: @@ -315,14 +315,14 @@ def getStatus() -> tuple: return hal_status, hal_version #@debugLog -def doLogin(hostname: str, username: str, password: str) -> tuple: +def doLogin(hostname: str, username: str, password: str) -> tuple[bool, int]: # simulate the login to our HAL system # give it a chance of 2% to fail to demonstrate an error from time to time success = random.randint(1, 100) if success > 2: return True, 200 else: - return False, 404 + return False, 401 def main(): global debugLogFilename diff --git a/mkp/hal9001-1.0.7.mkp b/mkp/hal9001-1.0.7.mkp new file mode 100644 index 0000000..c8fd04a Binary files /dev/null and b/mkp/hal9001-1.0.7.mkp differ