Closed timm088 closed 7 years ago
@timm088 sorry for the confusion; this plugin still works. There are a couple of informative messages squished together in here, so I'll try to clarify.
warning: event filtering in sensu-plugin is deprecated warning: occurrence filtering in sensu-plugin is deprecated
These warning is coming from the sensu-plugin library used by this pushover plugin. The plugin is providing these warnings as part of our effort to deprecate and then remove logic in this library which sometimes causes events to be filtered unexpectedly.
only handling every 30 occurrences: sonarr/service_check
This message is hinting at why your event was filtered by the sensu-plugin library instead of being delivered to the Pushover API. One part of the logic being deprecated and removed from sensu-plugin is the occurrence logic described in our plugins reference documentation.
In your case the default occurrence
and refresh
values used by sensu-plugin are causing events from the service_check
check to only be handled every 30 occurrences.
You can change this behavior by adding explicit occurrences
and refresh
values to the check definition, or disable it all together by following the instructions here.
Again, I apologize for the confusion. Adding deprecation warnings has caused some misunderstanding for many users, but we feel its a necessary part of communicating this larger change. See https://sensuapp.org/blog/2016/07/07/sensu-plugin-filter-deprecation.html for some additional words on the subject.
Hey, thanks for getting back.
Ok understood about those two items and I have fixed that. Sensu now acting on every 3 occurrences.
But, the plugin still has issues (any tips?)
{"timestamp":"2017-04-08T22:10:09.733118+1000","level":"error","message":"handler output","handler":{"type":"pipe","command":"/etc/sensu/plugins/pushover.rb","comment":"Pushover","userkey":"mykey","token":"myoktne","name":"pushover"},"event":{"id":"dc92ee00-c4c4-4abe-a35b-a144ea5f207a"},"output":["/etc/sensu/plugins/pushover.rb:25:in
handle': undefined method []' for nil:NilClass (NoMethodError)\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.4/lib/sensu-handler.rb:81:in
Managed to get the script working, but have hacked it up a bit myself with some hardcoding (not really worthy of a PR, but maybe this will help someone else
require 'net/https'
require 'sensu-handler'
require 'timeout'
#
#
#
class Pushover < Sensu::Handler
def event_name
@event['client']['name'] + '/' + @event['check']['name']
end
def handle
apiurl = 'https://api.pushover.net/1/messages'
priority = if @event['check']['status'] < 3
@event['check']['status'] - 1
else
0
end
params = {
title: event_name,
priority: priority,
message: @event['check']['output']
}
url = URI.parse(apiurl)
req = Net::HTTP::Post.new(url.path)
res = Net::HTTP.new(url.host, url.port)
res.use_ssl = true
res.verify_mode = OpenSSL::SSL::VERIFY_PEER
begin
Timeout.timeout(5) do
params['user'] = 'youruserkey or group key'
params['token'] = 'your api token'
req.set_form_data(params)
res.start { |http| http.request(req) }
puts 'pushover -- sent alert for ' + event_name + ' to user: ' + params['user'] + ', token: ' + params['token'] + '.'
end
rescue Timeout::Error
puts 'pushover -- timed out while attempting to ' + @event['action'] + ' a incident -- ' + event_name
end
end
end
Hi,
Just wondering if this plugin still works? Struggling to get it to fire to pushover
{"timestamp":"2017-04-06T22:12:57.414756+1000","level":"info","message":"handler output","handler":{"type":"pipe","comment":"My Token","command":"/usr/local/bin/handler-pushover.rb","apiurl":"https://api.pushover.net/1/messages","userkey":"mykey","token":"mytoken","name":"pushover"},"event":{"id":"4533e0a9-f592-4cc7-b74d-1a806d47cf7c"},"output":["warning: event filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nwarning: occurrence filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nonly handling every 30 occurrences: sonarr/service_check\n"]}
Not sure if that means this wont function anymore?