aboutsummaryrefslogtreecommitdiffstats
path: root/nextcloud_users
diff options
context:
space:
mode:
Diffstat (limited to 'nextcloud_users')
-rwxr-xr-xnextcloud_users15
1 files changed, 8 insertions, 7 deletions
diff --git a/nextcloud_users b/nextcloud_users
index eac5ae6..2230b84 100755
--- a/nextcloud_users
+++ b/nextcloud_users
@@ -1,12 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-#
+
# Plugin to monitor the amount of users sucessfully logging in to the specified nextcloud instance
#
# Parameters understood:
# config (required)
# autoconf (optional - used by munin-config)
-#
+
# Magic markers - optional - used by installation scripts and
# munin-config:
#
@@ -45,12 +45,13 @@ class NextcloudUsers:
auth = (os.environ['username'], os.environ['password'])
# init requests session with specific header and credentials
- s = requests.Session()
- s.auth = auth
- s.headers.update({'Accept': 'application/json'})
+ with requests.Session() as s:
+ s.auth = auth
+ s.headers.update({'Accept': 'application/json'})
+ s.stream = False
- # request data from api
- r = s.get(URL)
+ # request data from api
+ r = s.get(URL)
# if status code is successful close connection and continue
if r.status_code == 200: