niko (owner)

Revisions

gist: 225436 Download_button fork
public
Description:
unicorn stats
Public Clone URL: git://gist.github.com/225436.git
Embed All Files: show embed
def determine_private_dirty_rss #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 # Taken from passenger_memory_stats script
 
  # Returns the private dirty RSS for the given process, in KB.
  def determine_private_dirty_rss(pid)
    total = 0
    File.read("/proc/#{pid}/smaps").split("\n").each do |line|
      line =~ /^(Private)_Dirty: +(\d+)/
      if $2
        total += $2.to_i
      end
    end
    if total == 0
      return nil
    else
      return total
    end
  rescue Errno::EACCES, Errno::ENOENT
    return nil
  end
function unicorn-stats #
1
function unicorn-stats() { ps aux | grep unicorn_rails | grep -v grep | awk '{system("cat /proc/"$2"/smaps | grep Private_Dirty ")}{print $2 " " $10 " " $3 " " $12}' | awk '{ if( $1 ~ /Private_Dirty/ ){ sum += $2 } else { print $4 " "$1 ": " sum/1024 "MB " $3 "%CPU " $2 "h"; sum = 0 } }' | sort ; }