MKP 2.5.1, added version infos for apps with available updates

This commit is contained in:
mellis
2024-01-12 16:38:48 +01:00
parent 05415a8d1d
commit a2a409a405
9 changed files with 65 additions and 10 deletions

View File

@@ -136,10 +136,10 @@ def getSession(username, secret):
return session
def getData(session, url, verify):
data = {}
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
cookies = {"nc_sameSiteCookiestrict": "true"}
response = session.get(url, headers=headers, cookies=cookies, verify=verify)
response = session.get(url, headers=headers, verify=verify)
status = response.status_code
if (status == 200):
jsdata = response.text
@@ -157,8 +157,7 @@ def getDataAllUsers(session, url, verify):
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
headers["OCS-APIRequest"] = "true"
cookies = {"nc_sameSiteCookiestrict": "true"}
response = session.get(url, headers=headers, cookies=cookies, verify=verify)
response = session.get(url, headers=headers, verify=verify)
status = response.status_code
if (status == 200):
jsdata = response.text
@@ -172,8 +171,7 @@ def getDataUser(session, url, verify):
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
headers["OCS-APIRequest"] = "true"
cookies = {"nc_sameSiteCookiestrict": "true"}
response = session.get(url, headers=headers, cookies=cookies, verify=verify)
response = session.get(url, headers=headers, verify=verify)
status = response.status_code
if (status == 200):
jsdata = response.text
@@ -184,6 +182,8 @@ def getDataUser(session, url, verify):
sys.exit(1)
def doCmkOutput(data):
apps_with_updates_available = {}
str_apps_with_updates_available = ""
print("<<<nextcloud_info:sep(59)>>>")
print(f"NC_Version;{data['ocs']['data']['nextcloud']['system']['version']}")
print(f"NC_Freespace;{data['ocs']['data']['nextcloud']['system']['freespace']}")
@@ -205,6 +205,11 @@ def doCmkOutput(data):
try:
print(f"NC_Num_Apps_Installed;{data['ocs']['data']['nextcloud']['system']['apps']['num_installed']}")
print(f"NC_Num_Apps_Updates_Available;{data['ocs']['data']['nextcloud']['system']['apps']['num_updates_available']}")
apps_with_updates_available = data['ocs']['data']['nextcloud']['system']['apps']['app_updates']
if apps_with_updates_available:
for app, version in apps_with_updates_available.items():
str_apps_with_updates_available = str_apps_with_updates_available + app + "/" + version + " "
print(f"NC_Apps_With_Updates_Available;{str_apps_with_updates_available}")
except KeyError:
pass
print(f"NC_Active_Users_Last_5Min;{data['ocs']['data']['activeUsers']['last5minutes']}")