foreman_maintain 1.14.2 → 1.14.3

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: 33870bada1b5b0c7fcff16ceed118f84c50b9c12fccdc93927d1270ac3b4e308
4
- data.tar.gz: a11c5de1e5089b77c0658b1b8db3b92bb49ca382f4c5788ece9bf9d458c72eb6
3
+ metadata.gz: f8971bf9bea6cfdf4e123cbf5926859884bde1665d7e6e56f80b38598a1ec737
4
+ data.tar.gz: 0d02271818e046de3a240b569a3667da31101caf3efed94e3c4ccd71be8e94ed
5
5
  SHA512:
6
- metadata.gz: a541ecc432dd71795db47e76306b62338ae9ef4961734860c72c3809ca7a34d4b30f70b53c59221f9a12962f162d24d7fe0ecaa3091372f1c58110e3001497cc
7
- data.tar.gz: 6fffef2f94471ebb97c0e43e01e29d284885a28c66982c70d34785b0457dd544ff440ec1298d7d6533631b1b34e06b2ff869fbf30934956f367464a952ce2473
6
+ metadata.gz: 2390f8699745ed38eeef34fa8bf3891a5af7e7ca99d871aef1ac5efb5c45181c3112efae2db349770b8158ebb310331423ee408e5e48af3acf2e47ca34fb77f9
7
+ data.tar.gz: f3f9118b726d82f5b6a217495b179a522cfbec6a4eb86a45cc4907107153ea8fe6bc232b7129a04f7e02836adfe0d0d4be562081e271527e2f5b8d6beb1bf799
@@ -18,7 +18,7 @@ module Procedures::Iop
18
18
 
19
19
  def pull_images
20
20
  feature(:iop).container_images(@version).each do |container_image|
21
- execute!("podman pull #{container_image}")
21
+ execute!("podman pull --authfile /etc/foreman/registry-auth.json #{container_image}")
22
22
  end
23
23
  end
24
24
  end
@@ -0,0 +1,38 @@
1
+ module Report
2
+ class ActivationKeys < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report metrics related to Katello activation keys'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ def run
11
+ data_field('activation_keys_count') { activation_keys_count }
12
+ data_field('activation_keys_multi_cv_count') { activation_keys_multi_cv_count }
13
+ end
14
+
15
+ private
16
+
17
+ def activation_keys_count
18
+ sql_count(
19
+ 'katello_content_view_environment_activation_keys',
20
+ column: 'DISTINCT activation_key_id'
21
+ )
22
+ end
23
+
24
+ def activation_keys_multi_cv_count
25
+ sql_as_count(
26
+ "COUNT(*)",
27
+ <<~SQL
28
+ (
29
+ SELECT activation_key_id
30
+ FROM katello_content_view_environment_activation_keys
31
+ GROUP BY activation_key_id
32
+ HAVING COUNT(*) > 1
33
+ ) AS multi_cve_keys
34
+ SQL
35
+ )
36
+ end
37
+ end
38
+ end
@@ -1,7 +1,7 @@
1
1
  module Reports
2
2
  class Compliance < ForemanMaintain::Report
3
3
  metadata do
4
- description 'Check if OpenSCAP is used'
4
+ description 'Report metrics related to OpenSCAP'
5
5
  end
6
6
 
7
7
  def run
