Answers for "get centos uptime of a server in datetime format python"

0

get centos uptime of a server in datetime format python

def get_uptime(session=None):
    """
    Get the uptime of system in secs

    :param session: VM session or remote session object, None for host

    :return: uptime of system in float, None on error
    """
    cmd = "cat /proc/uptime"
    if session:
        uptime = session.cmd_output(cmd)
    else:
        try:
            uptime = process.run(cmd, shell=True).stdout_text
        except process.CmdError:
            return None
    return float(uptime.split()[0])
Posted by: Guest on March-02-2021

Code answers related to "get centos uptime of a server in datetime format python"

Python Answers by Framework

Browse Popular Code Answers by Language