Skip to content

Instantly share code, notes, and snippets.

@guyc
Created July 11, 2014 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyc/711a2d44f1c694744a8d to your computer and use it in GitHub Desktop.
Save guyc/711a2d44f1c694744a8d to your computer and use it in GitHub Desktop.
zabbix notifier for hipchat
#!/usr/local/rvm/rubies/ruby-1.9.3-p547/bin/ruby
# Guy Carpenter - 11 Jul 2014
require 'rubygems'
require 'hipchat'
# API: https://github.com/hipchat/hipchat-rb
# https://www.hipchat.com/docs/api/method/rooms/message
to = ARGV[0]
subject = ARGV[1] # <Host>:(PROBLEM|OK):(Warning|Error|):<Name>
message = ARGV[2]
levelOptions = {
:information => { :color => 'gray' },
:warning => { :color => 'yellow' },
:average => { :color => 'red' },
:high => { :color => 'red' },
:disaster => { :color => 'red' },
:ok => { :color => 'green' }
}
host,status,severity,description = subject.split(':')
if status == 'OK'
level = :ok
else
level = severity.downcase.to_sym
end
options = levelOptions[level] || levelOptions[:information]
room = 678156
username = host
api_token = 'deleted'
hipchat = HipChat::Client.new(api_token)
text = level.to_s.upcase + ":" + description
hipchat[room].send(username, text, :notify=>true, :color=>options[:color], :message_format=>'text')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment