Logging output fixes.
This commit is contained in:
parent
7179412d99
commit
5f8432ccdc
1 changed files with 5 additions and 4 deletions
9
uplink
9
uplink
|
|
@ -110,7 +110,7 @@ def get_data(config, inc):
|
||||||
password=config["database_password"],
|
password=config["database_password"],
|
||||||
database=config["database"])
|
database=config["database"])
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error("ERROR: Database connection failed!" + str(err))
|
logger.error(RED + "ERROR: Database connection failed!" + str(err) + END)
|
||||||
# see https://stackoverflow.com/questions/1489669/how-to-exit-the-entire-application-from-a-python-thread
|
# see https://stackoverflow.com/questions/1489669/how-to-exit-the-entire-application-from-a-python-thread
|
||||||
# maybe the following is better. need to evaluate:
|
# maybe the following is better. need to evaluate:
|
||||||
# thread.interrupt_main()
|
# thread.interrupt_main()
|
||||||
|
|
@ -124,7 +124,7 @@ def get_data(config, inc):
|
||||||
try:
|
try:
|
||||||
fc = FritzStatus(address=config["uplinks"][inc]["ip"], password=config["uplinks"][inc]["password"])
|
fc = FritzStatus(address=config["uplinks"][inc]["ip"], password=config["uplinks"][inc]["password"])
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error("ERROR: " + str(err) + " on device with ip:" + config["uplinks"][inc]["ip"])
|
logger.error(RED + "ERROR: " + str(err) + " on device with ip:" + config["uplinks"][inc]["ip"] + END)
|
||||||
sql = 'INSERT INTO log (timestamp, date, time, internal_ip, is_linked, is_connected, provider, message, ' \
|
sql = 'INSERT INTO log (timestamp, date, time, internal_ip, is_linked, is_connected, provider, message, ' \
|
||||||
'source_host) VALUES (\"' + str(timestamp) + '\",\"' + str(d) + '\",\"' + str(t) + '\",\"' + \
|
'source_host) VALUES (\"' + str(timestamp) + '\",\"' + str(d) + '\",\"' + str(t) + '\",\"' + \
|
||||||
str(config["uplinks"][inc]["ip"]) + '\",\"' + "0" + '\",\"' + "0" + '\",\"' + \
|
str(config["uplinks"][inc]["ip"]) + '\",\"' + "0" + '\",\"' + "0" + '\",\"' + \
|
||||||
|
|
@ -138,10 +138,11 @@ def get_data(config, inc):
|
||||||
|
|
||||||
if fc.is_connected:
|
if fc.is_connected:
|
||||||
status = "UP"
|
status = "UP"
|
||||||
|
logger.info(GREEN + config["uplinks"][inc]["provider"] + " " + status + END)
|
||||||
else:
|
else:
|
||||||
status = "DOWN"
|
status = "DOWN"
|
||||||
|
logger.info(RED + config["uplinks"][inc]["provider"] + " " + status + END)
|
||||||
|
|
||||||
logger.info(config["uplinks"][inc]["provider"] + " " + status)
|
|
||||||
sql = 'INSERT INTO log (timestamp, date, time, uptime, internal_ip, external_ip, external_ipv6, is_linked, ' \
|
sql = 'INSERT INTO log (timestamp, date, time, uptime, internal_ip, external_ip, external_ipv6, is_linked, ' \
|
||||||
'is_connected, str_transmission_rate_up, str_transmission_rate_down, str_max_bit_rate_up, ' \
|
'is_connected, str_transmission_rate_up, str_transmission_rate_down, str_max_bit_rate_up, ' \
|
||||||
'str_max_bit_rate_down, str_max_linked_bit_rate_up, str_max_linked_bit_rate_down, modelname, ' \
|
'str_max_bit_rate_down, str_max_linked_bit_rate_up, str_max_linked_bit_rate_down, modelname, ' \
|
||||||
|
|
@ -203,5 +204,5 @@ if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
run(_config)
|
run(_config)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.info("uplink terminated!")
|
logger.info(RED + "uplink terminated!" + END)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue