File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 88The Python script is designed to be run as a cronjob on every boot to run in the background.
99The script will gather information:
1010
11+ - UUID (Unique for each system to avoid overlapping hostname for multi-network monitoring)
12+ - Hostname
1113- CPU
1214- Memory
1315- Network
@@ -52,11 +54,12 @@ Example:
5254 ],
5355 "network_up" : 54 ,
5456 "network_down" : 4150 ,
55- "timestamp" : " 2018-10-10 01:41:21"
57+ "timestamp" : " 2018-10-10T01:41:21+00:00" ,
58+ "uuid" : 180331603484325
5659}
5760```
5861
59- The script includes a function to send JSON to a remote server.
62+ The script includes a function to POST JSON to a remote server.
6063
6164This script can be installed on several machines that report to a central monitoring server.
6265
Original file line number Diff line number Diff line change @@ -108,8 +108,8 @@ def send_data(data):
108108 try :
109109 # endpoint = monitoring server
110110 endpoint = "http://monitor.localhost.local/api/"
111- response = requests .get (url = endpoint , params = {"data" : data })
112- print ("\n GET :" )
111+ response = requests .post (url = endpoint , params = {"data" : data })
112+ print ("\n POST :" )
113113 print ("Response:" , response .status_code )
114114 print ("Headers:" )
115115 pprint .pprint (response .headers )
@@ -122,7 +122,7 @@ def send_data(data):
122122 print ("No JSON content" )
123123 break
124124 except requests .exceptions .RequestException as e :
125- print ("\n GET Error:\n " ,e )
125+ print ("\POST Error:\n " ,e )
126126 # Sleep 1 minute before retrying
127127 time .sleep (60 )
128128 else :
You can’t perform that action at this time.
0 commit comments