Skip to content

Commit 4e5573a

Browse files
committed
update InventoryReport
1 parent c2f75b1 commit 4e5573a

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed

schema/reportdb/common/views/InventoryReport.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--
2-
-- Copyright (c) 2022 SUSE LLC
2+
-- Copyright (c) 2022--2025 SUSE LLC
33
--
44
-- This software is licensed to you under the GNU General Public License,
55
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
@@ -41,6 +41,7 @@ CREATE OR REPLACE VIEW InventoryReport AS
4141
, System.registered_by
4242
, System.registration_time
4343
, System.last_checkin_time
44+
, System.last_boot_time
4445
, System.kernel_version
4546
, System.organization
4647
, System.architecture
@@ -58,6 +59,8 @@ CREATE OR REPLACE VIEW InventoryReport AS
5859
, Channels.software_channels
5960
, COALESCE(SystemOutdated.packages_out_of_date, (0)::bigint) AS packages_out_of_date
6061
, COALESCE(SystemOutdated.errata_out_of_date, (0)::bigint) AS errata_out_of_date
62+
, COALESCE(SystemOutdated.extra_pkg_count, (0)::bigint) AS extra_pkg_count
63+
, SystemOutdated.status AS status
6164
, System.synced_date
6265
FROM System
6366
LEFT JOIN SystemVirtualdata ON ( System.mgm_id = SystemVirtualdata.mgm_id AND System.system_id = SystemVirtualdata.virtual_system_id )

