Browse Source

Added email channel for Check_MK integration.

Martin Edenhofer 7 years ago
parent
commit
77ba574449

+ 6 - 3
app/assets/javascripts/app/controllers/_integration/check_mk.coffee

@@ -3,7 +3,7 @@ class Index extends App.ControllerIntegrationBase
   featureName: 'Check_MK'
   featureConfig: 'check_mk_config'
   description: [
-    ['This service receives http requests from %s and creates tickets with host and service.', 'Check_MK']
+    ['This service receives http requests or emails from %s and creates tickets with host and service.', 'Check_MK']
     ['If the host and service is recovered again, the ticket will be closed automatically.']
   ]
 
@@ -18,9 +18,11 @@ class Index extends App.ControllerIntegrationBase
       el: @$('.js-scriptSnipped')
       facility: 'check_mk'
       style: 'bash'
-      content: "#!/bin/bash\n\ncurl -X POST -F 'event_id=123' -F 'host=host1' -F 'service=http' -F 'state=down'  #{App.Config.get('http_type')}://#{App.Config.get('fqdn')}/api/v1/integration/check_mk/#{App.Setting.get('check_mk_token')}"
+      content: "#!/bin/bash\n\ncurl -X POST -F \"event_id=$NOTIFY_SERVICEPROBLEMID\" -F \"host=$NOTIFY_HOSTNAME\" -F \"service=$NOTIFY_SERVICEDESC\" -F \"state=$NOTIFY_SERVICESTATE\" -F \"text=$NOTIFY_SERVICEOUTPUT\" #{App.Config.get('http_type')}://#{App.Config.get('fqdn')}/api/v1/integration/check_mk/#{App.Setting.get('check_mk_token')}"
       description: [
-        ['To enable %s for sending http requests to %s, you need create "%s" in the admin interface if %s.', 'Check_MK', 'Zammad', 'Event Actions', 'Check_MK']
+        ['To enable %s for sending http requests to %s, you need create a own "notification rule" in %s.', 'Check_MK', 'Zammad', 'Check_MK']
+        ['Configurable in the admin interface of %s.', 'Check_MK']
+        ['You can use the following script to post the data to %s.', 'Zammad']
       ]
     )
 
@@ -41,6 +43,7 @@ App.Config.set(
     description: 'An open source monitoring tool.'
     controller: Index
     state: State
+    permission: ['admin.integration.check_mk']
   }
   'NavBarIntegrations'
 )

+ 7 - 0
app/models/channel/filter/check_mk.rb

@@ -0,0 +1,7 @@
+# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
+
+class Channel::Filter::CheckMk < Channel::Filter::MonitoringBase
+  def self.integration_name
+    'check_mk'
+  end
+end

+ 38 - 4
db/migrate/20170820000001_check_mk_integration.rb → db/migrate/20171024000002_check_mk_integration2.rb

@@ -1,4 +1,4 @@
-class CheckMkIntegration < ActiveRecord::Migration[4.2]
+class CheckMkIntegration2 < ActiveRecord::Migration[4.2]
   def up
 
     # return if it's a new setup
@@ -30,6 +30,29 @@ class CheckMkIntegration < ActiveRecord::Migration[4.2]
       },
       frontend: false
     )
+    Setting.create_if_not_exists(
+      title: 'Sender',
+      name: 'check_mk_sender',
+      area: 'Integration::CheckMK',
+      description: 'Defines the sender email address of the service emails.',
+      options: {
+        form: [
+          {
+            display: '',
+            null: false,
+            name: 'check_mk_sender',
+            tag: 'input',
+            placeholder: 'check_mk@monitoring.example.com',
+          },
+        ],
+      },
+      state: 'check_mk@monitoring.example.com',
+      preferences: {
+        prio: 2,
+        permission: ['admin.integration'],
+      },
+      frontend: false,
+    )
     Setting.create_if_not_exists(
       title: 'Group',
       name: 'check_mk_group_id',
@@ -48,7 +71,7 @@ class CheckMkIntegration < ActiveRecord::Migration[4.2]
       },
       state: 1,
       preferences: {
-        prio: 2,
+        prio: 3,
         permission: ['admin.integration'],
       },
       frontend: false
@@ -69,12 +92,13 @@ class CheckMkIntegration < ActiveRecord::Migration[4.2]
               true  => 'yes',
               false => 'no',
             },
+            translate: true,
           },
         ],
       },
       state: true,
       preferences: {
-        prio: 3,
+        prio: 4,
         permission: ['admin.integration'],
       },
       frontend: false
@@ -92,12 +116,13 @@ class CheckMkIntegration < ActiveRecord::Migration[4.2]
             name: 'check_mk_auto_close_state_id',
             tag: 'select',
             relation: 'TicketState',
+            translate: true,
           },
         ],
       },
       state: 4,
       preferences: {
-        prio: 4,
+        prio: 5,
         permission: ['admin.integration'],
       },
       frontend: false
@@ -114,6 +139,15 @@ class CheckMkIntegration < ActiveRecord::Migration[4.2]
       },
       frontend: false
     )
+    Setting.create_if_not_exists(
+      title: 'Defines postmaster filter.',
+      name: '5200_postmaster_filter_check_mk',
+      area: 'Postmaster::PreFilter',
+      description: 'Defines postmaster filter to manage Check_MK (http://mathias-kettner.com/check_mk.html) emails.',
+      options: {},
+      state: 'Channel::Filter::CheckMk',
+      frontend: false
+    )
   end
 
 end