Hi all. I'm having trouble with short-term drop-outs on my fibre WAN
connection. I created a simple connection monitor in Python (attachment
1). Attachment 2 shows the results over the last 3 days.
1. Do I have a reliable method of monitoring the connection?
2. I have difficulty working out why a down/up pair can have the same
time (to within 1 second) on many occasions.
BT Openreach were involved a few days ago but thought the problem sorted.
Comments gratefully received before I re-open a fault ticket.
Graeme
2020-10-30, 12:32:20:Test started; my pid is 32300
2020-10-30, 15:18:42:down
2020-10-30, 15:20:22:up
2020-10-30, 16:36:06:down
2020-10-30, 16:36:41:up
2020-10-30, 18:59:51:down
2020-10-30, 19:00:06:up
2020-10-30, 20:58:11:down
2020-10-30, 20:58:21:up
2020-10-31, 00:01:27:down
2020-10-31, 00:01:32:up
2020-10-31, 04:00:04:down
2020-10-31, 04:00:19:up
2020-10-31, 04:22:03:down
2020-10-31, 04:22:34:up
2020-10-31, 04:52:57:down
2020-10-31, 04:54:02:up
2020-10-31, 07:19:52:down
2020-10-31, 07:20:52:up
2020-10-31, 13:26:48:down
2020-10-31, 13:28:28:up
2020-10-31, 13:55:15:down
2020-10-31, 13:56:06:up
2020-10-31, 17:46:09:down
2020-10-31, 17:46:19:up
2020-10-31, 18:42:03:down
2020-10-31, 18:42:13:up
2020-10-31, 19:41:50:down
2020-10-31, 19:43:10:up
2020-10-31, 19:52:29:down
2020-10-31, 19:52:39:up
2020-10-31, 20:21:55:down
2020-10-31, 20:22:31:up
2020-10-31, 22:29:29:down
2020-10-31, 22:31:14:up
2020-11-01, 14:31:22:down
2020-11-01, 14:31:22:up
2020-11-01, 14:54:18:down
2020-11-01, 14:55:58:up
2020-11-01, 17:28:29:down
2020-11-01, 17:29:14:up
2020-11-01, 17:30:35:down
2020-11-01, 17:32:15:up
2020-11-01, 18:58:35:down
2020-11-01, 18:58:35:up
2020-11-01, 20:48:11:down
2020-11-01, 20:48:11:up
2020-11-01, 21:30:54:down
2020-11-01, 21:31:44:up
2020-11-01, 21:48:43:down
2020-11-01, 21:48:48:up
2020-11-01, 21:49:58:down
2020-11-01, 21:49:58:up
2020-11-02, 00:24:38:down
2020-11-02, 00:24:38:up
2020-11-02, 00:44:57:down
2020-11-02, 00:44:57:up
2020-11-02, 02:35:56:down
2020-11-02, 02:36:11:up
2020-11-02, 02:41:53:down
2020-11-02, 02:41:53:up
2020-11-02, 03:33:42:down
2020-11-02, 03:33:42:up
2020-11-02, 03:41:45:down
2020-11-02, 03:42:15:up
2020-11-02, 06:50:05:down
2020-11-02, 06:51:30:up
2020-11-02, 08:53:40:down
2020-11-02, 08:53:40:up
2020-11-02, 09:43:58:down
2020-11-02, 09:43:59:up
2020-11-02, 10:02:42:down
2020-11-02, 10:02:42:up
2020-11-02, 11:19:01:down
2020-11-02, 11:19:02:up
2020-11-02, 11:25:24:down
2020-11-02, 11:25:59:up
2020-11-02, 11:40:06:down
2020-11-02, 11:41:36:up
import os
from datetime import datetime
from time import sleep
import shlex
from subprocess import call, PIPE, STDOUT
from twilio.rest import Client
def connected():
def get_return_code_of_simple_cmd(cmd, stderr=STDOUT):
"""Execute a simple external command and return its exit status."""
args = shlex.split(cmd)
return call(args, stdout=PIPE, stderr=stderr)
cmd = "ping -c 1 www.google.com"
return get_return_code_of_simple_cmd(cmd) == 0
def log(status):
f = open('netlog', 'a')
now = datetime.now()
logtime = now.strftime('%Y-%m-%d, %H:%M:%S')
logrecord = logtime + ':' + status + '\n'
f.write(logrecord)
f.close()
def sendsms(text):
return
def main():
pid = os.getpid()
log('Test started; my pid is ' + str(pid))
try:
while True:
while connected():
sleep(10)
# connection lost
log('down')
#send sms
sendsms('Network is down')
while not connected():
sleep(10)
#connection restored
log('up')
#send sms
sendsms('Network is up')
except KeyboardInterrupt:
log('Test stopped')
exit()
if __name__ == "__main__":
main()
--
Next meeting: Online, Jitsi, Tuesday, 2020-11-03 20:00
Check to whom you are replying
Meetings, mailing list, IRC, ... http://dorset.lug.org.uk
New thread, don't hijack: mailto:dorset@mailman.lug.org.uk