class Backup::Notifier::Zabbix
Attributes
item_key[RW]
service_host[RW]
service_name[RW]
zabbix_host[RW]
zabbix_port[RW]
Public Class Methods
new(model, &block)
click to toggle source
Calls superclass method
Backup::Notifier::Base::new
# File lib/backup/notifier/zabbix.rb, line 17 def initialize(model, &block) super instance_eval(&block) if block_given? @zabbix_host ||= Config.hostname @zabbix_port ||= 10051 @service_name ||= "Backup #{ model.trigger }" @service_host ||= Config.hostname @item_key ||= 'backup_status' end
Private Instance Methods
notify!(status)
click to toggle source
Notify the user of the backup operation results.
`status` indicates one of the following:
`:success` : The backup completed successfully. : Notification will be sent if `on_success` is `true`.
`:warning` : The backup completed successfully, but warnings were logged. : Notification will be sent if `on_warning` or `on_success` is `true`.
`:failure` : The backup operation failed. : Notification will be sent if `on_warning` or `on_success` is `true`.
# File lib/backup/notifier/zabbix.rb, line 47 def notify!(status) send_message(message.call(model, :status => status_data_for(status))) end
send_message(message)
click to toggle source
# File lib/backup/notifier/zabbix.rb, line 51 def send_message(message) msg = [service_host, service_name, model.exit_status, message].join("\t") cmd = "#{ utility(:zabbix_sender) }" + " -z '#{ zabbix_host }'" + " -p '#{ zabbix_port }'" + " -s #{ service_host }" + " -k #{ item_key }" + " -o '#{ msg }'" run("echo '#{ msg }' | #{ cmd }") end