Maintenance: Check_MK changed its name to Checkmk.
This commit is contained in:
parent
dc743a7662
commit
7f14332fe0
8 changed files with 112 additions and 86 deletions
|
@ -1,59 +1,22 @@
|
|||
class Index extends App.ControllerIntegrationBase
|
||||
featureIntegration: 'check_mk_integration'
|
||||
featureName: 'Check_MK'
|
||||
featureName: 'Checkmk'
|
||||
featureConfig: 'check_mk_config'
|
||||
description: [
|
||||
['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.']
|
||||
['This service receives http requests or emails from %s and creates tickets with host and service.', 'Checkmk']
|
||||
['If the host and service has recovered, the ticket can be closed automatically.']
|
||||
]
|
||||
|
||||
render: =>
|
||||
super
|
||||
|
||||
new App.SettingsForm(
|
||||
area: 'Integration::CheckMK'
|
||||
el: @$('.js-form')
|
||||
)
|
||||
|
||||
new App.ScriptSnipped(
|
||||
el: @$('.js-scriptSnippedPre')
|
||||
style: 'bash'
|
||||
description: [
|
||||
['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']
|
||||
]
|
||||
)
|
||||
|
||||
new App.ScriptSnipped(
|
||||
el: @$('.js-scriptSnipped')
|
||||
header: 'Service Notification'
|
||||
style: 'bash'
|
||||
description: [
|
||||
['Script can be located under: ||%s||', '/opt/omd/site/SITENAME/local/share/check_mk/notifications/zammad-service']
|
||||
['Please make sure that the script is executable: ||%s||', 'chmod +x /opt/omd/site/SITENAME/local/share/check_mk/notifications/zammad-service']
|
||||
]
|
||||
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')}"
|
||||
)
|
||||
|
||||
new App.ScriptSnipped(
|
||||
el: @$('.js-scriptSnippedExtended')
|
||||
header: 'Host Notification'
|
||||
style: 'bash'
|
||||
description: [
|
||||
['Script can be located under: ||%s||', '/opt/omd/site/SITENAME/local/share/check_mk/notifications/zammad-host']
|
||||
['Please make sure that the script is executable: ||%s||', 'chmod +x /opt/omd/site/SITENAME/local/share/check_mk/notifications/zammad-host']
|
||||
]
|
||||
content: "#!/bin/bash\n\ncurl -X POST -F \"event_id=$NOTIFY_HOSTPROBLEMID\" -F \"host=$NOTIFY_HOSTNAME\" -F \"service=$NOTIFY_SERVICEDESC\" -F \"state=$NOTIFY_HOSTSTATE\" -F \"text=$NOTIFY_HOSTOUTPUT\" #{App.Config.get('http_type')}://#{App.Config.get('fqdn')}/api/v1/integration/check_mk/#{App.Setting.get('check_mk_token')}"
|
||||
)
|
||||
|
||||
new App.ScriptSnipped(
|
||||
el: @$('.js-scriptSnippedPost')
|
||||
header: 'Further Attributes'
|
||||
style: 'bash'
|
||||
description: [
|
||||
['It is also possible to set further attributes of created tickets. To do this, you only need to pass one additional parameter.']
|
||||
]
|
||||
content: '... -F "additional_ticket_attribute=some_value" ...'
|
||||
new Form(
|
||||
el: @$('.js-usage')
|
||||
)
|
||||
|
||||
new App.HttpLog(
|
||||
|
@ -65,10 +28,31 @@ class State
|
|||
@current: ->
|
||||
App.Setting.get('check_mk_integration')
|
||||
|
||||
class Form extends App.Controller
|
||||
events:
|
||||
'click .js-tabItem': 'toogle'
|
||||
'click .js-select': 'selectAll'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
@render()
|
||||
|
||||
render: ->
|
||||
@html App.view('integration/check_mk')()
|
||||
|
||||
@$('.js-code').each((i, block) ->
|
||||
hljs.highlightBlock block
|
||||
)
|
||||
|
||||
toogle: (e) =>
|
||||
target = $(e.target).data('tablist')
|
||||
@$('.js-tablistItem').addClass('hidden')
|
||||
@$(".js-#{target}").removeClass('hidden')
|
||||
|
||||
App.Config.set(
|
||||
'IntegrationCheckMk'
|
||||
{
|
||||
name: 'Check_MK'
|
||||
name: 'Checkmk'
|
||||
target: '#system/integration/check_mk'
|
||||
description: 'An open source monitoring tool.'
|
||||
controller: Index
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
class App.ScriptSnipped extends App.Controller
|
||||
elements:
|
||||
'.js-code': 'code'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
@render()
|
||||
|
||||
render: =>
|
||||
@html App.view('widget/script_snipped')(
|
||||
header: @header || 'Usage',
|
||||
description: @description
|
||||
style: @style
|
||||
content: @content
|
||||
)
|
||||
|
||||
@code.each((i, block) ->
|
||||
hljs.highlightBlock block
|
||||
)
|
|
@ -14,9 +14,6 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<div class="js-form"></div>
|
||||
<div class="js-scriptSnippedPre"></div>
|
||||
<div class="js-scriptSnipped"></div>
|
||||
<div class="js-scriptSnippedExtended"></div>
|
||||
<div class="js-scriptSnippedPost"></div>
|
||||
<div class="js-usage"></div>
|
||||
<div class="js-log"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<hr>
|
||||
|
||||
<h2><%- @T('Usage') %></h2>
|
||||
|
||||
<p><%- @T('To enable %s for sending http requests to %s, you need create a own "notification rule" in %s.', 'Checkmk', 'Zammad', 'Checkmk') %></p>
|
||||
|
||||
<div class="settings-entry">
|
||||
<table class="settings-list" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%"><%- @T('Type') %>
|
||||
<th width="80%"><%- @T('URL') %>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="settings-list-row-control"><%- @T('Endpoint') %>
|
||||
<td class="settings-list-control-cell">
|
||||
<form>
|
||||
<input type="url" class="form-control form-control--small js-select" readonly value="<%= App.Config.get('http_type') %>://<%= App.Config.get('fqdn') %>/api/v1/integration/check_mk/<%= App.Setting.get('check_mk_token') %>">
|
||||
</form>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><%- @T('Examples') %></h2>
|
||||
|
||||
<p><%- @T('You can use the following script to post the data to %s.', 'Zammad') %></p>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active"><a role="tab" data-toggle="tab" aria-expanded="true" class="js-tabItem" data-tablist="service"><%- @T('Service Notification') %></a></li>
|
||||
<li><a role="tab" data-toggle="tab" class="js-tabItem" data-tablist="host"><%- @T('Host Notification') %></a></li>
|
||||
</ul>
|
||||
|
||||
<div class="js-tablist settings-entry">
|
||||
<div class="js-tablistItem js-service">
|
||||
<p><%- @T('Script can be located under: ||%s|| and needs to be executable.', '/opt/omd/sites/{SITENAME}/local/share/check_mk/notifications/zammad-service') %></p>
|
||||
|
||||
<pre><code class="language-bash js-code hljs">
|
||||
#!/bin/bash
|
||||
|
||||
curl -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') %>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="js-tablistItem js-host hidden">
|
||||
<p><%- @T('Script can be located under: ||%s|| and needs to be executable.', '/opt/omd/sites/{SITENAME}/local/share/check_mk/notifications/zammad-host') %></p>
|
||||
|
||||
<pre><code class="language-bash js-code hljs">
|
||||
#!/bin/bash
|
||||
|
||||
curl -X POST -F "event_id=$NOTIFY_HOSTPROBLEMID" -F "host=$NOTIFY_HOSTNAME" -F "state=$NOTIFY_HOSTSTATE" -F "text=$NOTIFY_HOSTOUTPUT" <%= App.Config.get('http_type') %>://<%= App.Config.get('fqdn') %>/api/v1/integration/check_mk/<%= App.Setting.get('check_mk_token') %>
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
|
@ -1,10 +0,0 @@
|
|||
<hr>
|
||||
<h2><%- @T(@header) %></h2>
|
||||
<% if @description: %>
|
||||
<% for item in @description: %>
|
||||
<p><%- @T(item...) %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @content: %>
|
||||
<pre><code class="language-<%- @style %> js-code"><%- @content %></code></pre>
|
||||
<% end %>
|
|
@ -39,11 +39,11 @@ class Integration::CheckMkController < ApplicationController
|
|||
title = "#{params[:host]} is #{params[:state]}"
|
||||
body = "EventID: #{params[:event_id]}
|
||||
Host: #{params[:host]}
|
||||
Service: #{params[:service]}
|
||||
Service: #{params[:service] || '-'}
|
||||
State: #{params[:state]}
|
||||
Text: #{params[:text]}
|
||||
Text: #{params[:text] || '-'}
|
||||
RemoteIP: #{request.remote_ip}
|
||||
UserAgent: #{request.env['HTTP_USER_AGENT']}
|
||||
UserAgent: #{request.env['HTTP_USER_AGENT'] || '-'}
|
||||
"
|
||||
|
||||
# add article
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
class MaintenanceCheckmkWordingsOnSettings < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
|
||||
# return if it's a new setup
|
||||
return if !Setting.find_by(name: 'system_init_done')
|
||||
|
||||
Setting.find_by(name: 'check_mk_integration').update!(
|
||||
title: 'Checkmk integration',
|
||||
description: 'Defines if Checkmk (https://checkmk.com/) is enabled or not.',
|
||||
)
|
||||
|
||||
Setting.find_by(name: 'check_mk_token').update!(
|
||||
title: 'Checkmk token',
|
||||
description: 'Defines the Checkmk token for allowing updates.',
|
||||
)
|
||||
|
||||
end
|
||||
end
|
|
@ -3681,10 +3681,10 @@ Setting.create_if_not_exists(
|
|||
frontend: false
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Check_MK integration',
|
||||
title: 'Checkmk integration',
|
||||
name: 'check_mk_integration',
|
||||
area: 'Integration::Switch',
|
||||
description: 'Defines if Check_MK (http://mathias-kettner.com/check_mk.html) is enabled or not.',
|
||||
description: 'Defines if Checkmk (https://checkmk.com/) is enabled or not.',
|
||||
options: {
|
||||
form: [
|
||||
{
|
||||
|
@ -3739,7 +3739,7 @@ Setting.create_if_not_exists(
|
|||
{
|
||||
display: '',
|
||||
null: true,
|
||||
name: 'check_mk_auto_close',
|
||||
name: 'checkmk_auto_close',
|
||||
tag: 'boolean',
|
||||
options: {
|
||||
true => 'yes',
|
||||
|
@ -3779,10 +3779,10 @@ Setting.create_if_not_exists(
|
|||
frontend: false
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Check_MK tolen',
|
||||
title: 'Checkmk token',
|
||||
name: 'check_mk_token',
|
||||
area: 'Core',
|
||||
description: 'Defines the Check_MK token for allowing updates.',
|
||||
description: 'Defines the Checkmk token for allowing updates.',
|
||||
options: {},
|
||||
state: ENV['CHECK_MK_TOKEN'] || SecureRandom.hex(16),
|
||||
preferences: {
|
||||
|
|
Loading…
Reference in a new issue