@@ -0,0 +1,63 @@
1
+ module Report
2
+ class ContainerMetadata < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report metrics related to Katello container metadata'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ def run
11
+ data_field('container_manifests_count') { container_manifests_count }
12
+ data_field('container_manifest_lists_count') { container_manifest_lists_count }
13
+ data_field('container_tags_count') { container_tags_count }
14
+ data_field('container_meta_tags_count') { container_meta_tags_count }
15
+ end
16
+
17
+ private
18
+
19
+ def container_manifests_count
20
+ # Count distinct container manifests present in container repositories.
21
+ # Exclude flatpaks which also use the manifest tables.
22
+ sql = <<-SQL
23
+ katello_repository_docker_manifests rdm
24
+ INNER JOIN katello_docker_manifests dm ON rdm.docker_manifest_id = dm.id
25
+ INNER JOIN katello_repositories r ON rdm.repository_id = r.id
26
+ INNER JOIN katello_root_repositories rr ON r.root_id = rr.id
27
+ WHERE rr.content_type = 'docker'
28
+ AND COALESCE(dm.is_flatpak, false) = false
29
+ SQL
30
+ sql_count(sql, column: 'DISTINCT dm.id')
31
+ end
32
+
33
+ def container_manifest_lists_count
34
+ sql = <<-SQL
35
+ katello_repository_docker_manifest_lists rdml
36
+ INNER JOIN katello_repositories r ON rdml.repository_id = r.id
37
+ INNER JOIN katello_root_repositories rr ON r.root_id = rr.id
38
+ WHERE rr.content_type = 'docker'
39
+ SQL
40
+ sql_count(sql, column: 'DISTINCT rdml.docker_manifest_list_id')
41
+ end
42
+
43
+ def container_tags_count
44
+ sql = <<-SQL
45
+ katello_repository_docker_tags rdt
46
+ INNER JOIN katello_repositories r ON rdt.repository_id = r.id
47
+ INNER JOIN katello_root_repositories rr ON r.root_id = rr.id
48
+ WHERE rr.content_type = 'docker'
49
+ SQL
50
+ sql_count(sql)
51
+ end
52
+
53
+ def container_meta_tags_count
54
+ sql = <<-SQL
55
+ katello_repository_docker_meta_tags rdmt
56
+ INNER JOIN katello_repositories r ON rdmt.repository_id = r.id
57
+ INNER JOIN katello_root_repositories rr ON r.root_id = rr.id
58
+ WHERE rr.content_type = 'docker'
59
+ SQL
60
+ sql_count(sql)
61
+ end
62
+ end
63
+ end
@@ -1,54 +1,128 @@
1
- module Checks
2
- module Report
3
- class Content < ForemanMaintain::Report
4
- metadata do
5
- description 'Facts about Katello content'
6
- confine do
7
- feature(:katello)
8
- end
1
+ module Report
2
+ class Content < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report metrics related to Katello content'
5
+ confine do
6
+ feature(:katello)
9
7
  end
8
+ end
10
9
 
11
- def run
12
- data_field('custom_library_yum_repositories_count') { custom_library_yum_repositories }
13
- data_field('redhat_library_yum_repositories_count') { redhat_library_yum_repositories }
14
- data_field('library_debian_repositories_count') { library_repositories('deb') }
15
- data_field('library_container_repositories_count') { library_repositories('docker') }
16
- data_field('library_file_repositories_count') { library_repositories('file') }
17
- data_field('library_python_repositories_count') { library_repositories('python') }
18
- data_field('library_ansible_collection_repositories_count') do
19
- library_repositories('ansible_collection')
20
- end
21
- data_field('library_ostree_repositories_count') { library_repositories('ostree') }
22
- end
10
+ # rubocop:disable Metrics/AbcSize
11
+ # rubocop:disable Metrics/LineLength
12
+ def run
13
+ data_field('custom_library_yum_repositories_count') { custom_library_yum_repositories_count }
14
+ data_field('redhat_library_yum_repositories_count') { redhat_library_yum_repositories_count }
15
+ data_field('library_debian_repositories_count') { library_repositories_count('deb') }
16
+ data_field('library_container_repositories_count') { library_repositories_count('docker') }
17
+ data_field('library_file_repositories_count') { library_repositories_count('file') }
18
+ data_field('library_python_repositories_count') { library_repositories_count('python') }
19
+ data_field('library_ansible_collection_repositories_count') { library_repositories_count('ansible_collection') }
20
+ data_field('library_ostree_repositories_count') { library_repositories_count('ostree') }
21
+ data_field('redhat_repositories_enabled_count') { redhat_repositories_enabled_count }
22
+ data_field('redhat_file_repositories_enabled_count') { redhat_file_repositories_enabled_count }
23
+ merge_data('redhat_yum_repositories_architecture_count') { redhat_yum_repositories_architecture_count }
24
+ data_field('flatpak_remotes_count') { sql_count("katello_flatpak_remotes") }
25
+ data_field('flatpak_remote_repositories_count') { sql_count("katello_flatpak_remote_repositories") }
26
+ data_field('flatpak_images_count') { sql_count("katello_flatpak_remote_repository_manifests") }
27
+ data_field('rpms_count') { sql_count('katello_rpms') }
28
+ data_field('errata_count') { sql_count('katello_errata') }
29
+ data_field('module_streams_count') { sql_count('katello_module_streams') }
30
+ data_field('file_units_count') { sql_count('katello_files') }
31
+ data_field('ansible_collections_count') { sql_count('katello_ansible_collections') }
32
+ end
33
+ # rubocop:enable Metrics/AbcSize
34
+ # rubocop:enable Metrics/LineLength
23
35
 
24
- def custom_library_yum_repositories
25
- query_snippet =
26
- <<-SQL
27
- "katello_root_repositories"
28
- WHERE "katello_root_repositories"."id" NOT IN
29
- (SELECT "katello_root_repositories"."id" FROM "katello_root_repositories" INNER JOIN "katello_products"
30
- ON "katello_products"."id" = "katello_root_repositories"."product_id" INNER JOIN "katello_providers"
31
- ON "katello_providers"."id" = "katello_products"."provider_id" WHERE "katello_providers"."provider_type" = 'Red Hat')
32
- AND "katello_root_repositories"."content_type" = 'yum'
33
- SQL
34
- sql_count(query_snippet)
35
- end
36
+ private
36
37
 
