mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix status.uptime for Solaris 9, 10 and 11.
This commit is contained in:
parent
c30656814d
commit
c11940d14c
1 changed files with 11 additions and 6 deletions
|
@ -143,13 +143,18 @@ def uptime():
|
|||
|
||||
salt '*' status.uptime
|
||||
'''
|
||||
ut_path = "/proc/uptime"
|
||||
if not os.path.exists(ut_path):
|
||||
raise CommandExecutionError("File {ut_path} was not found.".format(ut_path=ut_path))
|
||||
ut_ret = {'seconds': 0}
|
||||
if salt.utils.is_linux():
|
||||
ut_path = "/proc/uptime"
|
||||
if not os.path.exists(ut_path):
|
||||
raise CommandExecutionError("File {ut_path} was not found.".format(ut_path=ut_path))
|
||||
ut_ret['seconds'] = int(float(open(ut_path).read().strip().split()[0]))
|
||||
elif salt.utils.is_sunos():
|
||||
cmd = "kstat -p unix:0:system_misc:boot_time | nawk '{printf \"%d\\n\", srand()-$2}'"
|
||||
ut_ret['seconds'] = int(__salt__['cmd.shell'](cmd, output_loglevel='trace').strip() or 0)
|
||||
else:
|
||||
raise CommandExecutionError('This platform is not supported')
|
||||
|
||||
ut_ret = {
|
||||
'seconds': int(float(open(ut_path).read().strip().split()[0]))
|
||||
}
|
||||
|
||||
utc_time = datetime.datetime.utcfromtimestamp(time.time() - ut_ret['seconds'])
|
||||
ut_ret['since_iso'] = utc_time.isoformat()
|
||||
|
|
Loading…
Add table
Reference in a new issue