Skip to content

Commit

Permalink
Support for monitoring multiple instances by one agent
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtor committed Jun 29, 2013
1 parent 1adc5a2 commit 5cb8f2a
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 14 deletions.
13 changes: 12 additions & 1 deletion newrelic_haproxy_agent/config/newrelic_plugin.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ newrelic:
# Agent Configuration:
#
agents:
haproxy:
my_haproxy_1:
# URI of the haproxy CSV stats url. See the 'CSV Export' link on your haproxy stats page (example stats page: http://demo.1wt.eu/).
uri: http://demo.1wt.eu/;csv
# The name of the proxy to monitor. Proxies are typically listed in the haproxy.cfg file.
proxy: http-in
# If multiple proxies have the same name, specify which proxy you want to monitor (ex: 'frontend' or 'backend')."
proxy_type: FRONTEND
# If protected under basic authentication provide the user name
user:
# If protected under basic authentication provide the password.
password:
my_haproxy_2:
# URI of the haproxy CSV stats url. See the 'CSV Export' link on your haproxy stats page (example stats page: http://demo.1wt.eu/).
uri: http://demo.1wt.eu/;csv
# The name of the proxy to monitor. Proxies are typically listed in the haproxy.cfg file.
Expand Down
13 changes: 8 additions & 5 deletions newrelic_haproxy_agent/newrelic_haproxy_agent.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
$stdout.sync = true

# Monitors HAProxy, a TCP/HTTP load balancer, reporting the following data for a specified proxy:
# * Error Rate (per-min)
Expand All @@ -12,7 +13,6 @@
# -------------
# Requires the fastercsv gem


require "rubygems"
require "bundler/setup"
require "newrelic_plugin"
Expand Down Expand Up @@ -62,7 +62,9 @@ class Agent < NewRelic::Plugin::Agent::Base
agent_guid "com.railsware.haproxy"
agent_config_options :uri, :proxy, :proxy_type, :user, :password
agent_version '0.0.5'
agent_human_labels("Haproxy") { proxy }
agent_human_labels("Haproxy") { ident }

attr_reader :ident

def setup_metrics
@requests=NewRelic::Processor::EpochCounter.new
Expand Down Expand Up @@ -131,9 +133,10 @@ def poll_cycle

end


NewRelic::Plugin::Setup.install_agent :haproxy, HaproxyAgent

NewRelic::Plugin::Config.config.agents.keys.each do |agent|
NewRelic::Plugin::Setup.install_agent agent, HaproxyAgent
end

#
# Launch the agent (never returns)
#
Expand Down
12 changes: 11 additions & 1 deletion newrelic_logwatcher_agent/config/newrelic_plugin.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ newrelic:
# Agent Configuration:
#
agents:
logwatcher:
my_logfile_1:
# Full path to the the log file
log_path: tmp.log
# Returns the number of matches for this term. Use Linux Regex formatting.
Expand All @@ -36,3 +36,13 @@ agents:
# For example, to count non-matching lines, enter 'v'.
# Use the abbreviated format ('v' and not 'invert-match').
grep_options:
my_logfile_2:
# Full path to the the log file
log_path: tmp2.log
# Returns the number of matches for this term. Use Linux Regex formatting.
# Default: "[Ee]rror"
term: "[Ee]rror "
# Provide any options to pass to grep when running.
# For example, to count non-matching lines, enter 'v'.
# Use the abbreviated format ('v' and not 'invert-match').
grep_options:
10 changes: 7 additions & 3 deletions newrelic_logwatcher_agent/newrelic_logwatcher_agent.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
$stdout.sync = true

# Monitors a given log file, reporting the rate of occurrences of a provided term. It’s the perfect plugin for error tracking.
#
Expand Down Expand Up @@ -69,7 +70,9 @@ class Agent < NewRelic::Plugin::Agent::Base
agent_guid "com.railsware.logwatcher"
agent_config_options :log_path, :term, :grep_options
agent_version '0.0.2'
agent_human_labels("Logwatcher") { "#{log_path}" }
agent_human_labels("Logwatcher") { ident }

attr_reader :ident

def setup_metrics
@occurances=NewRelic::Processor::DiffRate.new
Expand Down Expand Up @@ -124,8 +127,9 @@ def check_params
end
end


NewRelic::Plugin::Setup.install_agent :logwatcher, LogwatcherAgent
NewRelic::Plugin::Config.config.agents.keys.each do |agent|
NewRelic::Plugin::Setup.install_agent agent, LogwatcherAgent
end

#
# Launch the agent (never returns)
Expand Down
3 changes: 2 additions & 1 deletion newrelic_mpstat_agent/newrelic_mpstat_agent.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
$stdout.sync = true

# Reports the following MP statistics : user, nice, sys, iowait, irq, soft, steal, idle, intrps
#
Expand Down Expand Up @@ -41,7 +42,7 @@ class Agent < NewRelic::Plugin::Agent::Base
agent_guid "com.railsware.mpstat"
agent_config_options :command, :interval
agent_version '0.0.2'
agent_human_labels("Mpstat") { "Mpstat" }
agent_human_labels("Mpstat") { `hostname -f` }


def poll_cycle
Expand Down
7 changes: 6 additions & 1 deletion newrelic_resque_agent/config/newrelic_plugin.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ newrelic:
# Agent Configuration:
#
agents:
resque:
my_resque_1:
# Redis connection string: 'hostname:port' or 'hostname:port:db' or 'redis://user:password@hostname:port:db'
redis: localhost:6379
# Resque namespace
namespace:
my_resque_2:
# Redis connection string: 'hostname:port' or 'hostname:port:db' or 'redis://user:password@hostname:port:db'
redis: localhost:6379
# Resque namespace
Expand Down
10 changes: 8 additions & 2 deletions newrelic_resque_agent/newrelic_resque_agent.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
$stdout.sync = true

# Monitors Resque, a library for processing background jobs, reporting the following data for a specified instance:
# * Number of working workers
Expand Down Expand Up @@ -49,7 +50,9 @@ class Agent < NewRelic::Plugin::Agent::Base
agent_guid "com.railsware.resque"
agent_config_options :redis, :namespace
agent_version '0.0.3'
agent_human_labels("Resque") { redis }
agent_human_labels("Resque") { ident }

attr_reader :ident

def setup_metrics
@total_failed = NewRelic::Processor::EpochCounter.new
Expand Down Expand Up @@ -86,7 +89,10 @@ def poll_cycle
end

end
NewRelic::Plugin::Setup.install_agent :resque, ResqueAgent

NewRelic::Plugin::Config.config.agents.keys.each do |agent|
NewRelic::Plugin::Setup.install_agent agent, ResqueAgent
end

#
# Launch the agent (never returns)
Expand Down

0 comments on commit 5cb8f2a

Please sign in to comment.