37
- def redhat_library_yum_repositories
38
- query_snippet =
39
- <<-SQL
40
- "katello_root_repositories"
41
- INNER JOIN "katello_products" ON "katello_products"."id" = "katello_root_repositories"."product_id"
42
- INNER JOIN "katello_providers" ON "katello_providers"."id" = "katello_products"."provider_id"
43
- WHERE "katello_providers"."provider_type" = 'Red Hat'
44
- AND "katello_root_repositories"."content_type" = 'yum'
45
- SQL
46
- sql_count(query_snippet)
47
- end
38
+ def custom_library_yum_repositories_count
39
+ query_snippet =
40
+ <<-SQL
41
+ "katello_root_repositories"
42
+ WHERE "katello_root_repositories"."id" NOT IN
43
+ (SELECT "katello_root_repositories"."id" FROM "katello_root_repositories" INNER JOIN "katello_products"
44
+ ON "katello_products"."id" = "katello_root_repositories"."product_id" INNER JOIN "katello_providers"
45
+ ON "katello_providers"."id" = "katello_products"."provider_id" WHERE "katello_providers"."provider_type" = 'Red Hat')
46
+ AND "katello_root_repositories"."content_type" = 'yum'
47
+ SQL
48
+ sql_count(query_snippet)
49
+ end
48
50
 
49
- def library_repositories(content_type)
50
- sql_count("katello_root_repositories WHERE content_type = '#{content_type}'")
51
- end
51
+ def redhat_library_yum_repositories_count
52
+ query_snippet =
53
+ <<-SQL
54
+ "katello_root_repositories"
55
+ INNER JOIN "katello_products" ON "katello_products"."id" = "katello_root_repositories"."product_id"
56
+ INNER JOIN "katello_providers" ON "katello_providers"."id" = "katello_products"."provider_id"
57
+ WHERE "katello_providers"."provider_type" = 'Red Hat'
58
+ AND "katello_root_repositories"."content_type" = 'yum'
59
+ SQL
60
+ sql_count(query_snippet)
61
+ end
62
+
63
+ def library_repositories_count(content_type)
64
+ sql_count("katello_root_repositories WHERE content_type = '#{content_type}'")
65
+ end
66
+
67
+ def redhat_repositories_enabled_count
68
+ sql_as_count(
69
+ "COUNT(DISTINCT r.id)",
70
+ <<~SQL
71
+ katello_repositories r
72
+ INNER JOIN katello_root_repositories rr ON r.root_id = rr.id
73
+ INNER JOIN katello_products p ON rr.product_id = p.id
74
+ INNER JOIN katello_providers prov ON p.provider_id = prov.id
75
+ INNER JOIN katello_content_view_versions cvv ON r.content_view_version_id = cvv.id
76
+ INNER JOIN katello_content_views cv ON cvv.content_view_id = cv.id
77
+ INNER JOIN katello_environments e ON r.environment_id = e.id
78
+ WHERE prov.provider_type = 'Red Hat'
79
+ AND cv.default = true
80
+ AND e.library = true
81
+ AND r.library_instance_id IS NULL
82
+ SQL
83
+ )
84
+ end
85
+
86
+ def redhat_file_repositories_enabled_count
87
+ sql_count(
88
+ <<-SQL
89
+ katello_repositories r
90
+ INNER JOIN katello_root_repositories rr ON r.root_id = rr.id
91
+ INNER JOIN katello_products p ON rr.product_id = p.id
92
+ INNER JOIN katello_providers prov ON p.provider_id = prov.id
93
+ INNER JOIN katello_content_view_versions cvv ON r.content_view_version_id = cvv.id
94
+ INNER JOIN katello_content_views cv ON cvv.content_view_id = cv.id
95
+ INNER JOIN katello_environments e ON r.environment_id = e.id
96
+ WHERE prov.provider_type = 'Red Hat'
97
+ AND cv.default = true
98
+ AND e.library = true
99
+ AND r.library_instance_id IS NULL
100
+ AND rr.content_type = 'file'
101
+ SQL
102
+ )
103
+ end
104
+
105
+ def redhat_yum_repositories_architecture_count
106
+ query(
107
+ <<-SQL
108
+ SELECT rr.arch, COUNT(*) AS repo_count
109
+ FROM katello_repositories r
110
+ INNER JOIN katello_root_repositories rr ON r.root_id = rr.id
111
+ INNER JOIN katello_products p ON rr.product_id = p.id
112
+ INNER JOIN katello_providers prov ON p.provider_id = prov.id
113
+ INNER JOIN katello_content_view_versions cvv ON r.content_view_version_id = cvv.id
114
+ INNER JOIN katello_content_views cv ON cvv.content_view_id = cv.id
115
+ INNER JOIN katello_environments e ON r.environment_id = e.id
116
+ WHERE prov.provider_type = 'Red Hat'
117
+ AND cv.default = true
118
+ AND e.library = true
119
+ AND r.library_instance_id IS NULL
120
+ AND rr.content_type = 'yum'
121
+ AND rr.arch IS NOT NULL
122
+ GROUP BY rr.arch
123
+ ORDER BY rr.arch
124
+ SQL
125
+ ).to_h { |row| [row['arch'], row['repo_count'].to_i] }
52
126
  end
