foreman_monitoring 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/controllers/concerns/foreman_monitoring/hosts_controller_extensions.rb +2 -1
- data/app/helpers/foreman_monitoring/hosts_helper.rb +73 -0
- data/app/views/hosts/_downtime_fields.html.erb +1 -0
- data/lib/foreman_monitoring/engine.rb +61 -61
- data/lib/foreman_monitoring/version.rb +1 -1
- metadata +4 -4
- data/app/helpers/concerns/foreman_monitoring/hosts_helper_ext.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbc15d58535450315726e01bde9c45df3064ae3976604cf8fe53680b9f0f4224
|
4
|
+
data.tar.gz: 90bbd8f69daf9c6b12d3932c9b6ae3e2dec193c5f81877622d95714e4f347f6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d928ff20a8614adb90889492acbd822e61338e3e9ca3c62de391a1128f4b9c32f85c5cb5ef8d72c6a65a1cf67a43eddddb4bf1ea5d1f08011c8a8f1336ee4cb
|
7
|
+
data.tar.gz: b835d8b198011f5b203a3e598c954c91dab8d8c84e05ec8641e66aee128777d6548cdf86f7b919b08447895a2959112a0d402ee343e63c95caccdd44314e03e4
|
data/README.md
CHANGED
@@ -97,7 +97,8 @@ module ForemanMonitoring
|
|
97
97
|
:comment => params[:downtime][:comment],
|
98
98
|
:author => "Foreman User #{User.current}",
|
99
99
|
:start_time => Time.zone.parse(params[:downtime][:starttime]).to_i,
|
100
|
-
:end_time => Time.zone.parse(params[:downtime][:endtime]).to_i
|
100
|
+
:end_time => Time.zone.parse(params[:downtime][:endtime]).to_i,
|
101
|
+
**(params[:downtime][:all_services] == '1' ? { :all_services => true } : {})
|
101
102
|
}
|
102
103
|
end
|
103
104
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanMonitoring
|
4
|
+
module HostsHelper
|
5
|
+
def monitoring_hosts_multiple_actions
|
6
|
+
actions = []
|
7
|
+
actions << { action: [_('Set downtime'), select_multiple_downtime_hosts_path], priority: 1000 } \
|
8
|
+
if authorized_for(:controller => :hosts, :action => :select_multiple_downtime)
|
9
|
+
actions << { action: [_('Change Monitoring Proxy'), select_multiple_monitoring_proxy_hosts_path], priority: 1000 } \
|
10
|
+
if authorized_for(:controller => :hosts, :action => :select_multiple_monitoring_proxy)
|
11
|
+
actions
|
12
|
+
end
|
13
|
+
|
14
|
+
def host_title_actions(host)
|
15
|
+
title_actions(
|
16
|
+
button_group(
|
17
|
+
display_link_if_authorized(
|
18
|
+
_('Downtime'),
|
19
|
+
hash_for_host_path(:id => host).merge(
|
20
|
+
:auth_object => host,
|
21
|
+
:permission => :manage_downtime_hosts,
|
22
|
+
:anchor => 'set_host_downtime'
|
23
|
+
),
|
24
|
+
:class => 'btn btn-default',
|
25
|
+
:disabled => !host.monitored?,
|
26
|
+
:title => _('Set a downtime for this host'),
|
27
|
+
:id => 'host-downtime',
|
28
|
+
:data => {
|
29
|
+
:toggle => 'modal',
|
30
|
+
:target => '#set_host_downtime',
|
31
|
+
}
|
32
|
+
)
|
33
|
+
)
|
34
|
+
)
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def host_monitoring_result_icon_class(result)
|
39
|
+
icon_class = case result
|
40
|
+
when :ok
|
41
|
+
'pficon-ok'
|
42
|
+
when :warning
|
43
|
+
'pficon-info'
|
44
|
+
when :critical
|
45
|
+
'pficon-error-circle-o'
|
46
|
+
else
|
47
|
+
'pficon-help'
|
48
|
+
end
|
49
|
+
|
50
|
+
"host-status #{icon_class} #{host_monitoring_result_class(result)}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def host_monitoring_result_class(result)
|
54
|
+
case result
|
55
|
+
when :ok
|
56
|
+
'status-ok'
|
57
|
+
when :warning
|
58
|
+
'status-warn'
|
59
|
+
when :critical
|
60
|
+
'status-error'
|
61
|
+
else
|
62
|
+
'status-question'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def monitoring_datetime_f(f, attr, options = {})
|
67
|
+
field(f, attr, options) do
|
68
|
+
addClass options, 'form-control'
|
69
|
+
f.datetime_field attr, options
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
1
|
<%= text_f f, :comment, :size => "col-md-5", :label => _('Comment'), :help_inline => _('Short description that explains why the downtime was set.'), :required => true %>
|
2
2
|
<%= monitoring_datetime_f f, :starttime, :size => "col-md-5", :label => _('Starttime'), :help_inline => _('Time when the downtime should start.'), :min => DateTime.now, :value => Time.current, :required => true %>
|
3
3
|
<%= monitoring_datetime_f f, :endtime, :size => "col-md-5", :label => _('Endtime'), :help_inline => _('Time when the downtime should end.'), :value => Time.current.advance(:hours => 2), :required => true %>
|
4
|
+
<%= checkbox_f f, :all_services, :size => "col-md-5", :label => _('All services'), :help_inline => _("Set downtime for all host's services.") %>
|
@@ -6,11 +6,6 @@ module ForemanMonitoring
|
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
engine_name 'foreman_monitoring'
|
8
8
|
|
9
|
-
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
10
|
-
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
11
|
-
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
12
|
-
config.autoload_paths += Dir["#{config.root}/app/services"]
|
13
|
-
|
14
9
|
# Add any db migrations
|
15
10
|
initializer 'foreman_monitoring.load_app_instance_data' do |app|
|
16
11
|
ForemanMonitoring::Engine.paths['db/migrate'].existent.each do |path|
|
@@ -18,77 +13,82 @@ module ForemanMonitoring
|
|
18
13
|
end
|
19
14
|
end
|
20
15
|
|
21
|
-
initializer 'foreman_monitoring.register_plugin', :before => :finisher_hook do |
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
16
|
+
initializer 'foreman_monitoring.register_plugin', :before => :finisher_hook do |app|
|
17
|
+
app.reloader.to_prepare do
|
18
|
+
Foreman::Plugin.register :foreman_monitoring do
|
19
|
+
requires_foreman '>= 3.13'
|
20
|
+
|
21
|
+
settings do
|
22
|
+
category(:monitoring, N_('Monitoring')) do
|
23
|
+
setting('monitoring_affect_global_status',
|
24
|
+
type: :boolean,
|
25
|
+
description: N_("Monitoring status will affect a host's global status when enabled"),
|
26
|
+
default: true,
|
27
|
+
full_name: N_('Monitoring status should affect global status'))
|
28
|
+
setting('monitoring_create_action',
|
29
|
+
type: :string,
|
30
|
+
description: N_('What action should be taken when a host is created'),
|
31
|
+
default: 'create',
|
32
|
+
full_name: N_('Host Create Action'),
|
33
|
+
collection: proc { ::Monitoring::CREATE_ACTIONS })
|
34
|
+
setting('monitoring_delete_action',
|
35
|
+
type: :string,
|
36
|
+
description: N_('What action should be taken when a host is deleted'),
|
37
|
+
default: 'delete',
|
38
|
+
full_name: N_('Host Delete Action'),
|
39
|
+
collection: proc { ::Monitoring::DELETE_ACTIONS })
|
40
|
+
end
|
44
41
|
end
|
45
|
-
end
|
46
42
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
43
|
+
apipie_documented_controllers ["#{ForemanMonitoring::Engine.root}/app/controllers/api/v2/*.rb"]
|
44
|
+
|
45
|
+
security_block :foreman_monitoring do
|
46
|
+
permission :view_monitoring_results,
|
47
|
+
{},
|
48
|
+
:resource_type => 'Host'
|
49
|
+
permission :manage_downtime_hosts,
|
50
|
+
{ :hosts => [:downtime, :select_multiple_downtime, :update_multiple_downtime], :'api/v2/downtime' => [:create] },
|
51
|
+
:resource_type => 'Host'
|
52
|
+
permission :upload_monitoring_results,
|
53
|
+
:'api/v2/monitoring_results' => [:create]
|
54
|
+
end
|
59
55
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
56
|
+
# Extend built in permissions
|
57
|
+
Foreman::AccessControl.permission(:edit_hosts).actions.concat [
|
58
|
+
'hosts/select_multiple_monitoring_proxy',
|
59
|
+
'hosts/update_multiple_monitoring_proxy'
|
60
|
+
]
|
65
61
|
|
66
|
-
|
67
|
-
|
62
|
+
role 'Monitoring viewer', [:view_monitoring_results], 'Role granting permissions to view monitor results'
|
63
|
+
role 'Monitoring manager', [:view_monitoring_results, :manage_downtime_hosts], 'Role granting permissions to view monitor results and manage downtimes'
|
68
64
|
|
69
|
-
|
65
|
+
register_custom_status HostStatus::MonitoringStatus
|
70
66
|
|
71
|
-
|
67
|
+
add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:monitoring_results) }
|
72
68
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
69
|
+
monitoring_proxy_options = {
|
70
|
+
:feature => 'Monitoring',
|
71
|
+
:label => N_('Monitoring Proxy'),
|
72
|
+
:description => N_('Monitoring Proxy to use to manage monitoring of this host'),
|
73
|
+
:api_description => N_('ID of Monitoring Proxy to use to manage monitoring of this host')
|
74
|
+
}
|
79
75
|
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
# add monitoring smart proxy to hosts and hostgroups
|
77
|
+
smart_proxy_for Host::Managed, :monitoring_proxy, monitoring_proxy_options
|
78
|
+
smart_proxy_for Hostgroup, :monitoring_proxy, monitoring_proxy_options
|
83
79
|
|
84
|
-
|
80
|
+
add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:monitoring_proxy) }
|
81
|
+
|
82
|
+
describe_host do
|
83
|
+
multiple_actions_provider :monitoring_hosts_multiple_actions
|
84
|
+
end
|
85
|
+
end
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
88
89
|
config.to_prepare do
|
89
90
|
::Host::Managed.prepend(ForemanMonitoring::HostExtensions)
|
90
91
|
::Hostgroup.include(ForemanMonitoring::HostgroupExtensions)
|
91
|
-
::HostsHelper.prepend(ForemanMonitoring::HostsHelperExt)
|
92
92
|
::HostsController.prepend(ForemanMonitoring::HostsControllerExtensions)
|
93
93
|
rescue StandardError => e
|
94
94
|
Rails.logger.warn "ForemanMonitoring: skipping engine hook (#{e})"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_monitoring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Goebel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- app/controllers/api/v2/monitoring_results_controller.rb
|
53
53
|
- app/controllers/concerns/foreman_monitoring/find_host_by_client_cert.rb
|
54
54
|
- app/controllers/concerns/foreman_monitoring/hosts_controller_extensions.rb
|
55
|
-
- app/helpers/
|
55
|
+
- app/helpers/foreman_monitoring/hosts_helper.rb
|
56
56
|
- app/lib/proxy_api/monitoring.rb
|
57
57
|
- app/models/concerns/foreman_monitoring/host_extensions.rb
|
58
58
|
- app/models/concerns/foreman_monitoring/hostgroup_extensions.rb
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
rubygems_version: 3.5.
|
121
|
+
rubygems_version: 3.5.22
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Foreman plugin for monitoring system integration.
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ForemanMonitoring
|
4
|
-
module HostsHelperExt
|
5
|
-
def multiple_actions
|
6
|
-
actions = super
|
7
|
-
actions << [_('Set downtime'), select_multiple_downtime_hosts_path] if authorized_for(:controller => :hosts, :action => :select_multiple_downtime)
|
8
|
-
actions << [_('Change Monitoring Proxy'), select_multiple_monitoring_proxy_hosts_path] if authorized_for(:controller => :hosts, :action => :select_multiple_monitoring_proxy)
|
9
|
-
actions
|
10
|
-
end
|
11
|
-
|
12
|
-
def host_title_actions(host)
|
13
|
-
title_actions(
|
14
|
-
button_group(
|
15
|
-
display_link_if_authorized(_('Downtime'),
|
16
|
-
hash_for_host_path(:id => host).merge(:auth_object => host,
|
17
|
-
:permission => :manage_downtime_hosts,
|
18
|
-
:anchor => 'set_host_downtime'),
|
19
|
-
:class => 'btn btn-default',
|
20
|
-
:disabled => !host.monitored?,
|
21
|
-
:title => _('Set a downtime for this host'),
|
22
|
-
:id => 'host-downtime',
|
23
|
-
:data => { :toggle => 'modal',
|
24
|
-
:target => '#set_host_downtime' })
|
25
|
-
)
|
26
|
-
)
|
27
|
-
super
|
28
|
-
end
|
29
|
-
|
30
|
-
def host_monitoring_result_icon_class(result)
|
31
|
-
icon_class = case result
|
32
|
-
when :ok
|
33
|
-
'pficon-ok'
|
34
|
-
when :warning
|
35
|
-
'pficon-info'
|
36
|
-
when :critical
|
37
|
-
'pficon-error-circle-o'
|
38
|
-
else
|
39
|
-
'pficon-help'
|
40
|
-
end
|
41
|
-
|
42
|
-
"host-status #{icon_class} #{host_monitoring_result_class(result)}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def host_monitoring_result_class(result)
|
46
|
-
case result
|
47
|
-
when :ok
|
48
|
-
'status-ok'
|
49
|
-
when :warning
|
50
|
-
'status-warn'
|
51
|
-
when :critical
|
52
|
-
'status-error'
|
53
|
-
else
|
54
|
-
'status-question'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def monitoring_datetime_f(f, attr, options = {})
|
59
|
-
field(f, attr, options) do
|
60
|
-
addClass options, 'form-control'
|
61
|
-
f.datetime_field attr, options
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|