<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hostname(hn, ft, si):
 """Check hostname, facter and systemid to get the fqdn, hostname and domain. Prefer hostname to facter and systemid. Returns: insights.combiners.hostname.Hostname: A named tuple with `fqdn`, `hostname` and `domain` components. Raises: Exception: If no hostname can be found in any of the three parsers. """


    if not hn or not hn.fqdn:
        hn = ft

    if hn and hn.fqdn:
        fqdn = hn.fqdn
        hostname = hn.hostname if hn.hostname else fqdn.split(".")[0]
        domain = hn.domain if hn.domain else ".".join(fqdn.split(".")[1:])
        return Hostname(fqdn, hostname, domain)
    else:
        fqdn = si.get("profile_name") if si else None
        if fqdn:
            hostname = fqdn.split(".")[0]
            domain = ".".join(fqdn.split(".")[1:])
            return Hostname(fqdn, hostname, domain)

    raise Exception("Unable to get hostname.")