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 8
8
The Python script is designed to be run as a cronjob on every boot to run in the background.
9
9
The script will gather information:
10
10
11
+ - UUID (Unique for each system to avoid overlapping hostname for multi-network monitoring)
12
+ - Hostname
11
13
- CPU
12
14
- Memory
13
15
- Network
@@ -52,11 +54,12 @@ Example:
52
54
],
53
55
"network_up" : 54 ,
54
56
"network_down" : 4150 ,
55
- "timestamp" : " 2018-10-10 01:41:21"
57
+ "timestamp" : " 2018-10-10T01:41:21+00:00" ,
58
+ "uuid" : 180331603484325
56
59
}
57
60
```
58
61
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.
60
63
61
64
This script can be installed on several machines that report to a central monitoring server.
62
65
Original file line number Diff line number Diff line change @@ -108,8 +108,8 @@ def send_data(data):
108
108
try :
109
109
# endpoint = monitoring server
110
110
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 :" )
113
113
print ("Response:" , response .status_code )
114
114
print ("Headers:" )
115
115
pprint .pprint (response .headers )
@@ -122,7 +122,7 @@ def send_data(data):
122
122
print ("No JSON content" )
123
123
break
124
124
except requests .exceptions .RequestException as e :
125
- print ("\n GET Error:\n " ,e )
125
+ print ("\POST Error:\n " ,e )
126
126
# Sleep 1 minute before retrying
127
127
time .sleep (60 )
128
128
else :
You can’t perform that action at this time.
0 commit comments