Version 2.2.1
This commit is contained in:
parent
f1f5083ed8
commit
dd5c3c14d2
12
README.md
12
README.md
@ -1,10 +1,16 @@
|
|||||||
# Nextcloud-CheckMK
|
# Nextcloud CheckMK Special Agent
|
||||||
|
|
||||||
CheckMK Special Agent for Nextcloud
|
|
||||||
--
|
--
|
||||||
Monitors various aspects of Nextcloud instances like state, quota and disk usage of all users, number of apps with available updates, database cache hit rate and so on.
|
Monitors various aspects of Nextcloud instances like state, quota and disk usage of all users, number of apps with available updates, database cache hit rate and so on.
|
||||||
Gives additional information regarding versions of Nextcloud, database, number of storages and active users etc.
|
Gives additional information regarding versions of Nextcloud, database, number of storages and active users etc.
|
||||||
|
|
||||||
|
Version History:
|
||||||
|
--
|
||||||
|
2023/03/23: 2.2.1 Adjusted parameter handling
|
||||||
|
Added check for "free space on disk" (incl. adjustable levels)
|
||||||
|
Added adjustable levels for "number of files"
|
||||||
|
2023/03/11: 2.2.0 Upload initial public release
|
||||||
|
|
||||||
|
--
|
||||||
Example how the checks look like:
|
Example how the checks look like:
|
||||||
--
|
--
|
||||||
![Nextcloud Checks](images/Nextcloud-Checks.png)
|
![Nextcloud Checks](images/Nextcloud-Checks.png)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 34 KiB |
Binary file not shown.
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 24 KiB |
@ -24,20 +24,47 @@ def discover_nextcloud_info(section):
|
|||||||
def check_nextcloud_info(params, section):
|
def check_nextcloud_info(params, section):
|
||||||
for key in section:
|
for key in section:
|
||||||
if key == "nextcloud":
|
if key == "nextcloud":
|
||||||
|
levels_free_space = params["levels_free_space"]
|
||||||
|
levels_number_of_files = params["levels_number_of_files"]
|
||||||
status = section[key]["status"]
|
status = section[key]["status"]
|
||||||
|
free_space = section[key]["freespace"]
|
||||||
version = section[key]["version"]
|
version = section[key]["version"]
|
||||||
|
php_version = section[key]["php_version"]
|
||||||
|
webserver = section[key]["webserver"]
|
||||||
num_files = section[key]["number_files"]
|
num_files = section[key]["number_files"]
|
||||||
num_shares = section[key]["number_shares"]
|
num_shares = section[key]["number_shares"]
|
||||||
|
|
||||||
# create graph for number of files and shares
|
# create graph for number of files and shares
|
||||||
yield(Metric("nc_num_files", num_files))
|
yield(Metric("nc_num_files", num_files))
|
||||||
yield(Metric("nc_num_shares", num_shares))
|
yield(Metric("nc_num_shares", num_shares))
|
||||||
|
|
||||||
|
# create overall result
|
||||||
summary = f"Status is {status}"
|
summary = f"Status is {status}"
|
||||||
details = f"Version is {version}\nNumber of files: {num_files}\nNumber of shares: {num_shares}\n"
|
details = f"Nextcloud version: {version}\nPHP version: {php_version}\nWebserver: {webserver}\n\nNumber of files: {num_files}\nNumber of shares: {num_shares}\n\nFree space on disk: {render.bytes(free_space)}\n"
|
||||||
if status == "ok":
|
if status == "ok":
|
||||||
state = State.OK
|
state = State.OK
|
||||||
else:
|
else:
|
||||||
state = State.CRIT
|
state = State.CRIT
|
||||||
yield Result(state=state, summary=summary, details=details)
|
yield Result(state=state, summary=summary, details=details)
|
||||||
|
|
||||||
|
# Create result for free space on disk
|
||||||
|
# Levels for free space are given in GBytes, we have to adjust this here
|
||||||
|
warn, crit = levels_free_space
|
||||||
|
warn = warn*1024*1024*1024
|
||||||
|
crit = crit*1024*1024*1024
|
||||||
|
state = getStateLower((warn, crit), free_space)
|
||||||
|
# create graph for free space on disk
|
||||||
|
yield(Metric("nc_free_space", free_space, levels=(warn,crit)))
|
||||||
|
notice = f"Remaining free space on disk: {render.bytes(free_space)}"
|
||||||
|
if state != State.OK:
|
||||||
|
yield(Result(state=state, notice=notice))
|
||||||
|
|
||||||
|
# Create result for number of files
|
||||||
|
warn, crit = levels_number_of_files
|
||||||
|
state = getStateUpper((warn, crit), num_files)
|
||||||
|
notice = f"Number of files: {num_files}"
|
||||||
|
if state != State.OK:
|
||||||
|
yield(Result(state=state, notice=notice))
|
||||||
elif key == "users":
|
elif key == "users":
|
||||||
num_users = section[key]["number"]
|
num_users = section[key]["number"]
|
||||||
num_active_last1hour = section[key]["active_last1hour"]
|
num_active_last1hour = section[key]["active_last1hour"]
|
||||||
@ -82,7 +109,10 @@ def parse_nextcloud_info_section(string_table):
|
|||||||
}
|
}
|
||||||
params_list = [
|
params_list = [
|
||||||
"NC_Version",
|
"NC_Version",
|
||||||
|
"NC_Freespace",
|
||||||
"NC_Status",
|
"NC_Status",
|
||||||
|
"NC_Webserver",
|
||||||
|
"NC_PHP_Version",
|
||||||
"NC_Num_Users",
|
"NC_Num_Users",
|
||||||
"NC_Num_Files",
|
"NC_Num_Files",
|
||||||
"NC_Num_Shares",
|
"NC_Num_Shares",
|
||||||
@ -102,8 +132,14 @@ def parse_nextcloud_info_section(string_table):
|
|||||||
value = line[1]
|
value = line[1]
|
||||||
if param == "NC_Version":
|
if param == "NC_Version":
|
||||||
parsed_data["nextcloud"]["version"] = value
|
parsed_data["nextcloud"]["version"] = value
|
||||||
|
elif param == "NC_Freespace":
|
||||||
|
parsed_data["nextcloud"]["freespace"] = float(value)
|
||||||
elif param == "NC_Status":
|
elif param == "NC_Status":
|
||||||
parsed_data["nextcloud"]["status"] = value
|
parsed_data["nextcloud"]["status"] = value
|
||||||
|
elif param == "NC_Webserver":
|
||||||
|
parsed_data["nextcloud"]["webserver"] = value
|
||||||
|
elif param == "NC_PHP_Version":
|
||||||
|
parsed_data["nextcloud"]["php_version"] = value
|
||||||
elif param == "NC_Num_Files":
|
elif param == "NC_Num_Files":
|
||||||
parsed_data["nextcloud"]["number_files"] = int(value)
|
parsed_data["nextcloud"]["number_files"] = int(value)
|
||||||
elif param == "NC_Num_Shares":
|
elif param == "NC_Num_Shares":
|
||||||
@ -142,6 +178,8 @@ register.check_plugin(
|
|||||||
check_function=check_nextcloud_info,
|
check_function=check_nextcloud_info,
|
||||||
check_default_parameters={
|
check_default_parameters={
|
||||||
"levels_apps_with_updates_available": (1, 2),
|
"levels_apps_with_updates_available": (1, 2),
|
||||||
|
"levels_free_space": (8.0, 4.0),
|
||||||
|
"levels_number_of_files": (100000, 250000),
|
||||||
},
|
},
|
||||||
check_ruleset_name="nextcloud_info",
|
check_ruleset_name="nextcloud_info",
|
||||||
)
|
)
|
||||||
|
@ -32,7 +32,7 @@ def check_nextcloud_users(item, params, section):
|
|||||||
last_login_human = section[item][4]
|
last_login_human = section[item][4]
|
||||||
last_login_since = section[item][5]
|
last_login_since = section[item][5]
|
||||||
free_space = quota_total_bytes - quota_used_bytes
|
free_space = quota_total_bytes - quota_used_bytes
|
||||||
print(free_space)
|
#print(free_space)
|
||||||
levels_quota_used = params["levels_users_quota_used"]
|
levels_quota_used = params["levels_users_quota_used"]
|
||||||
levels_free_space = params["levels_users_free_space"]
|
levels_free_space = params["levels_users_free_space"]
|
||||||
if last_login_human == "never":
|
if last_login_human == "never":
|
||||||
|
@ -30,6 +30,7 @@ OPTIONS:
|
|||||||
-h, --help Show this help message and exit
|
-h, --help Show this help message and exit
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
# set this to true to produce debug output (this clutters the agent output)
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
nc_api_endpoint = "ocs/v2.php/apps/serverinfo/api/v1/info?format=json"
|
nc_api_endpoint = "ocs/v2.php/apps/serverinfo/api/v1/info?format=json"
|
||||||
@ -190,7 +191,8 @@ def getDataUser(url, verify):
|
|||||||
|
|
||||||
def doCmkOutput(data):
|
def doCmkOutput(data):
|
||||||
print("<<<nextcloud_info:sep(59)>>>")
|
print("<<<nextcloud_info:sep(59)>>>")
|
||||||
print(f"NC_Version;{data['ocs']['data']['nextcloud']['system']['version']}")
|
print(f"NC_Version;{data['ocs']['data']['nextcloud']['system']['version']}")
|
||||||
|
print(f"NC_Freespace;{data['ocs']['data']['nextcloud']['system']['freespace']}")
|
||||||
print(f"NC_Status;{data['ocs']['meta']['status']}")
|
print(f"NC_Status;{data['ocs']['meta']['status']}")
|
||||||
print(f"NC_Num_Users;{data['ocs']['data']['nextcloud']['storage']['num_users']}")
|
print(f"NC_Num_Users;{data['ocs']['data']['nextcloud']['storage']['num_users']}")
|
||||||
print(f"NC_Num_Files;{data['ocs']['data']['nextcloud']['storage']['num_files']}")
|
print(f"NC_Num_Files;{data['ocs']['data']['nextcloud']['storage']['num_files']}")
|
||||||
@ -204,6 +206,8 @@ def doCmkOutput(data):
|
|||||||
print(f"NC_Active_Users_Last_5Min;{data['ocs']['data']['activeUsers']['last5minutes']}")
|
print(f"NC_Active_Users_Last_5Min;{data['ocs']['data']['activeUsers']['last5minutes']}")
|
||||||
print(f"NC_Active_Users_Last_1Hour;{data['ocs']['data']['activeUsers']['last1hour']}")
|
print(f"NC_Active_Users_Last_1Hour;{data['ocs']['data']['activeUsers']['last1hour']}")
|
||||||
print(f"NC_Active_Users_Last_1Day;{data['ocs']['data']['activeUsers']['last24hours']}")
|
print(f"NC_Active_Users_Last_1Day;{data['ocs']['data']['activeUsers']['last24hours']}")
|
||||||
|
print(f"NC_Webserver;{data['ocs']['data']['server']['webserver']}")
|
||||||
|
print(f"NC_PHP_Version;{data['ocs']['data']['server']['php']['version']}")
|
||||||
|
|
||||||
print("<<<nextcloud_database:sep(59)>>>")
|
print("<<<nextcloud_database:sep(59)>>>")
|
||||||
print(f"NC_Database_Type;{data['ocs']['data']['server']['database']['type']}")
|
print(f"NC_Database_Type;{data['ocs']['data']['server']['database']['type']}")
|
||||||
@ -261,7 +265,13 @@ def main():
|
|||||||
protocol = "http"
|
protocol = "http"
|
||||||
else:
|
else:
|
||||||
protocol = "https"
|
protocol = "https"
|
||||||
port = opt_port
|
port = opt_port
|
||||||
|
if (protocol == "http" and port == "443"):
|
||||||
|
sys.stderr.write(f"Combining HTTP with port 443 is not supported.\n")
|
||||||
|
sys.exit(1)
|
||||||
|
if (protocol == "https" and port == "80"):
|
||||||
|
sys.stderr.write(f"Combining HTTPS with port 80 is not supported.\n")
|
||||||
|
sys.exit(1)
|
||||||
nc_url = createUrl(nc_api_endpoint, opt_hostname, protocol, port, opt_folder)
|
nc_url = createUrl(nc_api_endpoint, opt_hostname, protocol, port, opt_folder)
|
||||||
nc_data = getData(nc_url, verify)
|
nc_data = getData(nc_url, verify)
|
||||||
doCmkOutput(nc_data)
|
doCmkOutput(nc_data)
|
||||||
|
@ -10,9 +10,9 @@ description:
|
|||||||
You can create this token within the personal settings of an administrative user in Nextcloud.
|
You can create this token within the personal settings of an administrative user in Nextcloud.
|
||||||
Got to security settings and create a new app password, use this for the token.
|
Got to security settings and create a new app password, use this for the token.
|
||||||
The user must not be secured with 2FA.
|
The user must not be secured with 2FA.
|
||||||
Shows several information about a Nextcloud instance (e.g. number of files/storages/users.
|
Shows several information about a Nextcloud instance, e.g. number of files/storages/(active)users, free space on disk.
|
||||||
The check will raise CRIT if the Nextcloud instance is not in "ok" state.
|
The check will raise CRIT if the Nextcloud instance is not in "ok" state.
|
||||||
The check will raise WARN/CRIT if Database OP cache hit rate is below the configurable levels.
|
The check will raise WARN/CRIT if free space on disk is below the configurable levels.
|
||||||
The check will raise WARN/CRIT if the number of installed apps with available updates is above the configurable levels.
|
The check will raise WARN/CRIT if the number of installed apps with available updates is above the configurable levels.
|
||||||
inventory:
|
inventory:
|
||||||
one service is created (with several details)
|
one service is created (with several details)
|
||||||
|
@ -78,7 +78,13 @@ metric_info["nc_active_users_last_1day"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
metric_info["nc_users_free_space"] = {
|
metric_info["nc_users_free_space"] = {
|
||||||
"title": _("Free Space"),
|
"title": _("Free Space of User"),
|
||||||
|
"unit": "bytes",
|
||||||
|
"color": "22/a",
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_info["nc_free_space"] = {
|
||||||
|
"title": _("Free Space on Disk"),
|
||||||
"unit": "bytes",
|
"unit": "bytes",
|
||||||
"color": "22/a",
|
"color": "22/a",
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,34 @@ def _parameter_spec_nextcloud_info():
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
|
("levels_free_space", Tuple(
|
||||||
|
title=_("Nextcloud levels for free disk space overall"),
|
||||||
|
elements=[
|
||||||
|
Float(
|
||||||
|
title=_("Warning below"),
|
||||||
|
default_value=8.0,
|
||||||
|
unit="GBytes",
|
||||||
|
),
|
||||||
|
Float(
|
||||||
|
title=_("Critical below"),
|
||||||
|
default_value=4.0,
|
||||||
|
unit="GBytes",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
("levels_number_of_files", Tuple(
|
||||||
|
title=_("Nextcloud number of files"),
|
||||||
|
elements=[
|
||||||
|
Integer(
|
||||||
|
title=_("Warning at"),
|
||||||
|
default_value=100000,
|
||||||
|
),
|
||||||
|
Integer(
|
||||||
|
title=_("Critical at"),
|
||||||
|
default_value=250000,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
BIN
mkp/Nextcloud-2.2.1.mkp
Executable file
BIN
mkp/Nextcloud-2.2.1.mkp
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user