From fe135708deaf65c7da483250cfa9b855a08fd33d Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Thu, 26 Aug 2021 16:32:11 -0700 Subject: [PATCH] lf_check.py: tests for fully qualified host name to see if it has a domain name, otherwise use IP address Browsers can do weird things like transform $host to "www.${host}.com" if they don't detect a domain. Signed-off-by: Jed Reynolds --- py-scripts/tools/lf_check.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/py-scripts/tools/lf_check.py b/py-scripts/tools/lf_check.py index f985b688..70047664 100755 --- a/py-scripts/tools/lf_check.py +++ b/py-scripts/tools/lf_check.py @@ -317,8 +317,14 @@ class lf_check(): # Mail # command to check if mail running : systemctl status postfix # command = 'echo "$HOSTNAME mail system works!" | mail -s "Test: $HOSTNAME $(date)" chuck.rekiere@candelatech.com' - hostname = socket.gethostname() + hostname = socket.getfqdn() ip = socket.gethostbyname(hostname) + + # a hostname lacking dots by definition lacks a domain name + # this is not useful for hyperlinks outside the known domain, so an IP address should be preferred + if hostname.find('.') < 1: + hostname = ip + message_txt ="" if (self.email_txt != ""): message_txt = """{email_txt} lanforge target {lf_mgr_ip}