Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix overflowing text from ps by swapping args for comm #17

Merged
merged 1 commit into from
Nov 25, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bin/riemann-health
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Riemann::Tools::Health
total = used + i2-i1
fraction = used.to_f / total

report_pct :cpu, fraction, "user+nice+sytem\n\n#{`ps -eo pcpu,pid,args | sort -nrb -k1 | head -10`.chomp}"
report_pct :cpu, fraction, "user+nice+sytem\n\n#{`ps -eo pcpu,pid,comm | sort -nrb -k1 | head -10`.chomp}"
end

@old_cpu = [u2, n2, s2, i2]
Expand Down Expand Up @@ -129,7 +129,7 @@ class Riemann::Tools::Health
total = m['MemTotal'].to_i
fraction = 1 - (free.to_f / total)

report_pct :memory, fraction, "used\n\n#{`ps -eo pmem,pid,args | sort -nrb -k1 | head -10`.chomp}"
report_pct :memory, fraction, "used\n\n#{`ps -eo pmem,pid,comm | sort -nrb -k1 | head -10`.chomp}"
end

def freebsd_cpu
Expand All @@ -142,7 +142,7 @@ class Riemann::Tools::Health
total = used + i2-i1
fraction = used.to_f / total

report_pct :cpu, fraction, "user+nice+sytem+interrupt\n\n#{`ps -axo pcpu,pid,args | sort -nrb -k1 | head -10`.chomp}"
report_pct :cpu, fraction, "user+nice+sytem+interrupt\n\n#{`ps -axo pcpu,pid,comm | sort -nrb -k1 | head -10`.chomp}"
end

@old_cpu = [u2, n2, s2, t2, i2]
Expand All @@ -164,7 +164,7 @@ class Riemann::Tools::Health
meminfo = `sysctl -n vm.stats.vm.v_page_count vm.stats.vm.v_wire_count vm.stats.vm.v_active_count 2>/dev/null`.chomp.split
fraction = (meminfo[1].to_f + meminfo[2].to_f) / meminfo[0].to_f

report_pct :memory, fraction, "used\n\n#{`ps -axo pmem,pid,args | sort -nrb -k1 | head -10`.chomp}"
report_pct :memory, fraction, "used\n\n#{`ps -axo pmem,pid,comm | sort -nrb -k1 | head -10`.chomp}"
end

def darwin_top
Expand Down Expand Up @@ -192,7 +192,7 @@ class Riemann::Tools::Health
alert 'cpu', :unknown, nil, "unable to get CPU stats from top"
return false
end
report_pct :cpu, @topdata[:cpu], "usage\n\n#{`ps -eo pcpu,pid,args | sort -nrb -k1 | head -10`.chomp}"
report_pct :cpu, @topdata[:cpu], "usage\n\n#{`ps -eo pcpu,pid,comm | sort -nrb -k1 | head -10`.chomp}"
end

def darwin_load
Expand All @@ -217,7 +217,7 @@ class Riemann::Tools::Health
alert 'memory', :unknown, nil, "unable to get memory data from top"
return false
end
report_pct :memory, @topdata[:memory], "usage\n\n#{`ps -eo pmem,pid,args | sort -nrb -k1 | head -10`.chomp}"
report_pct :memory, @topdata[:memory], "usage\n\n#{`ps -eo pmem,pid,comm | sort -nrb -k1 | head -10`.chomp}"
end

def disk
Expand Down