diff --git a/nextcloud-user-quotas/nextcloud_user_quotas.py b/nextcloud-user-quotas/nextcloud_user_quotas.py
--- a/nextcloud-user-quotas/nextcloud_user_quotas.py
+++ b/nextcloud-user-quotas/nextcloud_user_quotas.py
#
@@ -34,8 +35,11 @@ def makeRequest(path, params=False):
#
r = SESSION.get(f"{NEXTCLOUD_PROTO}://{NEXTCLOUD_DOMAIN}/ocs/v2.php/cloud/{path}", params=params, headers=headers)
#
+ if r.status_code == 200:
#
+ return False, r.status_code
#
@@ -43,8 +47,12 @@ def getUserList():
#
''' Get a list of users
#
- resp_json = makeRequest('/users')
#
- return resp_json['ocs']['data']['users']
#
+ resp_json, stat_code = makeRequest('/users')
#
+ return False, stat_code
#
+ return resp_json['ocs']['data']['users'], stat_code
#
@@ -52,16 +60,20 @@ def getUserInfo(user):
#
''' Fetch info from the API for a username
#
- userinfo = makeRequest(f'/users/{user}')
#
+ userinfo, stat_code = makeRequest(f'/users/{user}')
#
+ return False, stat_code
#
if userinfo['ocs']['data']['quota']['quota'] < 0:
#
userinfo['ocs']['data']['quota']['quota'] = 0
#
userinfo['ocs']['data']['quota']['relative'] = 0.00
#
- return userinfo['ocs']['data']['quota']
#
+ return userinfo['ocs']['data']['quota'], stat_code
#
def quota_to_lp(user, quota_obj):
#
''' Take a quota object and output Influx line protocol
#
@@ -70,13 +82,40 @@ def quota_to_lp(user, quota_obj):
#
+def status_to_lp(stat_code, user = False):
#
+ ''' Accept a status code and an optional user and create a line of LP
#
+ s = f"{MEASUREMENT},user={user},hostname={NEXTCLOUD_DOMAIN} api_status_code={stat_code} {TIMESTAMP}"
#
+ s = f"{MEASUREMENT},user=none,hostname={NEXTCLOUD_DOMAIN} api_status_code={stat_code} {TIMESTAMP}"
#
- users = getUserList()
#
+ users, stat_code = getUserList()
#
+ print(status_to_lp(stat_code))
#
+ # API returned an error
#
- quota_obj = getUserInfo(user)
#
+ quota_obj, stat_code = getUserInfo(user)
#
+ print(status_to_lp(stat_code, user))
#
+ # API returned an error
#
+ # Other users might work though
#
lp = quota_to_lp(user, quota_obj)