Browse code

Rename

Frank Solli authored on 13/11/2017 20:14:27
Showing 2 changed files
1 1
deleted file mode 100644
... ...
@@ -1,31 +0,0 @@
1
-#!/usr/bin/env ruby
2
-#A small script to send piped json events from SensuAPP to Google Cloud Messaging, Frank Solli <frank@frank2.net>
3
-require ‘sensu-handler’
4
-require ‘json’
5
-require ‘rubygems’
6
-require ‘gcm’
7
-
8
-class GCMALERT < Sensu::Handler
9
-def event_name
10
-@event[‘client’][‘name’] + ‘/’ + @event[‘check’][‘name’]
11
-end
12
-
13
-def handle
14
-gcm_apikey = settings[‘gcmalert’][‘apikey’]
15
-gcm_regid = settings[‘gcmalert’][‘registration_ids’]
16
-puts gcm_regid
17
-
18
-gcm = GCM.new(gcm_apikey)
19
-registration_ids = [(gcm_regid)]
20
-
21
-if @event[‘action’].eql?("resolve")
22
-message = "RESOLVED – #{event_name} – #{@event[‘check’][‘output’]}"
23
-else
24
-message = "ALERT – #{event_name} – #{@event[‘check’][‘output’]}"
25
-end
26
-payload = {data: {info: "#{message}"}} #GCM requires a hash
27
-puts payload #debug
28
-response = gcm.send_notification(registration_ids, payload)
29
-puts response #debug
30
-end
31
-end
32 0
new file mode 100644
... ...
@@ -0,0 +1,31 @@
1
+#!/usr/bin/env ruby
2
+#A small script to send piped json events from SensuAPP to Google Cloud Messaging, Frank Solli <frank@frank2.net>
3
+require ‘sensu-handler’
4
+require ‘json’
5
+require ‘rubygems’
6
+require ‘gcm’
7
+
8
+class GCMALERT < Sensu::Handler
9
+def event_name
10
+@event[‘client’][‘name’] + ‘/’ + @event[‘check’][‘name’]
11
+end
12
+
13
+def handle
14
+gcm_apikey = settings[‘gcmalert’][‘apikey’]
15
+gcm_regid = settings[‘gcmalert’][‘registration_ids’]
16
+puts gcm_regid
17
+
18
+gcm = GCM.new(gcm_apikey)
19
+registration_ids = [(gcm_regid)]
20
+
21
+if @event[‘action’].eql?("resolve")
22
+message = "RESOLVED – #{event_name} – #{@event[‘check’][‘output’]}"
23
+else
24
+message = "ALERT – #{event_name} – #{@event[‘check’][‘output’]}"
25
+end
26
+payload = {data: {info: "#{message}"}} #GCM requires a hash
27
+puts payload #debug
28
+response = gcm.send_notification(registration_ids, payload)
29
+puts response #debug
30
+end
31
+end