Advertisement
Guest User

Untitled

a guest
Jan 1st, 2021
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. from icmplib import ping, multiping, traceroute, resolve, Host, Hop
  4. from datetime import datetime
  5. from influxdb_client import InfluxDBClient, Point, WritePrecision
  6. from influxdb_client.client.write_api import SYNCHRONOUS
  7.  
  8. token = "YOUR_TOKEN_HERE_INFLUXDB"
  9. org = "apollo"
  10. bucket = "uptime"
  11. client = InfluxDBClient(url="http://192.168.1.52:8086", token=token)
  12. write_api = client.write_api(write_options=SYNCHRONOUS)
  13.  
  14. while True:
  15.     for x in range(256):
  16.         response = ping('192.168.1.'+str(x),count=1,privileged=True,timeout=0.05)
  17.         if response.is_alive==True:
  18.             point = Point("uptime")\
  19.                 .tag("IP", '192.168.1.'+str(x))\
  20.                 .field("Avg_RTT", response.avg_rtt)\
  21.                 .time(datetime.utcnow(), WritePrecision.NS)
  22.             write_api.write(bucket, org, point)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement