Permalink
Browse files

ruby 1.9 friednly + minor cleanup

  • Loading branch information...
1 parent ae84aff commit e002c72521a029ebdbbaffb4e6ff7b7568db3e8e Andre Lewis committed Mar 26, 2010
Showing with 5 additions and 10 deletions.
  1. +2 −2 mpstat/README
  2. +3 −8 mpstat/mpstat.rb
View
@@ -1,4 +1,4 @@
-Improved IO Statistics Plugin
+MPSTAT Plugin
=================================
Created by [Yaroslav Lazor](http://github.com/yaroslavlazor)
@@ -8,7 +8,7 @@ Dependencies
------------
Requires the mpstat command, usually provided by the sysstat package.
-Compatibility
+Compatibility
-------------
Works on Linux and OSX.
View
@@ -6,7 +6,7 @@ class MPstat < Scout::Plugin
notes: The command used to display MP statistics
default: mpstat
interval:
- name: iostat Interval
+ name: mpstat Interval
notes: Report current usage as the average over this many seconds.
default: 5
EOS
@@ -18,9 +18,7 @@ def build_report
[:user, :nice, :sys, :iowait, :irq, :soft, :steal, :idle, :intrps].each{|k| result[k]=values[k]}
report(result)
rescue Exception => e
- error "Couldn't parse output. Make sure you have iostat installed. #{e}"
- # log.error e
- # log.error "Output: #{output}"
+ error "Couldn't parse output. Make sure you have mpstat installed. #{e}"
end
private
@@ -29,7 +27,6 @@ def stat_output()
command = option('command') || 'mpstat'
interval = option('interval') || 5
stat_command = "#{command} #{interval} 2"
- # log.info "running iostat_output for #{iostat_command}"
`#{stat_command}`
end
@@ -39,10 +36,8 @@ def values(output)
# 04:38:34 PM all 6.69 0.02 1.30 0.31 0.02 0.13 0.00 91.53 349.37
# take the format fields
- # log.info "extracting output format"
- format=output.grep(/CPU/).last.gsub(/\//,'p').gsub(/(%|:)/,'').downcase.split
+ format=output.split("\n").grep(/CPU/).last.gsub(/\//,'p').gsub(/(%|:)/,'').downcase.split
- # log.info "extracting output average values"
# take all the stat fields
raw_stats=output.split("\n").grep(/[0-9]+\.[0-9]+$/).last.split

0 comments on commit e002c72

Please sign in to comment.