aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornico <nico@magicbroccoli.de>2018-11-13 16:48:53 +0100
committernico <nico@magicbroccoli.de>2018-11-13 16:48:53 +0100
commit1e53dfb3ee5de39baff1451c2b076b853b203189 (patch)
tree97cc7021ee637fd8f793a3db440dbf6223f324d6
parent83e40d85436444c0caedd9443dc444363f842d49 (diff)
optimizations
- removed unnecessary list comprehension * automated whitespace/ newline correction
-rwxr-xr-xnextcloud_files.py13
-rwxr-xr-xnextcloud_storage.py2
2 files changed, 6 insertions, 9 deletions
diff --git a/nextcloud_files.py b/nextcloud_files.py
index 0583923..226a94f 100755
--- a/nextcloud_files.py
+++ b/nextcloud_files.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-# Plugin to monitor the amount storage to and from the specified nextcloud instance
+# Plugin to monitor the total number of files on the specified nextcloud instance
#
# Parameters understood:
# config (required)
@@ -39,12 +39,9 @@ class NextcloudStorage:
'nextcloud_storage': [],
}
- # storage
- storage = api_response['ocs']['data']['nextcloud']['storage']
-
- # append for every key in storage the key and the value if the key starts with "num"
- [data['nextcloud_storage'].append(str(key) + ".value " + str(storage[key]))
- for key in storage if key.startswith('num_files')]
+ # append the total number of files present
+ num_files = api_response['ocs']['data']['nextcloud']['storage']['num_files']
+ data['nextcloud_storage'].append('num_files.value %s' % num_files)
return data
@@ -93,6 +90,6 @@ class NextcloudStorage:
else:
self.run()
+
if __name__ == "__main__":
NextcloudStorage().main()
-
diff --git a/nextcloud_storage.py b/nextcloud_storage.py
index 57204d1..ed6c74e 100755
--- a/nextcloud_storage.py
+++ b/nextcloud_storage.py
@@ -102,6 +102,6 @@ class NextcloudStorage:
else:
self.run()
+
if __name__ == "__main__":
NextcloudStorage().main()
-