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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8c19621c4296a6cc5d051522ee0176ef3a4726f24bc73eda2c1182c812939c5
4
- data.tar.gz: 1691af6f9079acd23c0f826b6052605d99eff64346c127a5b50a2fbac4e38344
3
+ metadata.gz: fbc15d58535450315726e01bde9c45df3064ae3976604cf8fe53680b9f0f4224
4
+ data.tar.gz: 90bbd8f69daf9c6b12d3932c9b6ae3e2dec193c5f81877622d95714e4f347f6e
5
5
  SHA512:
6
- metadata.gz: 57746ee94c93571b9e8fa14050f2ff1358d265fa710908175fa26b9baa799c5597d31ef2b8a71c3d31b9a57c6c6e4e46fc7377700d1a4f686e1db2a18835f54c
7
- data.tar.gz: 14c121e8aaf4c486e1fdd74ce09747578658cc8f8d7c5c9e471d897ea55fe27d8e5c5a3068c87373988af09d6b96bfee113fb90428680abed618eca0c825ebbd
6
+ metadata.gz: 3d928ff20a8614adb90889492acbd822e61338e3e9ca3c62de391a1128f4b9c32f85c5cb5ef8d72c6a65a1cf67a43eddddb4bf1ea5d1f08011c8a8f1336ee4cb
7
+ data.tar.gz: b835d8b198011f5b203a3e598c954c91dab8d8c84e05ec8641e66aee128777d6548cdf86f7b919b08447895a2959112a0d402ee343e63c95caccdd44314e03e4
data/README.md CHANGED
@@ -37,7 +37,8 @@ touch ~foreman/tmp/restart.txt
37
37
  | >= 2.0 | ~> 2.0 |
38
38
  | >= 2.2 | ~> 2.1 |
39
39
  | >= 3.0 | ~> 3.0 |
40
- | >= 3.6 | ~> 3.1 |
40
+ | >= 3.6 | ~> 3.1, ~>3.2 |
41
+ | >= 3.13 | ~> 3.3 |
41
42
 
42
43
  # Usage
43
44
 
@@ -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 |_app|
22
- Foreman::Plugin.register :foreman_monitoring do
23
- requires_foreman '>= 3.0'
24
-
25
- settings do
26
- category(:monitoring, N_('Monitoring')) do
27
- setting('monitoring_affect_global_status',
28
- type: :boolean,
29
- description: N_("Monitoring status will affect a host's global status when enabled"),
30
- default: true,
31
- full_name: N_('Monitoring status should affect global status'))
32
- setting('monitoring_create_action',
33
- type: :string,
34
- description: N_('What action should be taken when a host is created'),
35
- default: 'create',
36
- full_name: N_('Host Create Action'),
37
- collection: proc { ::Monitoring::CREATE_ACTIONS })
38
- setting('monitoring_delete_action',
39
- type: :string,
40
- description: N_('What action should be taken when a host is deleted'),
41
- default: 'delete',
42
- full_name: N_('Host Delete Action'),
43
- collection: proc { ::Monitoring::DELETE_ACTIONS })
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
- apipie_documented_controllers ["#{ForemanMonitoring::Engine.root}/app/controllers/api/v2/*.rb"]
48
-
49
- security_block :foreman_monitoring do
50
- permission :view_monitoring_results,
51
- {},
52
- :resource_type => 'Host'
53
- permission :manage_downtime_hosts,
54
- { :hosts => [:downtime, :select_multiple_downtime, :update_multiple_downtime], :'api/v2/downtime' => [:create] },
55
- :resource_type => 'Host'
56
- permission :upload_monitoring_results,
57
- :'api/v2/monitoring_results' => [:create]
58
- end
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
- # Extend built in permissions
61
- Foreman::AccessControl.permission(:edit_hosts).actions.concat [
62
- 'hosts/select_multiple_monitoring_proxy',
63
- 'hosts/update_multiple_monitoring_proxy'
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
- role 'Monitoring viewer', [:view_monitoring_results], 'Role granting permissions to view monitor results'
67
- role 'Monitoring manager', [:view_monitoring_results, :manage_downtime_hosts], 'Role granting permissions to view monitor results and manage downtimes'
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
- register_custom_status HostStatus::MonitoringStatus
65
+ register_custom_status HostStatus::MonitoringStatus
70
66
 
71
- add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:monitoring_results) }
67
+ add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:monitoring_results) }
72
68
 
73
- monitoring_proxy_options = {
74
- :feature => 'Monitoring',
75
- :label => N_('Monitoring Proxy'),
76
- :description => N_('Monitoring Proxy to use to manage monitoring of this host'),
77
- :api_description => N_('ID of Monitoring Proxy to use to manage monitoring of this host')
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
- # add monitoring smart proxy to hosts and hostgroups
81
- smart_proxy_for Host::Managed, :monitoring_proxy, monitoring_proxy_options
82
- smart_proxy_for Hostgroup, :monitoring_proxy, monitoring_proxy_options
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
- add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:monitoring_proxy) }
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})"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanMonitoring
4
- VERSION = '3.1.0'
4
+ VERSION = '3.3.0'
5
5
  end
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.1.0
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: 2024-05-28 00:00:00.000000000 Z
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/concerns/foreman_monitoring/hosts_helper_ext.rb
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.9
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