53
127
  end
54
128
  end
@@ -0,0 +1,111 @@
1
+ module Reports
2
+ class ContentExport < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report metrics related to Katello content exports'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ # rubocop:disable Metrics/LineLength
11
+ def run
12
+ data_field('export_repository_histories_count') { export_repository_histories_count }
13
+ data_field('export_content_view_version_histories_count') { export_content_view_version_histories_count }
14
+ data_field('export_library_histories_count') { export_library_histories_count }
15
+ data_field('export_complete_count') { export_complete_count }
16
+ data_field('export_incremental_count') { export_incremental_count }
17
+ data_field('export_format_syncable_count') { export_format_syncable_count }
18
+ data_field('export_format_importable_count') { export_format_importable_count }
19
+ end
20
+ # rubocop:enable Metrics/LineLength
21
+
22
+ private
23
+
24
+ def cv_count_generated_for
25
+ sql_count(<<-SQL)
26
+ information_schema.columns
27
+ WHERE table_name = 'katello_content_views'
28
+ AND column_name = 'generated_for'
29
+ SQL
30
+ end
31
+
32
+ def cvv_count_metadata
33
+ sql_count(<<-SQL)
34
+ information_schema.columns
35
+ WHERE table_name = 'katello_content_view_version_export_histories'
36
+ AND column_name = 'metadata'
37
+ SQL
38
+ end
39
+
40
+ def export_repository_histories_count
41
+ return 0 unless table_exists('katello_content_view_version_export_histories')
42
+ return 0 unless table_exists('katello_content_view_versions')
43
+ return 0 unless table_exists('katello_content_views')
44
+ return 0 unless cv_count_generated_for > 0
45
+
46
+ base_join = <<-SQL
47
+ katello_content_view_version_export_histories h
48
+ INNER JOIN katello_content_view_versions cvv ON h.content_view_version_id = cvv.id
49
+ INNER JOIN katello_content_views cv ON cvv.content_view_id = cv.id
50
+ SQL
51
+ sql_count(<<-SQL)
52
+ #{base_join}
53
+ WHERE cv.generated_for IN ('repository_export', 'repository_export_syncable')
54
+ SQL
55
+ end
56
+
57
+ def export_content_view_version_histories_count
58
+ return 0 unless table_exists('katello_content_view_version_export_histories')
59
+ sql_count('katello_content_view_version_export_histories')
60
+ end
61
+
62
+ def export_library_histories_count
63
+ return 0 unless table_exists('katello_content_view_version_export_histories')
64
+ return 0 unless table_exists('katello_content_view_versions')
65
+ return 0 unless table_exists('katello_content_views')
66
+ return 0 unless cv_count_generated_for > 0
67
+
68
+ base_join = <<-SQL
69
+ katello_content_view_version_export_histories h
70
+ INNER JOIN katello_content_view_versions cvv ON h.content_view_version_id = cvv.id
71
+ INNER JOIN katello_content_views cv ON cvv.content_view_id = cv.id
72
+ SQL
73
+ sql_count(<<-SQL)
74
+ #{base_join}
75
+ WHERE cv.generated_for IN ('library_export', 'library_export_syncable')
76
+ SQL
77
+ end
78
+
79
+ def export_complete_count
80
+ return 0 unless table_exists('katello_content_view_version_export_histories')
81
+ sql_count("katello_content_view_version_export_histories WHERE export_type = 'complete'")
82
+ end
83
+
84
+ def export_incremental_count
85
+ return 0 unless table_exists('katello_content_view_version_export_histories')
86
+ sql_count("katello_content_view_version_export_histories WHERE export_type = 'incremental'")
87
+ end
88
+
89
+ def export_format_syncable_count
90
+ return 0 unless table_exists('katello_content_view_version_export_histories')
91
+ return 0 unless cvv_count_metadata > 0
92
+
93
+ sql_count(<<-SQL)
94
+ katello_content_view_version_export_histories
95
+ WHERE metadata LIKE '%:format: syncable%'
96
+ OR metadata LIKE '%format: syncable%'
97
+ SQL
98
+ end
99
+
100
+ def export_format_importable_count
101
+ return 0 unless table_exists('katello_content_view_version_export_histories')
102
+ return 0 unless cvv_count_metadata > 0
103
+
104
+ sql_count(<<-SQL)
105
+ katello_content_view_version_export_histories
106
+ WHERE metadata LIKE '%:format: importable%'
107
+ OR metadata LIKE '%format: importable%'
108
+ SQL
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,66 @@
1
+ module Report
2
+ class ContentViews < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report metrics related to Katello content views'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ def run
11
+ data_field('content_views_count') { content_views_count }
12
+ data_field('content_views_rolling_count') { content_views_rolling_count }
13
+ data_field('content_views_rolling_using_library_count') do
14
+ rolling_content_views_using_library_count
15
+ end
16
+ data_field('content_views_rolling_using_lifecycle_environments_count') do
17
+ rolling_content_views_using_lifecycle_environments_count
18
+ end
19
+ data_field('content_views_composite_count') { content_views_composite_count }
20
+ end
21
+
22
+ private
23
+
24
+ def content_views_count
25
+ sql_count(<<-SQL)
26
+ katello_content_views
27
+ WHERE \"default\" = false
28
+ AND rolling = false
29
+ AND composite = false
30
+ AND generated_for = 0
31
+ SQL
32
+ end
33
+
34
+ def content_views_rolling_count
35
+ sql_count("katello_content_views WHERE rolling = true")
36
+ end
37
+
38
+ def rolling_content_views_using_library_count
39
+ sql_as_count(
40
+ "COUNT(DISTINCT cv.id)",
41
+ <<~SQL
42
+ katello_content_views AS cv
43
+ INNER JOIN katello_content_view_environments AS cve ON cv.id = cve.content_view_id
44
+ INNER JOIN katello_environments AS env ON cve.environment_id = env.id
45
+ WHERE cv.rolling = true AND env.library = true
46
+ SQL
47
+ )
48
+ end
49
+
50
+ def rolling_content_views_using_lifecycle_environments_count
51
+ sql_as_count(
52
+ "COUNT(DISTINCT cv.id)",
53
+ <<~SQL
54
+ katello_content_views AS cv
55
+ INNER JOIN katello_content_view_environments AS cve ON cv.id = cve.content_view_id
56
+ INNER JOIN katello_environments AS env ON cve.environment_id = env.id
57
+ WHERE cv.rolling = true AND env.library = false
58
+ SQL
59
+ )
60
+ end
61
+
62
+ def content_views_composite_count
63
+ sql_count("katello_content_views WHERE composite = true")
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,24 @@
1
+ module Reports
2
+ class Dashboard < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Facts about the Foreman dashboard'
5
+ end
6
+
7
+ def run
8
+ merge_data('dashboard_widgets_count') { dashboard_widgets_count_by_user }
9
+ end
10
+
11
+ private
12
+
13
+ def dashboard_widgets_count_by_user
14
+ return {} unless table_exists('widgets')
15
+ query(
16
+ <<-SQL
17
+ SELECT user_id, COUNT(*) AS widget_count
18
+ FROM widgets
19
+ GROUP BY user_id
20
+ SQL
21
+ ).to_h { |row| ["User ID " + row['user_id'].to_s, row['widget_count'].to_i] }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,56 @@
1
+ module Reports
2
+ class Hosts < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report metrics related to hosts'
5
+ end
6
+
7
+ def run
8
+ data_field('hosts_multi_cv_count') { hosts_multi_cv_count }
9
+ data_field('hosts_multi_cv_with_rolling_cv_count') { hosts_multi_cv_with_rolling_cv_count }
10
+ data_field('hosts_with_assigned_smart_proxy_count') { hosts_with_assigned_smart_proxy_count }
11
+ end
12
+
13
+ private
14
+
15
+ def hosts_multi_cv_count
16
+ sql_as_count(
17
+ "COUNT(*)",
18
+ <<~SQL
19
+ (
20
+ SELECT content_facet_id
21
+ FROM katello_content_view_environment_content_facets
22
+ GROUP BY content_facet_id
23
+ HAVING COUNT(*) > 1
24
+ ) AS multi_cve_hosts
25
+ SQL
26
+ )
27
+ end
28
+
29
+ def hosts_multi_cv_with_rolling_cv_count
30
+ sql_as_count(
31
+ "COUNT(DISTINCT cf.content_facet_id)",
32
+ <<~SQL
33
+ katello_content_view_environment_content_facets AS cf
34
+ INNER JOIN katello_content_view_environments AS cve ON cf.content_view_environment_id = cve.id
35
+ INNER JOIN katello_content_views AS cv ON cve.content_view_id = cv.id
36
+ WHERE cf.content_facet_id IN (
37
+ SELECT content_facet_id
38
+ FROM katello_content_view_environment_content_facets
39
+ GROUP BY content_facet_id
40
+ HAVING COUNT(*) > 1
41
+ )
42
+ AND cv.rolling = true
43
+ SQL
44
+ )
45
+ end
46
+
47
+ def hosts_with_assigned_smart_proxy_count
48
+ # Excludes smart proxy id 1 which is the server itself
49
+ sql_count(<<-SQL)
50
+ katello_content_facets
51
+ WHERE content_source_id IS NOT NULL
52
+ AND content_source_id != 1
53
+ SQL
54
+ end
55
+ end
56
+ end
@@ -9,7 +9,13 @@ module Reports
9
9
 
