1def get_uptime(session=None):
2 """
3 Get the uptime of system in secs
4
5 :param session: VM session or remote session object, None for host
6
7 :return: uptime of system in float, None on error
8 """
9 cmd = "cat /proc/uptime"
10 if session:
11 uptime = session.cmd_output(cmd)
12 else:
13 try:
14 uptime = process.run(cmd, shell=True).stdout_text
15 except process.CmdError:
16 return None
17 return float(uptime.split()[0])