Archives

It's very easy to create a Scout plugin

By Andre Bullet_white Posted in HowTo Bullet_white Comments 1 comment

How easy? Really easy. There are just two things you need to know to get started:

1. Starting the Agent in test mode

The agent sports a nifty autotest-like mode to help you quickly iterate new plugin code. To start:

scout_agent test my_new_plugin.rb

With that, the agent is watching my_new_plugin.rb, just waiting for you to hit save so it can come to life. Whenever you modify the target file, the Agent will immediately log to console the results of your plugin-in-progress.

2. The basic format of a plugin

Keeping this very simple—a plugin looks like this:

class ExampleReport < Scout::Plugin
  def build_report
    report(:minute=>Time.now.min)
  end
end

Yeah, that’s a simple case all right. It just reports the minute every time it runs, so it will generate a single data series with a value between 0 and 59.

If you haven’t created a plugin before, I encourage you to try this very simple example. It will take you approximately two minutes, and you’ll see how easy the Agent’s test mode makes it to iterate.

Go a little deeper

There’s more: generating alerts, reading from option files, etc. When you’re ready, check out the developer documentation at https://scoutapp.com/info/creating_a_plugin