-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping-influx.py
More file actions
44 lines (34 loc) · 768 Bytes
/
ping-influx.py
File metadata and controls
44 lines (34 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
script to test internet connectivity and log it
to influxdb
"""
from influxdb import InfluxDBClient
from pythonping import ping
# iDB_props = {
# "database": "mydb",
# "port": "1157",
# "host": "192.168.1.2"
# }
pingDest = "google.com" #ping doesn't like http://
pingResult = ""
client = InfluxDBClient(database="mydb",
port=1157,
host="192.168.1.2")
while
response = ping(pingDest, count=1)
if response._responses[0].success:
pingResult = True
else:
pingResult = False
datum = [
{
"measurement": "connectivity",
"tags": {
"site": pingDest,
},
"fields": {
"value": str(pingResult)
}
}
]
client.write_points(datum)