Questo contenuto non è disponibile nella lingua selezionata.
Chapter 12. Using report templates to monitor hosts
You can use report templates to query Satellite data to obtain information about, for example, host status, registered hosts, applicable errata, applied errata, and user activity. You can use the report templates that ship with Satellite or write your own custom report templates to suit your requirements.
12.1. Generating host monitoring reports by using Satellite web UI Copia collegamentoCollegamento copiato negli appunti!
To view the report templates in the Satellite web UI, navigate to Monitor > Reports > Report Templates. You can also schedule reports from the Satellite web UI.
Procedure
- In the Satellite web UI, navigate to Monitor > Reports > Report Templates. For example, the Host – Installed Products template generates a report with installed product information along with other metrics, including system purpose attributes.
- To the right of the report template that you want to use, click Generate.
- Optional: To schedule a report, to the right of the Generate at field, click the icon to select the date and time you want to generate the report at.
- Optional: To send a report to an e-mail address, select the Send report via e-mail checkbox, and in the Deliver to e-mail addresses field, enter the required e-mail address.
- Optional: Apply search query filters. To view all available results, do not populate the filter field with any values.
- Click Submit. A CSV file that contains the report is downloaded. If you have selected the Send report via e-mail checkbox, the host monitoring report is sent to your e-mail address.
12.2. Generating host monitoring reports by using Hammer CLI Copia collegamentoCollegamento copiato negli appunti!
To view the report templates, use the hammer report-template command. To schedule reports, configure a cron job.
Procedure
List all available report templates:
$ hammer report-template listGenerate a report:
$ hammer report-template generate --id My_Template_IDThis command waits until the report fully generates before completing. If you want to generate the report as a background task, you can use the
hammer report-template schedulecommand.
Example 12.1. Generating a report based on the Subscription - General template
To generate the Subscription - General report, add the Days from Now option to specify the latest expiration time of general subscriptions.
To show all subscriptions:
$ hammer report-template generate \ --inputs "Days from Now=no limit" \ --name "Subscription - General Report"To show all subscriptions that are going to expire within 60 days:
$ hammer report-template generate \ --inputs "Days from Now=60" \ --name "Subscription - General Report"
12.3. Creating a report template Copia collegamentoCollegamento copiato negli appunti!
In Satellite, you can create a report template and customize the template to suit your requirements. You can import existing report templates and further customize them with snippets and template macros.
Report templates use Embedded Ruby (ERB) syntax. To view information about working with ERB syntax and macros, in the Satellite web UI, navigate to Monitor > Reports > Report Templates, and click Create Template, and then click the Help tab.
When you create a report template in Satellite, safe mode is enabled by default.
Procedure
- In the Satellite web UI, navigate to Monitor > Reports > Report Templates.
- Click Create Template.
- In the Name field, enter a unique name for your report template.
- If you want the template to be available to all locations and organizations, select Default.
- Create the template directly in the template editor or import a template from a text file by clicking Import. For more information about importing templates, see Section 12.7, “Importing report templates”.
- Optional: In the Audit Comment field, you can add any useful information about this template.
-
Click the Input tab, and in the Name field, enter a name for the input that you can reference in the template in the following format:
input('name'). Note that you must save the template before you can reference this input value in the template body. - Select whether the input value is mandatory. If the input value is mandatory, select the Required checkbox.
- From the Value Type list, select the type of input value that the user must input.
- Optional: If you want to use facts for template input, select the Advanced checkbox.
- Optional: In the Options field, define the options that the user can select from. If this field remains undefined, the users receive a free-text field in which they can enter the value they want.
- Optional: In the Default field, enter a value, for example, a host name, that you want to set as the default template input.
- Optional: In the Description field, you can enter information that you want to display as inline help about the input when you generate the report.
- Optional: Click the Type tab, and select whether this template is a snippet to be included in other templates.
- Click the Location tab and add the locations where you want to use the template.
- Click the Organizations tab and add the organizations where you want to use the template.
- Click Submit to save your changes.
Additional resources
12.4. Exporting report templates by using Satellite web UI Copia collegamentoCollegamento copiato negli appunti!
You can export report templates that you create in Satellite from Satellite web UI.
Procedure
- In the Satellite web UI, navigate to Monitor > Reports > Report Templates.
- Locate the template that you want to export, and from the list in the Actions column, select Export.
- Repeat this action for every report template that you want to download.
12.5. Exporting report templates by using Hammer CLI Copia collegamentoCollegamento copiato negli appunti!
You can export report templates that you create in Satellite by using Hammer CLI.
Procedure
To view the report templates available for export, enter the following command:
$ hammer report-template listNote the template ID of the template that you want to export in the output of this command.
To export a report template, enter the following command:
$ hammer report-template dump --id My_Template_ID > example_export.erb
12.6. Exporting report templates using the Satellite API Copia collegamentoCollegamento copiato negli appunti!
You can use the Satellite report_templates API to export report templates from Satellite.
Procedure
Use the following request to retrieve a list of available report templates. For example:
$ curl \ --insecure \ --user My_User_Name:My_Password \ --request GET \ --config https://satellite.example.com/api/report_templates \ | json_reformatIn this example, the
json_reformattool is used to format the JSON output.Example response:
{ "total": 6, "subtotal": 6, "page": 1, "per_page": 20, "search": null, "sort": { "by": null, "order": null }, "results": [ { "created_at": "2019-11-20 17:49:52 UTC", "updated_at": "2019-11-20 17:49:52 UTC", "name": "Applicable errata", "id": 112 }, { "created_at": "2019-11-20 17:49:52 UTC", "updated_at": "2019-11-20 17:49:52 UTC", "name": "Applied Errata", "id": 113 }, { "created_at": "2019-11-30 16:15:24 UTC", "updated_at": "2019-11-30 16:15:24 UTC", "name": "Hosts - complete list", "id": 158 }, { "created_at": "2019-11-20 17:49:52 UTC", "updated_at": "2019-11-20 17:49:52 UTC", "name": "Host statuses", "id": 114 }, { "created_at": "2019-11-20 17:49:52 UTC", "updated_at": "2019-11-20 17:49:52 UTC", "name": "Registered hosts", "id": 115 }, { "created_at": "2019-11-20 17:49:52 UTC", "updated_at": "2019-11-20 17:49:52 UTC", "name": "Subscriptions", "id": 116 } ] }Note the
idof the template that you want to export, and use the following request to export the template.Example request:
$ curl --insecure --output /tmp/_Example_Export_Template.erb_ \ --user admin:password --request GET --config \ https://satellite.example.com/api/report_templates/My_Template_ID/exportNote that
158is an example ID of the template to export.In this example, the exported template is redirected to
host_complete_list.erb.
12.7. Importing report templates Copia collegamentoCollegamento copiato negli appunti!
You can import a report template into the body of a new template that you want to create. Note that using the Satellite web UI, you can only import templates individually.
Prerequisites
- You must have exported templates from Satellite to import them to use in new templates. For more information see Section 12.4, “Exporting report templates by using Satellite web UI” and Section 12.5, “Exporting report templates by using Hammer CLI”.
Procedure
- In the Satellite web UI, navigate to Monitor > Reports > Report Templates.
- In the upper right of the Report Templates window, click Create Template.
-
On the upper right of the Editor tab, click the folder icon, and select the
.erbfile that you want to import. - Edit the template to suit your requirements.
- Click Submit.
12.8. Importing report templates using the Satellite API Copia collegamentoCollegamento copiato negli appunti!
You can use the Satellite API to import report templates into Satellite. Importing report templates using the Satellite API automatically parses the report template metadata and assigns organizations and locations.
Prerequisites
Create a template using
.erbsyntax or export a template from another Satellite.For more information about writing templates, see Appendix B, Template writing reference.
For more information about exporting templates from Satellite, see Section 12.6, “Exporting report templates using the Satellite API”.
Procedure
Use the following example to format the template that you want to import to a
.jsonfile:# cat Example_Template.json { "name": "Example Template Name", "template": " Enter ERB Code Here " }Example JSON file with ERB template:
{ "name": "Hosts - complete list", "template": " <%# name: Hosts - complete list snippet: false template_inputs: - name: host required: false input_type: user advanced: false value_type: plain resource_type: Katello::ActivationKey model: ReportTemplate -%> <% load_hosts(search: input('host')).each_record do |host| -%> <% report_row( 'Server FQDN': host.name ) -%> <% end -%> <%= report_render %> " }Use the following request to import the template:
$ curl \ --insecure \ --user My_User_Name:My_Password \ --data @Example_Template.json \ --header "Content-Type:application/json" \ --request POST \ --config https://satellite.example.com/api/report_templates/importUse the following request to retrieve a list of report templates and validate that you can view the template in Satellite:
$ curl \ --insecure \ --user My_User_Name:My_Password \ --request GET \ --config https://satellite.example.com/api/report_templates | json_reformat
12.9. Report template safe mode Copia collegamentoCollegamento copiato negli appunti!
When you create report templates in Satellite, report template safe mode is enabled by default. Safe mode helps prevent rendering problems and enforces best practices in report templates.
Report template safe mode limits the macros and variables that you can use in the report template. The list of supported macros and variables is available in the Satellite web UI.
To view the macros and variables that are available, in the Satellite web UI, navigate to Monitor > Reports > Report Templates and click Create Template. In the Create Template window, click the Help tab and expand Safe mode methods.
While safe mode is enabled, if you try to use a macro or variable that is not listed in Safe mode methods, the template editor displays an error message.
To view the status of safe mode in Satellite, in the Satellite web UI, navigate to Administer > Settings and click the Provisioning tab. Locate the Safemode rendering row to check the value.