schema/reportdb/postgres/docs/views/InventoryReport.pre

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ COMMENT ON COLUMN InventoryReport.registration_time
3030
IS 'When this system was onboarded';
3131
COMMENT ON COLUMN InventoryReport.last_checkin_time
3232
IS 'When this system was visible and reachable last time';
33+
COMMENT ON COLUMN InventoryReport.last_boot_time
34+
IS 'When this system was last time booted';
3335
COMMENT ON COLUMN InventoryReport.kernel_version
3436
IS 'The version of the kernel installed on this system';
3537
COMMENT ON COLUMN InventoryReport.organization
@@ -64,5 +66,9 @@ COMMENT ON COLUMN InventoryReport.packages_out_of_date
6466
IS 'The number of packages installed on the system that can be updated';
6567
COMMENT ON COLUMN InventoryReport.errata_out_of_date
6668
IS 'The number of patches that can be applied to the system';
69+
COMMENT ON COLUMN InventoryReport.extra_pkg_count
70+
IS 'The number of packages which do not exist in a channel assigned to this system';
71+
COMMENT ON COLUMN InventoryReport.status
72+
IS 'The status of this system: unentitled, awol, kickstarting, reboot needed, updates scheduled, actions scheduled, up2date, critical or updates';
6773
COMMENT ON COLUMN InventoryReport.synced_date
6874
IS 'The timestamp of when this data was last refreshed.';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
--
2+
-- Copyright (c) 2022--2025 SUSE LLC
3+
--
4+
-- This software is licensed to you under the GNU General Public License,
5+
-- version 2 (GPLv2). There is NO WARRANTY for this software, express or
6+
-- implied, including the implied warranties of MERCHANTABILITY or FITNESS
7+
-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
8+
-- along with this software; if not, see
9+
-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
10+
--
11+
12+
DROP VIEW IF EXISTS InventoryReport;
13+
14+
CREATE OR REPLACE VIEW InventoryReport AS
15+
-- CTEs to group all one to many relationship joining values with ; as separator
16+
WITH Entitlements AS (
17+
SELECT mgm_id, system_id, string_agg(system_group_id || ' - ' || name, ';') AS entitlements
18+
FROM systementitlement
19+
GROUP BY mgm_id, system_id
20+
), Groups AS (
21+
SELECT mgm_id, system_id, string_agg(system_group_id || ' - ' || group_name, ';') AS system_groups
22+
FROM SystemGroupMember
23+
GROUP BY mgm_id, system_id
24+
), ConfigChannels AS (
25+
SELECT mgm_id, system_id, string_agg(config_channel_id || ' - ' || name, ';') AS configuration_channels
26+
FROM SystemConfigChannel
27+
GROUP BY mgm_id, system_id
28+
), Channels AS (
29+
SELECT mgm_id, system_id, string_agg(channel_id || ' - ' || name, ';') AS software_channels
30+
FROM SystemChannel
31+
GROUP BY mgm_id, system_id
32+
), V6Addresses AS (
33+
SELECT mgm_id, system_id, interface_id, string_agg(address || ' (' || scope || ')', ';') AS ip6_addresses
34+
FROM SystemNetAddressV6
35+
GROUP BY mgm_id, system_id, interface_id
36+
)
37+
SELECT System.mgm_id
38+
, System.system_id
39+
, System.profile_name
40+
, System.hostname
41+
, System.minion_id
42+
, System.machine_id
43+
, System.registered_by
44+
, System.registration_time
45+
, System.last_checkin_time
46+
, System.last_boot_time
47+
, System.kernel_version
48+
, System.organization
49+
, System.architecture
50+
, System.hardware
51+
, SystemNetInterface.name AS primary_interface
52+
, SystemNetInterface.hardware_address AS hardware_address
53+
, SystemNetAddressV4.address AS ip_address
54+
, V6Addresses.ip6_addresses
55+
, ConfigChannels.configuration_channels
56+
, Entitlements.entitlements
57+
, Groups.system_groups
58+
, SystemVirtualdata.host_system_id AS virtual_host
59+
, SystemVirtualdata.virtual_system_id IS NULL AS is_virtualized
60+
, SystemVirtualdata.instance_type_name AS virt_type
61+
, Channels.software_channels
62+
, COALESCE(SystemOutdated.packages_out_of_date, (0)::bigint) AS packages_out_of_date
63+
, COALESCE(SystemOutdated.errata_out_of_date, (0)::bigint) AS errata_out_of_date
64+
, COALESCE(SystemOutdated.extra_pkg_count, (0)::bigint) AS extra_pkg_count
65+
, SystemOutdated.status AS status
66+
, System.synced_date
67+
FROM System
68+
LEFT JOIN SystemVirtualdata ON ( System.mgm_id = SystemVirtualdata.mgm_id AND System.system_id = SystemVirtualdata.virtual_system_id )
69+
LEFT JOIN SystemOutdated ON ( System.mgm_id = SystemOutdated.mgm_id AND System.system_id = SystemOutdated.system_id )
70+
LEFT JOIN SystemNetInterface ON (System.mgm_id = SystemNetInterface.mgm_id AND System.system_id = SystemNetInterface.system_id AND SystemNetInterface.primary_interface)
71+
LEFT JOIN SystemNetAddressV4 ON (System.mgm_id = SystemNetAddressV4.mgm_id AND System.system_id = SystemNetAddressV4.system_id AND SystemNetInterface.interface_id = SystemNetAddressV4.interface_id)
72+
LEFT JOIN V6Addresses ON (System.mgm_id = V6Addresses.mgm_id AND System.system_id = V6Addresses.system_id AND SystemNetInterface.interface_id = V6Addresses.interface_id)
73+
LEFT JOIN Entitlements ON ( System.mgm_id = entitlements.mgm_id AND System.system_id = entitlements.system_id )
74+
LEFT JOIN Groups ON ( System.mgm_id = Groups.mgm_id AND System.system_id = Groups.system_id )
75+
LEFT JOIN ConfigChannels ON ( System.mgm_id = ConfigChannels.mgm_id AND System.system_id = ConfigChannels.system_id )
76+
LEFT JOIN Channels ON ( System.mgm_id = Channels.mgm_id AND System.system_id = Channels.system_id )
77+
ORDER BY System.mgm_id, System.system_id
78+
;

0 commit comments

Comments
 (0)