Skip to content

Instantly share code, notes, and snippets.

@kylegato
Created July 11, 2013 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylegato/aee8f1f93887d226474a to your computer and use it in GitHub Desktop.
Save kylegato/aee8f1f93887d226474a to your computer and use it in GitHub Desktop.
def loadavg():
'''
Return the load averages for this minion
CLI Example::
salt '*' status.loadavg
'''
procf = '/proc/loadavg'
if not os.path.isfile(procf):
comps = "%.2f %.2f %.2f" % os.getloadavg()
else:
comps = salt.utils.fopen(procf, 'r').read().strip()
load_avg = comps.split()
return {'1-min': _number(load_avg[0]),
'5-min': _number(load_avg[1]),
'15-min': _number(load_avg[2])}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment