Skip to content

Instantly share code, notes, and snippets.

@pbrandiezs
Created July 10, 2018 20:34
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 pbrandiezs/98188c132e806f7f4c434b291d386ab7 to your computer and use it in GitHub Desktop.
Save pbrandiezs/98188c132e806f7f4c434b291d386ab7 to your computer and use it in GitHub Desktop.
Ruby example using %Q to parse iowait
def getIOWait
command_to_run = %Q[iostat 15 2 | awk 'BEGIN{RS=ORS="\\n\\n";FS=OFS="\\n"}/avg-cpu:/' | tail -2 | head -1 | awk {'print $4'}]
result = `#{command_to_run}`
# result = '20.0'
result.to_f
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment