8.7. 创建报告模板以监控权利
您可以使用报告模板返回具有特定订阅的主机列表,并显示这些主机的内核数。
有关编写模板的更多信息,请参阅 附录 A, 模板编写参考。
流程
- 在 Satellite Web UI 中,导航到 Monitor > Report Templates,然后点 Create Template。
可选:在 Editor 字段中,使用
<%# > tags添加注释,其中包含稍后引用可能有用的信息。例如:<%# name: Entitlements snippet: false model: ReportTemplate require: - plugin: katello version: 3.14.0 -%>
使用
load_hosts ()宏添加一行,并使用以下方法和变量填充宏:<%- load_hosts(includes: [:lifecycle_environment, :operatingsystem, :architecture, :content_view, :organization, :reported_data, :subscription_facet, :pools => [:subscription]]).each_record do |host| -%>
要查看您可以使用的变量列表,请点 Help 选项卡和 Safe 模式 方法和变量 表中,找到 Host::Managed 行。
使用
每个方法添加带有host.pools变量的行,例如:<%- host.pools.each do |pool| -%>
使用
report_row ()方法添加一行,以创建报告并添加您要目标的变量作为报告的一部分:<%- report_row( 'Name': host.name, 'Organization': host.organization, 'Lifecycle Environment': host.lifecycle_environment, 'Content View': host.content_view, 'Host Collections': host.host_collections, 'Virtual': host.virtual, 'Guest of Host': host.hypervisor_host, 'OS': host.operatingsystem, 'Arch': host.architecture, 'Sockets': host.sockets, 'RAM': host.ram, 'Cores': host.cores, 'SLA': host_sla(host), 'Products': host_products(host), 'Subscription Name': sub_name(pool), 'Subscription Type': pool.type, 'Subscription Quantity': pool.quantity, 'Subscription SKU': sub_sku(pool), 'Subscription Contract': pool.contract_number, 'Subscription Account': pool.account_number, 'Subscription Start': pool.start_date, 'Subscription End': pool.end_date, 'Subscription Guest': registered_through(host) ) -%>在模板中添加 end 语句:
<%- end -%> <%- end -%>
要生成报告,您必须添加 <%= report_render -%> 宏:
<%= report_render -%>
- 单击 Submit 以保存模板。