55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/logstash/outputs/pushover.rb', line 55
def receive(event)
return unless output?(event)
@logger.info("Pushover event", :event => event)
message = event.to_s
if @add_tags
message += " tags: " + @tags.join(',') if @tags
end
begin
request = Net::HTTP::Post.new(@api_uri.path)
request.set_form_data({
:token => @app_token,
:user => @user_key,
:message => event
})
response = @client
response.use_ssl = true
response.verify_mode = OpenSSL::SSL::VERIFY_PEER
response.start do |http|
r = http.request(request)
if status = r.body.match(/"status":(\d+)/)[1] != 1
@logger.warn("API error", :status => status)
end
end
rescue Exception => e
@logger.warn("Failed to push notification", :event => event, :exception => e,
:backtrace => e.backtrace)
end
end
|