Skip to content
fairchild edited this page Sep 13, 2010 · 4 revisions

NOTE: much of this wiki page is outdated. Monitors have changed slightly in 1.1.
Relevant source code for monitors can be found at http://github.com/auser/poolparty/tree/vmrun/lib/poolparty/monitors

PoolParty transparently loads monitors built-in, but also allows you to write monitors that you can use in your spec inherently.

Custom monitors are a class wrapper around one method (run). The CPU monitor looks like this:


module PoolParty
  module Monitors

    class CpuMonitor < BaseMonitor

      def run
        str = %x[uptime]
        str.split(/\s+/)[-1].to_f rescue 0.0
      end

    end

    register_monitor :cpu
  end
end

First thing you’ll notice is that the cpu monitor must be named as such: [name]Monitor. So the base mysql database monitor could look like:


module PoolParty
module Monitors
class MysqlMonitor < BaseMonitor
def run
end
end
register_monitor :mysql
end
end

For your monitor to be included in the available monitors, you must call register_monitor with the name outside the context of the class.

The monitor you create must be a subclass of the PoolParty::Monitors::BaseMonitor class as well.

Finally, the instance method :run is called when running a monitor. Whatever is returned from this method is taken as the return for the monitor. Notice on the cpu monitor that the uptime numbers are returned as the load.

To get this monitor to be loaded in the cloud, add it to the directory with your spec file under the monitors/ directory. You must create this directory if it does not already exist. To add a monitor to all your clouds, add it to the directory /etc/poolparty/monitors. Make sure it is saved with a ruby (.rb) extension.

If you have a monitor you’d like to share, please attach it here or send it to the google groups.

Clone this wiki locally