Class: NagiosHerald::Formatter::CheckMemory
- Inherits:
-
NagiosHerald::Formatter
- Object
- NagiosHerald::Formatter
- NagiosHerald::Formatter::CheckMemory
- Includes:
- Logging
- Defined in:
- lib/nagios-herald/formatters/check_memory.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.
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, #additional_info, #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. Colorizes the ‘ps` output returned by the check_mem NRPE check. The output contains the top n processes by memory utilization similar to:
TOP 5 PROCESSES BY MEMORY USAGE:
%MEM RSS USER PID COMMAND
2.4 1231696 larry 6658 tmux
1.5 777204 moe 32234 tmux/tmux -CC
0.8 399964 curly 12161 /usr/sbin/gmond
0.7 384772 shep 1945 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/mysql.example.com.err --pid-file=/var/lib/mysql/mysql.example.com.pid
0.7 355148 root 1245 SCREEN
Returns nothing. Updates the formatter content hash.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nagios-herald/formatters/check_memory.rb', line 19 def additional_details section = __method__ long_output = get_nagios_var("NAGIOS_LONG#{@state_type}OUTPUT") lines = long_output.split('\n') html = [] html << "<pre>" html << lines[0] # TOP 5 PROCESSES BY MEMORY USAGE: html << lines[1] # %MEM RSS USER PID COMMAND html << "<font color='red'>#{lines[2]}</font>" # Color the first result red... for i in 3..lines.length-1 html << "<font color='orange'>#{lines[i]}</font>" # ...and the remainder orange. end html << "</pre>" output_string = html.join( "<br>" ) add_html(section, "<b>Additional Details</b>:") add_html(section, output_string) add_text(section, "Additional Details:\n#") add_text(section, "#{unescape_text(long_output)}\n") line_break(section) end |