Red Hat Satellite is a system management solution that simplifies the deployment, scaling, and management of Red Hat infrastructure in physical, virtual, and cloud environments. The satellite allows users to set up and update systems to ensure their safe and efficient operation in accordance with various standards. By automating most of the tasks associated with maintaining system health, the Satellite helps organizations improve efficiency, reduce operating costs, and more readily respond to strategic business needs.

Although you can perform basic administrative tasks using the Red Hat services included in a Red Hat Enterprise Linux subscription, the Red Hat Satellite adds extensive management capabilities to the entire life cycle.
Among such opportunities:
')
- Installing patches;
- Subscription management;
- Initialization;
- Configuration management.
With one console, you can manage thousands of systems as easily as one, which increases availability, reliability and provides opportunities for system auditing.
And now we have a new Red Hat Satellite 6.5!One of the cool things that appeared in Red Hat Satellite 6.5 is the new report engine.
The Satellite Server often serves as the center where all information about Red Hat corporate systems flows to, and this latest engine allows you to create and export reports containing information about Satellite client hosts, software subscriptions, as well as software defects that need to be fixed (errata) and etc. Programmed reports in the embedded language Ruby (ERB).
Satellite 6.5 comes bundled with ready-made reports, and the engine allows users to customize these reports or create their own. Satellite 6.5's built-in reports are generated in CSV format, but in this post we will show how to generate reports in HTML format.
Satellite 6.5 Embedded Reports
Satellite 6.5 includes four embedded reports:
- Applicable errata - a list of software defects (errata) to be eliminated on content hosts (optionally filtered by hosts or defects);
- Host statuses - a report on the status of Satellite hosts (optionally filtered by hosts);
- Registered hosts - information on Satellite hosts: IP address, OS version, software subscriptions (optionally filtered by hosts);
- Subscriptions - information about software subscriptions: total number of subscriptions, number of free, SKU-codes (optionally filtered by subscription parameters).
To generate a report, open the
Monitor menu, select
Report Templates, and click the Generate button to the right of the desired report. Leave the filter field empty to include all data in the report, or enter something there to limit the results. For example, if only RHEL 8 hosts should be displayed in the Registered Hosts report, then specify the filter
os = RedHat and os_major = 8 , as shown in the screenshot below:
After generating the report, you can download it and open it in a LibreOffice Calc type spreadsheet that imports data from CSV and spreads it out in columns, for example, as the
Applicable errata report on the screen below:
Please note that the
Default option is enabled in the properties of embedded reports, so they are automatically added to all new organizations and locations that you create in the Satellite.
Customization of embedded reports
Let's analyze customization using the example of the embedded report
Subscriptions . By default, this report reflects the total number of subscriptions (1), as well as the number of available, that is, free subscriptions (2). We will add another column with the number of subscriptions used, which is defined as (1) - (2). For example, if we have 50 RHEL subscriptions in total and 10 of them are free, then 40 subscriptions are used.
Since the editing of embedded reports is blocked and it is not recommended to change them, you will have to clone the embedded report, give it a new name and then modify this clone copy.
So, if we want to modify the
Subscriptions report, we first need to clone it. Therefore, open the
Monitor menu, select
Report Templates and select
Clone from the drop-down menu to the right of the
Subscriptions template. Then enter the name of the clone report (let's call it
Custom Subscriptions ) and add the line
'Used' between the
Available and
Quantity lines
: pool.quantity - pool.available, - note the comma at the end of the line. Here is how it looks in the screenshot:
Then click the
Submit button, which brings us back to the
Report Templates page. There we click the
Generate button to the right of the
Custom Subscriptions report that we just created. The Subscriptions filter field is left blank and click
Submit . After that, a report is created and loaded, in which there is a
Used column added by us.
Help for built-in Ruby language is located on the
Help tab in the report editing window. It contains an overview of the syntax, as well as available variables and methods.
Create your own report
Now let's take a look at creating our own reports on the example of a report on the Ansible roles assigned to hosts in the Satellite. Open the
Monitor menu, click
Report Templates, and then click the
Create Template button. Let's call our report
Ansible Roles Report and insert the following ERB code into it:
<%# name: Ansible Roles Report snippet: false template_inputs: - name: hosts required: false input_type: user description: Limit the report only on hosts found by this search query. Keep empty for report on all available hosts. advanced: false model: ReportTemplate -%> <% load_hosts(search: input('hosts'), includes: :ansible_roles).each_record do |host| -%> <% report_row({ 'Name': host.name, 'All Ansible Roles': host.all_ansible_roles }) -%> <% end -%> <%= report_render -%>
This code generates a report on the host, displaying for them the attribute "all_ansible_roles".
Then go to the
Inputs tab and click the
+ Add Input button. We say that name is equal to
hosts , and the description type is
Filter by hosts (optional) . Then click
Submit and then click the
Generate button to the right of the report you just created. Then you can set a host filter or immediately click
Submit to generate a report on all hosts. The generated report will look like this in LibreOffice Calc:
Creating HTML reports
Satellite Report Engine allows you to generate reports not only in CSV format. As an example, we will create our own report based on the Host
Statuses embedded report, but only in the form of an HTML table with cell color coding based on status. To do this, we clone
Host Statuses , and then replace its ERB code with the following:
<!DOCTYPE html> <html> <head> <title>Host Statuses</title> <style> th { background-color: black; color: white; } td.green { background-color:#92d400; color:black; } td.yellow { background-color:#f0ab00; color:black; } td.red { background-color:#CC0000; color:black; } table,th,td { border-collapse:collapse; border: 1px solid black; } </style> </head> <body> <table> <tr> <th> Hostname </th> <th> Status </th> <% load_hosts(search: input('hosts'), includes: :host_statuses).each_record do |host| -%> <% all_host_statuses_hash(host).each do |key, value| -%> <th> <%= key %> </th> <% end -%> <% break -%> <% end -%> </tr> <%- load_hosts(search: input('hosts'), includes: :host_statuses).each_record do |host| -%> <tr> <td> <%= host.name %> </td> <% if host.global_status == 0 -%> <td class="green"> OK </td> <% elsif host.global_status == 1 -%> <td class="yellow"> Warning </td> <% else -%> <td class="red"> Error (<%= host.global_status %>) </td> <% end -%> <% all_host_statuses_hash(host).each do |key, value| -%> <% if value == 0 -%> <td class="green"> OK </td> <% elsif value == 1 -%> <td class="yellow"> Warning </td> <% else -%> <td class="red"> Error (<%= value %>) </td> <% end -%> <% end -%> </tr> <% end -%> </table> </body> </html>
This report generates HTML that will look like this in the browser:
Running reports from the command line
To launch a report from the command line, use the
hammer command, and the cron utility allows you to automate this process.
Use the hammer report-template generate —name "" command, for example:
# hammer report-template generate —name "Host statuses HTML"
The content of the report will be displayed on the console. Information can be redirected to a file, after which you can configure cron to launch a shell script to generate a report and send it by e-mail. The HTML format is perfectly displayed in email clients, which allows organizing regular delivery of reports to interested parties in an easy-to-read form.
Thus, the report engine in Satellite 6.5 is a powerful tool for exporting important data available to companies in the Satellite. It is very flexible and allows you to use both embedded reports and their modified versions. In addition, users can create their own reports from scratch. Details about the Satellite Reporting Engine are available on our YouTube video.
July 9 at 11:00 Moscow time, do not miss the webinar about the new version of Red Hat Enterprise Linux 8Our speaker is Aram Kananov, Manager of Platform Development and Management Systems, Red Hat in Europe, the Middle East and Africa. Aram's work in Red Hat includes a comprehensive analysis of the market, industry and competitors, as well as product positioning and marketing for the business unit of the platforms, which includes managing the entire life cycle of the entire product from deployment to end of use.