From e2fd9741ea89362f61312ecd90d996a8622e061e Mon Sep 17 00:00:00 2001 From: D Delmar Davis Date: Wed, 16 Aug 2023 18:12:36 -0700 Subject: Notes --- thumper.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'thumper.py') diff --git a/thumper.py b/thumper.py index 7dd9af5..5bece66 100755 --- a/thumper.py +++ b/thumper.py @@ -1,25 +1,48 @@ #!/usr/bin/python +#------------------------------------------------------------------- thumper.py +# Check the backyard temperature sensors +# +# (C) D Delmar Davis 2023 +# +# Note: POC lots of hard coded foo here.... +# it takes about a minute and 20 seconds to come back so.. +# bunnyfoofoo's crontab should look like this +# */2 * * * * /usr/local/bin/thumper.py import socket import subprocess +#---------------------------------------------------------------- isExporting() +# Check to see if node exporter is running on thumper. +# def isExporting(): try: # connect to the host -- tells us if the host is actually # reachable sock = socket.create_connection(("thumper", 9100),timeout=3) if sock is not None: - print('dew\'s dat wabbit') + print('Found da wabbit') sock.close return True - except OSError as e: + except OSError: pass return False + +#---------------------------------------------------------------- kickThumper() +# Make sure the poe port is on an powercycle that port +# def kickThumper(): - ret = subprocess.call(["ssh", "root@henri-le-renne", "swctrl poe set auto id 6"]); - ret = subprocess.call(["ssh", "root@henri-le-renne", "swctrl poe restart id 6"]); + ret = subprocess.call(["ssh", + "root@henri-le-renne", + "swctrl poe set auto id 6"]); + ret = subprocess.call(["ssh", + "root@henri-le-renne", + "swctrl poe restart id 6"]); +#------------------------------------------------------------------- __main__() +# Check to see if thumper is exporting and if not reset. +# if __name__ == '__main__': if (not isExporting()) : print("Thumpers not talking. Going to kick it") -- cgit v1.2.3