10
10
  def run
11
11
  merge_data('image_mode_hosts_by_os_count') { image_mode_hosts_by_os_count }
12
- data['remote_execution_transient_package_actions_count'] = transient_actions_count
12
+ data_field('remote_execution_transient_package_actions_count') { transient_actions_count }
13
+ data_field('host_installed_packages_transient_count') do
14
+ host_installed_packages_transient_count
15
+ end
16
+ data_field('host_installed_packages_persistent_count') do
17
+ host_installed_packages_persistent_count
18
+ end
13
19
  end
14
20
 
15
21
  # OS usage on image mode hosts
@@ -46,5 +52,13 @@ module Reports
46
52
 
47
53
  sql_count(sql, cte: cte)
48
54
  end
55
+
56
+ def host_installed_packages_transient_count
57
+ sql_count("katello_host_installed_packages WHERE persistence = 'transient'")
58
+ end
59
+
60
+ def host_installed_packages_persistent_count
61
+ sql_count("katello_host_installed_packages WHERE persistence = 'persistent'")
62
+ end
49
63
  end
50
64
  end
@@ -0,0 +1,59 @@
1
+ module Report
2
+ class LifecycleEnvironments < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report metrics related to Katello lifecycle environments'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ def run
11
+ data_field('lifecycle_environments_count') { lifecycle_environments_count }
12
+ data_field('lifecycle_environment_paths_count') { lifecycle_environment_paths_count }
13
+ data_field('registry_name_patterns_count') { registry_name_patterns_count }
14
+ end
15
+
16
+ private
17
+
18
+ def lifecycle_environments_count
19
+ sql_count("katello_environments WHERE library = false")
20
+ end
21
+
22
+ # rubocop:disable Metrics/MethodLength
23
+ def lifecycle_environment_paths_count
24
+ # A path is defined as a complete chain from the Library environment to a leaf environment
25
+ # (per organization). We count distinct leaf environments reachable from each org's Library.
26
+ env_paths_cte = <<~SQL
27
+ WITH RECURSIVE env_tree AS (
28
+ SELECT e.id, e.organization_id
29
+ FROM katello_environments e
30
+ WHERE e.library = true
31
+ UNION ALL
32
+ SELECT child.id, child.organization_id
33
+ FROM env_tree parent
34
+ INNER JOIN katello_environment_priors p ON p.prior_id = parent.id
35
+ INNER JOIN katello_environments child ON child.id = p.environment_id
36
+ ), leaf_envs AS (
37
+ SELECT t.id, t.organization_id
38
+ FROM env_tree t
39
+ INNER JOIN katello_environments e ON e.id = t.id
40
+ LEFT JOIN katello_environment_priors p ON p.prior_id = t.id
41
+ WHERE p.prior_id IS NULL
42
+ AND e.library = false
43
+ ), distinct_leaf_envs AS (
44
+ SELECT DISTINCT organization_id, id FROM leaf_envs
45
+ )
46
+ SQL
47
+ sql_count('distinct_leaf_envs', cte: env_paths_cte)
48
+ end
49
+ # rubocop:enable Metrics/MethodLength
50
+
51
+ def registry_name_patterns_count
52
+ sql_count(<<-SQL)
53
+ katello_environments
54
+ WHERE registry_name_pattern IS NOT NULL
55
+ AND registry_name_pattern != ''
56
+ SQL
57
+ end
58
+ end
59
+ end
@@ -5,7 +5,6 @@ module Reports
5
5
  end
