aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornico <nico@magicbroccoli.de>2018-09-04 15:10:28 +0200
committernico <nico@magicbroccoli.de>2018-09-04 15:10:28 +0200
commitf7a99afdca61f17ae30c8a73194498c7f6281ec7 (patch)
tree6ca61236ce0da4042d3a564a699295d75c8a11c5
parentc9e2bc743397229a930c2647d5b59034f9be08c0 (diff)
removed hardcoded variables
+ added env variable support to remove hardcoded elements from plugin code * updated readme to represent thse changes
-rw-r--r--README.md10
-rw-r--r--nextcloud_shares5
-rw-r--r--nextcloud_users5
3 files changed, 12 insertions, 8 deletions
diff --git a/README.md b/README.md
index 500dd75..45bf39c 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,14 @@
Some basic Munin Plugins gathering information from the NextCloud external API.
## install
-To use these Plugins one has to add his specific URL and credential to the script.
+To use these plugins properly some configuration parameters need to be added to the plugin-config `/etc/munin/plugin-config.d/munin-node`.
```
-URL = 'https://URL.TO.YOUR.NEXTCLOUD.tld/ocs/v2.php/apps/serverinfo/api/v1/info'
-auth = ('username', 'password or logintoken')
+[nextcloud_*]
+url = https://URL.TO.YOUR.NEXTCLOUD.tld/ocs/v2.php/apps/serverinfo/api/v1/info
+username = username
+password = password or logintoken
```
-If these are correct the script needs to be placed in the munin directory eg. `/etc/munin/plugins/`
+After that the script needs to be placed in the munin plugin directory eg. `/etc/munin/plugins/`
The munin-node needs to be restarted to facilitate the new plugins.
`systemctl restart munin-node`
diff --git a/nextcloud_shares b/nextcloud_shares
index b2e858e..cf75234 100644
--- a/nextcloud_shares
+++ b/nextcloud_shares
@@ -3,9 +3,10 @@
import re
import requests
import sys
+import os
-URL = 'https://URL.TO.YOUR.NEXTCLOUD.tld/ocs/v2.php/apps/serverinfo/api/v1/info'
-auth = ('username', 'password or logintoken')
+URL = os.environ['url']
+auth = (os.environ['username'], os.environ['password'])
class NextcloudShares:
diff --git a/nextcloud_users b/nextcloud_users
index fce9c73..e311a12 100644
--- a/nextcloud_users
+++ b/nextcloud_users
@@ -2,9 +2,10 @@
# -*- coding: utf-8 -*-
import requests
import sys
+import os
-URL = 'https://URL.TO.YOUR.NEXTCLOUD.tld/ocs/v2.php/apps/serverinfo/api/v1/info'
-auth = ('username', 'password or logintoken')
+URL = os.environ['url']
+auth = (os.environ['username'], os.environ['password'])
class NextcloudUsers: