forked from agperson/zabbix-hipchat-alerts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhipchat.rb
executable file
·28 lines (22 loc) · 953 Bytes
/
hipchat.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
alert_script = File.dirname(__FILE__) + "/notify.rb"
# Load configuration
config = YAML.load_file(File.join(File.dirname(__FILE__), 'config.yaml'))
url = config['zabbix_url']
YAML.load(ARGV[2]).each { |k, v| instance_variable_set("@" + k, v) }
if @status == "PROBLEM" then
case @severity
when "Warning" then color = "yellow"
when "Average" then color = "purple"
when "High" then color = "red"
when "Disaster" then color = "red"
else color = "gray"
end
message = "<strong>#{@status}: #{@name}</strong> (#{@severity})<br />host #{@hostname} [ <a href='#{url}/events.php?triggerid=#{@id}\'>Events</a> | <a href='#{url}/acknow.php?eventid=#{@event_id}'>Acknowledge</a> ]"
else
color = "green"
message = "<strong>#{@status}: #{@name}</strong> (#{@severity})<br />host #{@hostname}"
end
exec("#{alert_script} --color #{color} --notify --message \"#{message}\"")