From b4f05f7578dbadf13a3a38437c535d96ac7e9585 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Tue, 31 Aug 2021 16:19:39 +0200 Subject: [PATCH] Added apache plugin --- pastafaristats/send_info_daemon.py | 2 ++ pastafaristats/utils/apache.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 pastafaristats/utils/apache.py diff --git a/pastafaristats/send_info_daemon.py b/pastafaristats/send_info_daemon.py index ca147be..e1dad49 100644 --- a/pastafaristats/send_info_daemon.py +++ b/pastafaristats/send_info_daemon.py @@ -190,6 +190,8 @@ def start(): #Wait seconds to + print('Syncing time collection...') + while True: sleep(2) diff --git a/pastafaristats/utils/apache.py b/pastafaristats/utils/apache.py new file mode 100644 index 0000000..e82f441 --- /dev/null +++ b/pastafaristats/utils/apache.py @@ -0,0 +1,30 @@ +import requests + +def stat(obj_stats): + + #new_obj_stats['apache_data']={'status': 1} + + url='http://127.0.0.1/server-status?auto' + + try: + + r=requests.get(url) + + data=r.text.split("\n") + + final_data={v.split(':')[0].strip():v.split(':')[1].strip() for v in data if v.find(':')!=-1} + + final_data['status']=1 + + obj_stats['apache_data']=final_data + + except: + obj_stats['apache_data']['status']=0 + + return obj_stats + +if __name__=='__main__': + + print(stat({})) + +