Skip to content
This repository was archived by the owner on Jun 13, 2020. It is now read-only.

Be nicer changes #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/nagios-herald/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ def parse_options
default nil
end

option :message_type, :required => true do
option :message_type do
short "-m"
long "--message-type"
desc "[REQUIRED] Type of message to deliver (i.e. email, IRC, pager)"
desc "Type of message to deliver (i.e. email, IRC, pager)"
default "email"
end

option :no_send do
Expand Down Expand Up @@ -118,10 +119,11 @@ def parse_options
desc "Nagios CGI url (used for acknowledgement links)"
end

option :replyto, :required => true do
option :replyto do
short "-y"
long "--reply-to"
desc "[REQUIRED] Reply-to email address (i.e. nagios@example.com) used for acknowledgement replies."
desc "Reply-to email address (i.e. nagios@example.com) used for acknowledgement replies."
default "nagios@example.com"
end

footer ""
Expand Down Expand Up @@ -239,10 +241,10 @@ def announce
end
message_class = Message.message_types[@options.message_type]
message = message_class.new(recipient, @options)

formatter_class = Formatter.formatters[@options.formatter_name]
if formatter_class.nil?
logger.info "Undefined formatter. Defaulting to the base formatter."
logger.info "Formatter not found - known formatters are : #{Formatter.formatters.keys.join(', ')}"
logger.info "Defaulting to the base formatter."
formatter_class = NagiosHerald::Formatter # default to the base formatter
end
formatter = formatter_class.new(@options)
Expand Down
2 changes: 1 addition & 1 deletion lib/nagios-herald/helpers/elasticsearch_query.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'net/http'
require 'uri'
require 'json'
require 'elasticsearch'

# Query Elasticsearch with arbitrary search criteria

Expand All @@ -26,6 +25,7 @@ class ElasticsearchQuery
#
# Returns a new ElasticsearchQuery object.
def initialize(options={})
require 'elasticsearch'
today = Time.now.strftime("%Y.%m.%d")
@elasticsearch_index = options[:index] ? options[:index] : "logstash-#{today}"
@elasticsearch_time_period = options[:time_period] ? options[:time_period] : "1h"
Expand Down
2 changes: 1 addition & 1 deletion lib/nagios-herald/helpers/ganglia_graph.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'chef/search/query'

module NagiosHerald
module Helpers
Expand All @@ -9,6 +8,7 @@ class GangliaGraph
#
# Returns GangliaGraph helper object.
def initialize
require 'chef/search/query'
@ganglia_base_uri = Config.config['servers']['ganglia']
end

Expand Down