6
6
 
7
7
  def run
8
- general_fields
9
8
  rbac_fields
10
9
  settings_fields
11
10
  bookmarks_fields
@@ -35,14 +34,6 @@ module Reports
35
34
  data_field('user_groups_count') { sql_count('usergroups') }
36
35
  end
37
36
 
38
- def general_fields
39
- data_field('smart_proxies_count') { sql_count('smart_proxies') }
40
- merge_data('smart_proxies_creation_date') do
41
- query("select id, created_at from smart_proxies").
42
- to_h { |row| [row['id'], row['created_at']] }
43
- end
44
- end
45
-
46
37
  def rbac_fields
47
38
  data_field('total_users_count') { sql_count('users') }
48
39
  data_field('non_admin_users_count') { sql_count('users where admin = false') }
@@ -0,0 +1,116 @@
1
+ module Reports
2
+ class SmartProxies < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report smart proxy metrics'
5
+ end
6
+
7
+ def run
8
+ data_field('smart_proxies_count') { smart_proxies_count }
9
+ merge_data('smart_proxies_creation_date') { smart_proxies_creation_date }
10
+ data_field('smart_proxies_with_assigned_hosts_count') do
11
+ smart_proxies_with_assigned_hosts_count
12
+ end
13
+ data_field('smart_proxies_assigned_hosts_count_min') do
14
+ smart_proxies_assigned_hosts_count_min
15
+ end
16
+ data_field('smart_proxies_assigned_hosts_count_median') do
17
+ smart_proxies_assigned_hosts_count_median
18
+ end
19
+ data_field('smart_proxies_assigned_hosts_count_average') do
20
+ smart_proxies_assigned_hosts_count_average
21
+ end
22
+ data_field('smart_proxies_assigned_hosts_count_max') do
23
+ smart_proxies_assigned_hosts_count_max
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def smart_proxies_count
30
+ # Exclude server smart proxy
31
+ sql_count('smart_proxies WHERE id != 1')
32
+ end
33
+
34
+ def smart_proxies_creation_date
35
+ query("select id, created_at from smart_proxies").to_h do |row|
36
+ [row['id'], row['created_at']]
37
+ end
38
+ end
39
+
40
+ def smart_proxies_with_assigned_hosts_count
41
+ # Exclude server smart proxy
42
+ sql_count(
43
+ <<-SQL
44
+ (SELECT DISTINCT content_source_id
45
+ FROM katello_content_facets
46
+ WHERE content_source_id IS NOT NULL AND content_source_id != 1
47
+ ) AS smart_proxies_with_hosts
48
+ SQL
49
+ )
50
+ end
51
+
52
+ def smart_proxies_assigned_hosts_count_min
53
+ # Exclude server smart proxy
54
+ result = query(
55
+ <<-SQL
56
+ SELECT MIN(host_count) as min_count
57
+ FROM (
58
+ SELECT COUNT(*) as host_count
59
+ FROM katello_content_facets
60
+ WHERE content_source_id IS NOT NULL AND content_source_id != 1
61
+ GROUP BY content_source_id
62
+ ) AS counts
63
+ SQL
64
+ ).first
65
+ result ? result['min_count'].to_i : 0
66
+ end
67
+
68
+ def smart_proxies_assigned_hosts_count_median
69
+ # Exclude server smart proxy
70
+ result = query(
71
+ <<-SQL
72
+ SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY host_count) as median_count
73
+ FROM (
74
+ SELECT COUNT(*) as host_count
75
+ FROM katello_content_facets
76
+ WHERE content_source_id IS NOT NULL AND content_source_id != 1
77
+ GROUP BY content_source_id
78
+ ) AS counts
79
+ SQL
80
+ ).first
81
+ result ? result['median_count'].to_f : 0.0
82
+ end
83
+
84
+ def smart_proxies_assigned_hosts_count_average
85
+ # Exclude server smart proxy
86
+ result = query(
87
+ <<-SQL
88
+ SELECT AVG(host_count) as avg_count
89
+ FROM (
90
+ SELECT COUNT(*) as host_count
91
+ FROM katello_content_facets
92
+ WHERE content_source_id IS NOT NULL AND content_source_id != 1
93
+ GROUP BY content_source_id
94
+ ) AS counts
95
+ SQL
96
+ ).first
97
+ result ? result['avg_count'].to_f : 0.0
98
+ end
99
+
100
+ def smart_proxies_assigned_hosts_count_max
101
+ # Exclude server smart proxy
102
+ result = query(
103
+ <<-SQL
104
+ SELECT MAX(host_count) as max_count
105
+ FROM (
106
+ SELECT COUNT(*) as host_count
107
+ FROM katello_content_facets
108
+ WHERE content_source_id IS NOT NULL AND content_source_id != 1
109
+ GROUP BY content_source_id
110
+ ) AS counts
111
+ SQL
112
+ ).first
113
+ result ? result['max_count'].to_i : 0
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,40 @@
1
+ module Reports
2
+ class SmartProxiesContent < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report smart proxy metrics related to Katello'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ def run
11
+ data_field('smart_proxies_syncing_library_count') { smart_proxies_syncing_library_count }
12
+ data_field('smart_proxies_syncing_multiple_lifecycle_environments_count') do
13
+ smart_proxies_syncing_multiple_lifecycle_environments_count
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def smart_proxies_syncing_library_count
20
+ # Exclude server smart proxy
21
+ sql_count(<<-SQL, column: 'DISTINCT sp.id')
22
+ smart_proxies sp
23
+ INNER JOIN katello_capsule_lifecycle_environments kcle ON sp.id = kcle.capsule_id
24
+ INNER JOIN katello_environments ke ON kcle.lifecycle_environment_id = ke.id
25
+ WHERE ke.library = true AND sp.id != 1
26
+ SQL
27
+ end
28
+
29
+ def smart_proxies_syncing_multiple_lifecycle_environments_count
30
+ # Exclude server smart proxy
31
+ sql_count(<<-SQL)
32
+ (SELECT capsule_id, COUNT(DISTINCT lifecycle_environment_id) as env_count
33
+ FROM katello_capsule_lifecycle_environments
34
+ WHERE capsule_id != 1
35
+ GROUP BY capsule_id
36
+ HAVING COUNT(DISTINCT lifecycle_environment_id) > 1) multi_env_capsules
37
+ SQL
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,33 @@
1
+ module Report
2
+ class SyncPlans < ForemanMaintain::Report
3
+ metadata do
4
+ description 'Report metrics related to Katello sync plans'
5
+ confine do
6
+ feature(:katello)
7
+ end
8
+ end
9
+
10
+ def run
11
+ data_field('sync_plans_used') { sync_plans_used }
12
+ data_field('sync_plans_count') { sync_plans_count }
13
+ end
14
+
15
+ private
16
+
17
+ def sync_plans_used
18
+ if table_exists('katello_sync_plans')
19
+ sql_count('katello_sync_plans') > 0
20
+ else
21
+ false
22
+ end
23
+ end
24
+
25
+ def sync_plans_count
26
+ if table_exists('katello_sync_plans')
27
+ sql_count('katello_sync_plans')
28
+ else
29
+ 0
30
+ end
31
+ end
32
+ end
33
+ end
@@ -9,7 +9,7 @@ module ForemanMaintain
9
9
  # description can be used too
