def _find_utmp():
    result = {}
    # These are the likely locations for the file on Ubuntu
    for utmp in '/var/run/utmp', '/run/utmp':
        try:
            result[os.stat(utmp).st_mtime] = utmp
        except Exception:
            pass
    return result[sorted(result).pop()]
Figure out which utmp file to use when determining runlevel.
dataset/ETHPy150Open saltstack/salt/salt/modules/upstart.py/_find_utmp