Class: NagiosHerald::Formatter::CheckLogstash
- Inherits:
-
NagiosHerald::Formatter
- Object
- NagiosHerald::Formatter
- NagiosHerald::Formatter::CheckLogstash
- Includes:
- Logging
- Defined in:
- lib/nagios-herald/formatters/check_logstash.rb
Instance Attribute Summary
Attributes inherited from NagiosHerald::Formatter
#content, #sandbox, #state_type
Instance Method Summary collapse
-
#additional_details ⇒ Object
Public: Overrides Formatter::Base#additional_details.
-
#additional_info ⇒ Object
Public: Overrides Formatter::Base#additional_info.
Methods included from Logging
#configure_logger_for, #logger, #logger_for
Methods inherited from NagiosHerald::Formatter
#ack_info, #action_url, #add_attachment, #add_html, #add_short_text, #add_text, #alert_ack_url, #clean_sandbox, #delete_html, #delete_section_for_type, #delete_short_text, #delete_text, #end_section, formatters, #generate_ack_content, #generate_content, #generate_message_content, #generate_problem_content, #generate_recovery_content, #generate_section, #generate_subject, #get_sandbox_path, #host_info, inherited, #initialize, #line_break, #notes, #notification_info, #recipients_email_link, #short_ack_info, #short_state_detail, #start_section, #state_info
Methods included from Util
#get_nagios_var, get_script_path, load_helper, underscore_to_camel_case, #unescape_text
Constructor Details
This class inherits a constructor from NagiosHerald::Formatter
Instance Method Details
#additional_details ⇒ Object
Public: Overrides Formatter::Base#additional_details. Calls on methods defined in this class to colorize and bold the ‘df` output generated by the check_disk NRPE check.
Returns nothing. Updates the formatter content hash.
61 62 63 |
# File 'lib/nagios-herald/formatters/check_logstash.rb', line 61 def additional_details end |
#additional_info ⇒ Object
Public: Overrides Formatter::Base#additional_info. Calls on methods defined in this class to generate stack bars and download Ganglia graphs.
Returns nothing. Updates the formatter content hash.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/nagios-herald/formatters/check_logstash.rb', line 14 def additional_info section = __method__ # this defines the section key in the formatter's content hash service_output = get_nagios_var("NAGIOS_SERVICECHECKCOMMAND") command_components = parse_command(service_output) # The aggregation level limit for which we can render results agg_level_limit = 3 logstash_helper = NagiosHerald::Helpers::LogstashQuery.new results = get_logstash_results(logstash_helper, command_components[:query]) # Handle the case when an exception is thrown inside get_logstash_results if results.empty? add_text(section, "Something went wrong while getting logstash results\n\n") return end if results["hits"]["hits"].empty? && results["aggregations"] # We have aggregations query_agg_data = logstash_helper.query["aggregations"] || logstash_helper.query["aggs"] agg_depth_level = 1 + agg_depth(query_agg_data) # We can't cope with more than 3 level deep aggregates if agg_depth_level > agg_level_limit #Add error text to the alert and return straight away add_text(section, "Error - query contains #{agg_depth_level} levels of aggregation - more than #{agg_level_limit} levels are not supported by this plugin\n") return end agg_field_name = query_agg_data.keys.first html_output = generate_table_from_buckets(results["aggregations"][agg_field_name]["buckets"]) else # We have normal search results html_output = generate_html_output(results["hits"]["hits"]) end add_html(section, html_output) end |