10
10
  report_data = scenario.steps.map(&:data).compact.reduce(&:merge).
11
11
  transform_keys(&:to_s).sort.to_h
12
- report_data['version'] = 2
12
+ report_data['version'] = 3
13
13
  report_data
14
14
  end
15
15
 
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.14.2'.freeze
2
+ VERSION = '1.14.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.2
4
+ version: 1.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
@@ -336,13 +336,19 @@ files:
336
336
  - definitions/procedures/sync_plans/enable.rb
337
337
  - definitions/procedures/timer/start.rb
338
338
  - definitions/procedures/timer/stop.rb
339
+ - definitions/reports/activation_keys.rb
339
340
  - definitions/reports/alternate_content_sources.rb
340
341
  - definitions/reports/bookmarks.rb
341
342
  - definitions/reports/compliance.rb
343
+ - definitions/reports/container_metadata.rb
342
344
  - definitions/reports/content.rb
345
+ - definitions/reports/content_export.rb
346
+ - definitions/reports/content_views.rb
347
+ - definitions/reports/dashboard.rb
343
348
  - definitions/reports/disconnected_environment.rb
344
349
  - definitions/reports/external_auth_source.rb
345
350
  - definitions/reports/grouping.rb
351
+ - definitions/reports/hosts.rb
346
352
  - definitions/reports/image_mode_hosts.rb
