Sha256: ce67f2c9cbbccaf9b7596c592a19cc3f1e9fcee461bf4c4ce0a69a01345c3ff6
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
require 'nagios-herald/messages/base' require 'mail' module NagiosHerald class Message class Pager < Message attr_accessor :subject attr_accessor :text # 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. def initialize(recipients, options = {}) @replyto = options[:replyto] @subject = "" @text = "" super(recipients, options) end # Public: Generates the text portion of the content hash. # # Returns the full text portion of the content hash. 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 # Public: Prints the subject and text content to the terminal. # Useful for debugging. # # Returns nothing. def print puts @subject puts @text end # Public: Sends the pager message. # # Returns nothing. def build_message @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 def send mail = self.build_message mail.deliver! unless mail.nil? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nagios-herald-0.0.4 | lib/nagios-herald/messages/pager.rb |