require the code below in a .god config file
and you can use the VirtMemoryUsage as you would use the MemoryUsage
condition
It patches the pollers to expose virtual memory usage.
Have fun with it


module God
  module System
    class SlashProcPoller < PortablePoller
      def virt_memory
        stat[:virt].to_i * @@kb_per_page
      rescue # This shouldn't fail is there's an error (or proc
doesn't exist)
        0
      end
    end

    class PortablePoller
      def virt_memory
        ps_int('virt')
      end
    end

    class Process
      def virt_memory
        @poller.virt_memory
      end
    end
  end
  module Conditions
    class VirtMemoryUsage < MemoryUsage
      def test
        process = System::Process.new(self.pid)
        @timeline.push(process.virt_memory)

        history = "[" + @timeline.map { |x| "#{x > self.above ? '*' :
''}#{x}kb" }.join(", ") + "]"

        if @timeline.select { |x| x > self.above }.size >=
self.times.first
          self.info = "virtual memory out of bounds #{history}"
          return true
        else
          self.info = "virtual memory within bounds #{history}"
          return false
        end
      end
    end
  end
end

-- 
You received this message because you are subscribed to the Google Groups 
"god.rb" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/god-rb?hl=en.

Reply via email to