From a69f6c1d881eb96f61dc2c5d8b178c4322fc99e6 Mon Sep 17 00:00:00 2001
From: Chris <chris@codingallnight.com>
Date: Wed, 8 Jan 2020 10:20:00 -0800
Subject: [PATCH] Refactor stats.py to enable pushing to multiple checks

---
 stats.py | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/stats.py b/stats.py
index 05965bc..4662ca5 100644
--- a/stats.py
+++ b/stats.py
@@ -42,8 +42,8 @@ def cpu_load():
 def disk_usage(mount='/'):
     disk = cmd_df(mount).split(' ')
     return {
-        'used':  disk[2],
-        'avail': disk[3],
+        'used': disk[2],
+        'available': disk[3],
         'used_percent': disk[4].strip('%')
     }
 
@@ -59,10 +59,10 @@ def mem_usage():
         'swap_free': swap[3]
     }
 
-def push_to_nodeping(data):
+def push_to_nodeping(check_id, token, data):
     params = {
-        'id': NODEPING_ID,
-        'checktoken': NODEPING_TOKEN
+        'id': check_id,
+        'checktoken': token
     }
     if not DEBUG:
         r = requests.post(url=NODEPING_ENDPOINT, json={'data': data}, params=params)
@@ -71,13 +71,13 @@ def push_to_nodeping(data):
             print r.status_code
 
 if __name__ == '__main__':
-    out = {
+    data = {
         'cpu_load': cpu_load(),
         'disk': disk_usage(),
         'memory': mem_usage()
     }
     if DEBUG:
-        print(json.dumps(out, indent=4))
-    push_to_nodeping(out)
+        print(json.dumps(data, indent=4))
+    push_to_nodeping(NODEPING_ID, NODEPING_TOKEN, data)
 
 # vi: set ts=4 sw=4 et ft=python:
\ No newline at end of file
-- 
GitLab