diff --git a/README.md b/README.md index 85e8233..aaf6856 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Version History: -- |Date|Version|Changes| |----|-------|-------| +|2023/11/26|2.3.4|Fixed agent crash if opcache_get_status is disabled by server settings| |2023/08/16|2.3.3|Fixed some misleading info strings regarding database opcache| |2023/08/12|2.3.2|MKP now compatible with CheckMK 2.2| |2023/03/27|2.3.1|Fixed bugs in parameter handling| diff --git a/local/lib/python3/cmk/base/plugins/agent_based/nextcloud_database.py b/local/lib/python3/cmk/base/plugins/agent_based/nextcloud_database.py index 240716a..7a179c0 100644 --- a/local/lib/python3/cmk/base/plugins/agent_based/nextcloud_database.py +++ b/local/lib/python3/cmk/base/plugins/agent_based/nextcloud_database.py @@ -35,6 +35,9 @@ def check_nextcloud_database(params, section): yield Metric("nc_database_size", size) state = getStateLower(levels, opcache_hit_rate) summary = f"PHP OPCache hit rate: {render.percent(opcache_hit_rate)}" + if opcache_hit_rate == 0: + state = State.UNKNOWN + summary = f"PHP OPCache hit rate: 0% - please check if opcache_get_status is enabled" details = f"\nDatabase type: {type}\nDatabase version: {version}\nDatabase size: {render.bytes(size)}" yield(Result(state=state, summary=summary, details=details)) diff --git a/local/share/check_mk/agents/special/agent_nextcloud b/local/share/check_mk/agents/special/agent_nextcloud index c4dc655..67a907c 100755 --- a/local/share/check_mk/agents/special/agent_nextcloud +++ b/local/share/check_mk/agents/special/agent_nextcloud @@ -227,7 +227,12 @@ def doCmkOutput(data): print(f"NC_Database_Type;{data['ocs']['data']['server']['database']['type']}") print(f"NC_Database_Version;{data['ocs']['data']['server']['database']['version']}") print(f"NC_Database_Size;{data['ocs']['data']['server']['database']['size']}") - print(f"NC_OPCache_Hit_Rate;{data['ocs']['data']['server']['php']['opcache']['opcache_statistics']['opcache_hit_rate']}") + # opcache entry does not exist if opcache_get_status is disabled by server settings + # thanks to Marcus Klein from Iteratio to report (and solve!) this bug + if (data['ocs']['data']['server']['php']['opcache']): + print(f"NC_OPCache_Hit_Rate;{data['ocs']['data']['server']['php']['opcache']['opcache_statistics']['opcache_hit_rate']}") + else: + print(f"NC_OPCache_Hit_Rate;0") def doCmkOutputAllUsers(data, verify, hostname, protocol, port, folder): print("<<>>") diff --git a/mkp/Nextcloud-2.3.4.mkp b/mkp/Nextcloud-2.3.4.mkp new file mode 100755 index 0000000..6222091 Binary files /dev/null and b/mkp/Nextcloud-2.3.4.mkp differ