Compare commits

...

9 Commits

Author SHA1 Message Date
f1777d2d19 Merge pull request 'work' (#1) from work into main
Reviewed-on: #1
2024-11-26 12:59:21 -06:00
80e4c31b0a ping changes
All checks were successful
/ Plan (push) Successful in 48s
/ Plan (pull_request) Successful in 10s
/ Deploy (pull_request) Successful in 12s
2024-11-26 12:56:03 -06:00
619a56ebc1 more debugging
All checks were successful
/ Plan (push) Successful in 45s
2024-11-26 12:54:17 -06:00
42b91cbf72 install ping in container
All checks were successful
/ Plan (push) Successful in 3m21s
2024-11-26 12:43:45 -06:00
93e091f1d2 ping add
All checks were successful
/ Plan (push) Successful in 56s
2024-11-26 12:41:37 -06:00
92e0ab385a debugging
All checks were successful
/ Plan (push) Successful in 1m0s
2024-11-26 12:37:16 -06:00
d61365ec99 additional debugging
All checks were successful
/ Plan (push) Successful in 50s
2024-11-26 12:35:16 -06:00
5aabd3e7b1 fix shebang
All checks were successful
/ Plan (push) Successful in 1m5s
2024-11-26 12:31:33 -06:00
11455452d1 force run
All checks were successful
/ Plan (push) Successful in 1m5s
2024-11-26 12:28:20 -06:00
3 changed files with 21 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
FROM debian:bullseye-slim
#
RUN apt update && apt install python3 python3-pip -y
RUN apt update && apt install python3 python3-pip iputils-ping -y
COPY logpingresult.py /usr/local/bin/
COPY requirements.txt /
COPY init.sh /

View File

@@ -7,4 +7,5 @@ services:
- INFLUX_USER=${INFLUX_USER}
- INFLUX_PASSWORD=${INFLUX_PASSWORD}
- INFLUX_URI=${INFLUX_URI}
- PING_HOSTS="8.8.8.8,10.0.2.1,24.220.0.10,10.2.0.1,192.168.1.25"
- PING_HOSTS="8.8.8.8,10.0.2.1,24.220.0.10,10.2.0.1,192.168.1.25"
#

View File

@@ -1,4 +1,4 @@
#/usr/bin/python3
#!/usr/bin/python3
import os
import subprocess as sp
import requests
@@ -19,13 +19,20 @@ infdbpass = os.environ["INFLUX_PASSWORD"]
influxuri = os.environ["INFLUX_URI"]
pingaddresses = os.environ["PING_HOSTS"].split(",")
while(True):
for ip in pingaddresses:
response = sp.getstatusoutput(f"ping -c 1 {ip}")
if(response[0]!=0):
time=2000
else:
myresp = response[1].split("\n")[1].split(' ')[6].split('=')[1]
result = addinfluxrecord(ip,myresp)
print(result)
time.sleep(5)
if len(pingaddresses) > 0:
print(pingaddresses)
for ip in pingaddresses:
print(ip)
response = sp.getstatusoutput(f"ping -c 1 {ip}")
print(response)
if(response[0]!=0):
time=2000
else:
myresp = response[1].split("\n")[1].split(' ')[6].split('=')[1]
result = addinfluxrecord(ip,myresp)
print(result)
time.sleep(5)
else:
print("No Hosts Defined")
exit