Class: NagiosHerald::Message::Pager
- Inherits:
-
NagiosHerald::Message
- Object
- NagiosHerald::Message
- NagiosHerald::Message::Pager
- Defined in:
- lib/nagios-herald/messages/pager.rb
Instance Attribute Summary collapse
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from NagiosHerald::Message
Instance Method Summary collapse
-
#build_message ⇒ Object
Public: Sends the pager message.
-
#curate_text ⇒ Object
Public: Generates the text portion of the content hash.
-
#initialize(recipients, options = {}) ⇒ Pager
constructor
Public: Initializes a new Message::Pager object.
-
#print ⇒ Object
Public: Prints the subject and text content to the terminal.
- #send ⇒ Object
Methods inherited from NagiosHerald::Message
Methods included from Util
#get_nagios_var, get_script_path, load_helper, underscore_to_camel_case, #unescape_text
Methods included from Logging
#configure_logger_for, #logger, #logger_for
Constructor Details
#initialize(recipients, options = {}) ⇒ Pager
Public: Initializes a new Message::Pager object.
recipients - A list of recipients for this message. options - The options hash from Executor. FIXME: Is that ^^ necessary now with Config.config available?
Returns a new Message::Pager object.
18 19 20 21 22 23 |
# File 'lib/nagios-herald/messages/pager.rb', line 18 def initialize(recipients, = {}) @replyto = [:replyto] @subject = "" @text = "" super(recipients, ) end |
Instance Attribute Details
#subject ⇒ Object
Returns the value of attribute subject.
8 9 10 |
# File 'lib/nagios-herald/messages/pager.rb', line 8 def subject @subject end |
#text ⇒ Object
Returns the value of attribute text.
9 10 11 |
# File 'lib/nagios-herald/messages/pager.rb', line 9 def text @text end |
Instance Method Details
#build_message ⇒ Object
Public: Sends the pager message.
Returns nothing.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/nagios-herald/messages/pager.rb', line 51 def @subject = self.content[:short_subject] curate_text mail = Mail.new({ :from => @replyto, :to => @recipients, :subject => @subject, :body => @text }) if @no_send self.print return end return mail end |
#curate_text ⇒ Object
Public: Generates the text portion of the content hash.
Returns the full text portion of the content hash.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/nagios-herald/messages/pager.rb', line 28 def curate_text notification_type = get_nagios_var('NAGIOS_NOTIFICATIONTYPE') if notification_type.eql?('ACKNOWLEDGEMENT') @text += self.content[:short_text][:ack_info] unless self.content[:short_text][:ack_info].empty? else [:state_info, :additional_info, :additional_details].each do |info| @text += self.content[:short_text][info] unless self.content[:short_text][info].empty? end end end |
#print ⇒ Object
Public: Prints the subject and text content to the terminal. Useful for debugging.
Returns nothing.
43 44 45 46 |
# File 'lib/nagios-herald/messages/pager.rb', line 43 def print puts @subject puts @text end |
#send ⇒ Object
72 73 74 75 |
# File 'lib/nagios-herald/messages/pager.rb', line 72 def send mail = self. mail.deliver! unless mail.nil? end |