mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #37031 from isbm/isbm-solaris-status-fix-dev
Prevent fallback to uptime on status.uptime for Solaris 9, 10 and 11
This commit is contained in:
commit
60ec60ddfd
1 changed files with 10 additions and 11 deletions
|
@ -148,18 +148,17 @@ def uptime():
|
|||
|
||||
salt '*' status.uptime
|
||||
'''
|
||||
ut_path = "/proc/uptime"
|
||||
if not os.path.exists(ut_path):
|
||||
if __grains__['kernel'] == 'Linux':
|
||||
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))
|
||||
elif not salt.utils.which('uptime'):
|
||||
raise CommandExecutionError("No uptime binary available.")
|
||||
else:
|
||||
return __salt__['cmd.run']('uptime')
|
||||
|
||||
ut_ret = {
|
||||
'seconds': int(float(open(ut_path).read().strip().split()[0]))
|
||||
}
|
||||
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:
|
||||
return __salt__['cmd.run']('uptime')
|
||||
|
||||
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