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 <jed@candelatech.com>
This commit is contained in:
Jed Reynolds
2021-08-26 16:32:11 -07:00
parent 8e273b8b37
commit fe135708de

View File

@@ -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}