Class: Jah::Prok
Constant Summary collapse
- BANLIST =
[/^ata/, /^init$/, /^scsi_/, /\/\d$/, /agetty/ ]
Constants included from Command
Instance Attribute Summary collapse
-
#comm ⇒ Object
readonly
Returns the value of attribute comm.
-
#cpu ⇒ Object
readonly
Returns the value of attribute cpu.
-
#mem ⇒ Object
readonly
Returns the value of attribute mem.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#rss ⇒ Object
readonly
Returns the value of attribute rss.
-
#stat ⇒ Object
readonly
Returns the value of attribute stat.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#tty ⇒ Object
readonly
Returns the value of attribute tty.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#vsz ⇒ Object
readonly
Returns the value of attribute vsz.
Class Method Summary collapse
Instance Method Summary collapse
- #hup! ⇒ Object
-
#initialize(args) ⇒ Prok
constructor
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND.
- #kill! ⇒ Object
- #move_to_acre! ⇒ Object
- #to_s ⇒ Object
Methods included from Command
Constructor Details
#initialize(args) ⇒ Prok
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
31 32 33 34 35 36 37 38 |
# File 'lib/jah/commands/prok.rb', line 31 def initialize(args) return unless args[0] @user, @pid, @cpu, @mem, @vsz, @rss, @tty, @stat, @start, @time, *@comm = args @pid, @vsz, @rss = [@pid, @vsz, @rss].map(&:to_i) @cpu, @mem = [@cpu, @mem].map(&:to_f) @comm = @comm.join(" ") end |
Instance Attribute Details
#comm ⇒ Object (readonly)
Returns the value of attribute comm.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def comm @comm end |
#cpu ⇒ Object (readonly)
Returns the value of attribute cpu.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def cpu @cpu end |
#mem ⇒ Object (readonly)
Returns the value of attribute mem.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def mem @mem end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def pid @pid end |
#rss ⇒ Object (readonly)
Returns the value of attribute rss.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def rss @rss end |
#stat ⇒ Object (readonly)
Returns the value of attribute stat.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def stat @stat end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def time @time end |
#tty ⇒ Object (readonly)
Returns the value of attribute tty.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def tty @tty end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def user @user end |
#vsz ⇒ Object (readonly)
Returns the value of attribute vsz.
5 6 7 |
# File 'lib/jah/commands/prok.rb', line 5 def vsz @vsz end |
Class Method Details
.all ⇒ Object
14 15 16 17 18 |
# File 'lib/jah/commands/prok.rb', line 14 def self.all `ps auxww`.to_a[1..-1].map do |l| new(l.split) end end |
.find(comm_or_pid) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/jah/commands/prok.rb', line 20 def self.find(comm_or_pid) all.select do |p| unless comm_or_pid.to_i.zero? p.pid == comm_or_pid.to_i else p.comm =~ /#{comm_or_pid}/ end end end |
.genocide!(ary) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/jah/commands/prok.rb', line 56 def self.genocide!(ary) parsed = ary.gsub(/\W/, "").split(" ") for prok in parsed find(prok).each(&:kill!) end end |
Instance Method Details
#hup! ⇒ Object
40 41 42 |
# File 'lib/jah/commands/prok.rb', line 40 def hup! exec "kill -1 #{pid}" end |
#kill! ⇒ Object
44 45 46 |
# File 'lib/jah/commands/prok.rb', line 44 def kill! exec "kill #{pid}" end |
#move_to_acre! ⇒ Object
48 49 50 |
# File 'lib/jah/commands/prok.rb', line 48 def move_to_acre! exec "kill -9 #{pid}" end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/jah/commands/prok.rb', line 52 def to_s "#{pid} - #{user} - #{comm} (#{mem}, #{cpu})" end |