Class: HipchatNagiosNotifier::CLI
- Inherits:
-
Thor
- Object
- Thor
- HipchatNagiosNotifier::CLI
- Defined in:
- lib/hipchat_nagios_notifier.rb
Constant Summary collapse
- COLORS =
{ 'PROBLEM' =>'red', 'RECOVERY' =>'green', 'ACKNOWLEDGEMENT' =>'green', 'FLAPPINGSTART' =>'orange', 'FLAPPINGSTOP' =>'green', 'FLAPPINGDISABLED' =>'gray', 'DOWNTIMESTART' =>'red', 'DOWNTIMESTOP' =>'green', 'DOWNTIMECANCELLED' =>'green' }
Instance Method Summary collapse
Instance Method Details
#host(api_key, room, from, details) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hipchat_nagios_notifier.rb', line 29 def host(api_key, room, from, details) nagioshost = Socket.gethostname.split('.')[0] hostname,,type,hostaddress,hoststate,hostoutput = details.split('|') color = COLORS[type] || 'gray' notify api_key, room, from, color, %{#{} - Host #{hostname} (Origin: nagios@#{nagioshost}) Details: Notification type: #{type} Host: #{hostname} (Address #{hostaddress}) State: #{hoststate} Info: #{hostoutput} ---------}.gsub("\n", "<br/>") end |
#service(api_key, room, from, details) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/hipchat_nagios_notifier.rb', line 20 def service(api_key, room, from, details) nagioshost = Socket.gethostname.split('.')[0] servicedesc, hostalias,,type,hostaddress,servicestate,serviceoutput = details.split('|') color = COLORS[type] || 'gray' notify api_key, room, from, color, %{#{} - #{servicedesc} is #{servicestate} on #{hostaddress}: #{serviceoutput}} end |