Check uptime and facts to get the uptime information.

    Prefer uptime to facts.

    Returns:
        insights.combiners.uptime.Uptime: A named tuple with `currtime`,
        `updays`, `uphhmm`, `users`, `loadavg` and `uptime` components.

    Raises:
        Exception: If no data is available from both of the parsers.

def uptime(ut, facter):
    """Check uptime and facts to get the uptime information.

    Prefer uptime to facts.

    Returns:
        insights.combiners.uptime.Uptime: A named tuple with `currtime`,
        `updays`, `uphhmm`, `users`, `loadavg` and `uptime` components.

    Raises:
        Exception: If no data is available from both of the parsers.
    """

    ut = ut
    if ut and ut.loadavg:
        return Uptime(ut.currtime, ut.updays, ut.uphhmm,
                      ut.users, ut.loadavg, ut.uptime)
    ft = facter
    if ft and hasattr(ft, 'uptime_seconds'):
        import datetime
        secs = int(ft.uptime_seconds)
        up_dd = secs // (3600 * 24)
        up_hh = (secs % (3600 * 24)) // 3600
        up_mm = (secs % 3600) // 60
        updays = str(up_dd) if up_dd > 0 else ''
        uphhmm = '%02d:%02d' % (up_hh, up_mm)
        up_time = datetime.timedelta(seconds=secs)
        return Uptime(None, updays, uphhmm, None, None, up_time)

    raise Exception("Unable to get uptime information.")