347
353
  - definitions/reports/instance.rb
348
354
  - definitions/reports/inventory.rb
@@ -350,6 +356,7 @@ files:
350
356
  - definitions/reports/kerberos.rb
351
357
  - definitions/reports/lab_features.rb
352
358
  - definitions/reports/ldap_auth_source.rb
359
+ - definitions/reports/lifecycle_environments.rb
353
360
  - definitions/reports/networking.rb
354
361
  - definitions/reports/oidc_usage.rb
355
362
  - definitions/reports/personal_access_token.rb
@@ -359,6 +366,9 @@ files:
359
366
  - definitions/reports/recurring_logics.rb
360
367
  - definitions/reports/rh_cloud.rb
361
368
  - definitions/reports/selinux.rb
369
+ - definitions/reports/smart_proxies.rb
370
+ - definitions/reports/smart_proxies_content.rb
371
+ - definitions/reports/sync_plans.rb
362
372
  - definitions/reports/template
363
373
  - definitions/reports/virt_who.rb
364
374
  - definitions/reports/vmware.rb
@@ -490,7 +500,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
490
500
  - !ruby/object:Gem::Version
491
501
  version: '0'
492
502
  requirements: []
493
- rubygems_version: 4.0.3
503
+ rubygems_version: 4.0.6
494
504
  specification_version: 4
495
505
  summary: Foreman maintenance tool belt
496
506
  test_files: []