This article was originally published on the Red Hat Customer Portal. The information may no longer be current.
Overview
One of the big changes with Satellite 6 and also Red Hat Subscription Management (RHSM) is that the tools now maintain an accurate inventory of what systems are consuming which subscription. This document will illustrate how to use hammer and other tools to extract subscription consumption information from Satellite. This information is useful for audit/reporting and other usages.
Prerequisites
It is important that you have read (or understand) the concepts as presented in:
- The Hammer CLI Guide
Hammer-cli-csv
One of the most common questions we get is 'How can I see which systems are using which subscription?'. Introduced as a supported tool in Satellite 6.2.2, hammer-cli-csv, can be used to export subscription consumption usage. It can also be used as part of the renewal process to attach subscriptions based upon the contents of a CSV file (as described in Subscription-manager for the former Red Hat Network User: Part 6 - understanding and improving the renewal experience). For now, we'll focus on the export functionality.
Note: some earlier versions of hammer-cli-csv didn't respect hammer's request_timeout value. This was addressed via RHBA-2017:0197. If you are running Satellite 6.2.7 or newer, you have this erratum already. If you aren't, you'd need to apply it if you are exporting large numbers of hosts.
Firstly, let's run hammer to export subs
hammer csv content-hosts \
--export \
--file content-hosts-export.csv \
--itemized-subscriptions \
--verbose \
--organization Example
NOTE If you haven't setup hammer's configuration file to store username/password & server, it connects to https://localhost and uses admin as the username.
The command above writes content-hosts-export.csv
to the current directory
cat content-hosts-export.csv
Name,Organization,Environment,Content View,Host Collections,Virtual,Guest of Host,OS,Arch,Sockets,RAM,Cores,SLA,Products,Subscription Name,Subscription Type,Subscription Quantity,Subscription SKU,Subscription Contract,Subscription Account,Subscription Start,Subscription End,Subscription Guest
kvm01.example.com,Example,Infrastructure,RHEL7_Infra,"",No,,Red Hat Enterprise Linux Server 7.3,x86_64,1,16316756,2,"",69|Red Hat Enterprise Linux Server,"Red Hat Enterprise Linux Server, Premium (1-2 sockets) (Unlimited guests) with Smart Management",Red Hat,1,RH0149450,11002744,5699795,07/04/2016,07/04/2017,
Below is an explanation of each of the fields. Note: A full example report is attached to this blog post.
Item | Details | Notes |
---|---|---|
Name | Name of the host | |
Organization | Organization the host resides in | |
Environment | Lifecycle Environment of the Host | |
Content view | Attached Content View | |
Host Collections | list of 1 or more Host Collections that the host is a member of (comma separated) | |
Virtual | is the host virtual or physical (as reported by subscription-manager facts) | |
Guest of Host | on which hosts does the guest reside | |
OS | Operating system (as reported by subscription-manager facts) | |
Arch | Architecture (as reported by subscription-manager facts) | |
Sockets | Sockets (as reported by subscription-manager facts) | |
RAM | Memory (as reported by subscription-manager facts) | |
Cores | Cores (as reported by subscription-manager facts) | |
SLA | Service Level Agreement | |
Products | Installed Products (from /etc/pki/product*) (comma separated) | Covered in Subscription-manager for the former Red Hat Network User: Part 8 - product certificates |
Subscription Name | Canonical name of the subscription (as reported by subscription-manager, rct and the UI) | |
Subscription Type | what type of subscription | There are 3 types (Red Hat, Red Hat Guest [for derived subscriptions], and Custom [for 3 party products]) |
Subscription Quantity | Quantity of attached entitlements | Instance based subs counting is interesting see Subscription-manager for the former Red Hat Network User: Part 10 - Instance Based Subscriptions |
Subscription SKU | Stock Keeping Unit (SKU) | |
Subscription Contract | Contract number of the subscription | |
Subscription Account | Which account are these subscriptions from. | |
Subscription Start | When does the subscription start | |
Subscription End | When does the subscription end | |
Subscription Guest | Host constraint of this subscription | only guests of the listed host can use this subscription. |
Expanding hammer-cli-csv to report on custom fields
While the report above is useful for most use cases, maybe you have a need to report on fields that aren't in the default report.
Example: I want to create a simple custom report that shows that prints the host name, subscription status, and CPU model name.
In /etc/hammer/cli.modules.d/csv.yml (or your user's local hammer config file) add:
:csv:
:enable_module: true
:columns:
:content-hosts:
:define:
- :name: Subscription Status
:json:
- subscription_status_label
- :name: Last Checkin
:json:
- subscription_facet_attributes
- last_checkin
- :name: CPU Model Name
:json:
- facts
- proc_cpuinfo::common::model_name
Then run a hammer export
hammer csv content-hosts \
--export \
--columns "Name,Subscription Status,CPU Model Name" \
--file custom_report.csv
And let's look at the report.
Name,Subscription Status,CPU Model Name
kvm01.example.com,Fully entitled,"Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz"
How do I know what properties to use in my configuration file?
Any property of the object that your are exporting can be used via hammer csv. In this example, we are exporting data from a (content) host, so any of a (content) hosts properties is valid. Lets look at a host kvm01.example.com via the API to see all of its properties.
curl -sk \
-u admin:[redacted] https://satellite.example.com/api/hosts/kvm01.example.com | json_reformat
{
"ip": null,
"environment_id": 3,
"environment_name": "KT_Example_infrastructure_rhel7_infra_2",
"last_report": "2017-02-19 13:00:41 UTC",
"mac": "b8:ae:ed:7d:0b:aa",
"realm_id": null,
"realm_name": null,
"sp_mac": null,
"sp_ip": null,
"sp_name": null,
"domain_id": 1,
"domain_name": "example.com",
"architecture_id": 1,
"architecture_name": "x86_64",
"operatingsystem_id": 9,
"operatingsystem_name": "RedHat 7.3",
"subnet_id": 1,
"subnet_name": "Infrastructure",
<!-- OUTPUT REDACTED ->
}
Any of the above can be used.
Hammer as an ad-hoc reporting tool.
Hammer has a few functionalities that make it useful for ad-hoc reporting. As an example, you may not need system level subscription report, but you may want to know 'of the subscriptions that I've purchased, how many are in use (and conversely, how many do I have free?'). You can do this with hammer, specifically hammer subscription list
. Hammer can output to a number of formats, including CSV, YAML and JSON.
hammer --output json subscription list \
--organization Example
[
{
"ID": 251,
"UUID": "2c9180935a41d344015a513e4fcd0c1d",
"Name": "Red Hat Enterprise Linux for Virtual Datacenters with Smart Management, Standard",
"Contract": 11002776,
"Account": [REDACTED],
"Support": "Standard",
"Quantity": "Unlimited",
"Consumed": 0,
"End Date": "2017-07-04T03:59:59.000+0000",
"Attached": 0
},
{
"ID": 252,
"UUID": "2c9180935a568fcf015a58992cce003b",
"Name": "Red Hat Cloud Infrastructure with Smart Management, Premium (2-sockets)",
"Contract": 11002794,
"Account": [REDACTED],
"Support": "Premium",
"Quantity": "Unlimited",
"Consumed": 0,
"End Date": "2017-07-04T03:59:59.000+0000",
"Attached": 0
}
]
sat6Inventory
If you are still on Satellite 6.0 or Satellite 6.1, you do not have access to hammer-cli-csv. We provide in the Red Hat Satellite GitHub Organization the community supported sat6Inventory script, which is useful for subscription reporting for older versions of Satellite. Note: sat6Inventory does work with Satellite 6.2, but we prefer that you use hammer-cli-csv as that is the supported tool. And feel free to file RFEs against hammer-cli-csv.
rhsmShowConsumerSubs
If you are using systems registered to Red Hat Subscription Managemen (RHSM), we provide, also in the Red Hat Satellite GitHub Organization the community supported rhsmTools repo, which has the rhsmShowConsumerSubs.py script, which is useful for subscription reporting for Red Hat Subscription Management. It reports subscriptions attached to any consumer registered to RHSM. These include systems (type system) & subscription management applications (type SAM and Satellite)
Further reading
- Subscription-manager for the former Red Hat Network User: Part 1
- Subscription-manager for the former Red Hat Network User: Part 2 - Subscription-manager learns grep
- Subscription-manager for the former Red Hat Network User: Part 3 - Understanding virt-who
- Subscription-manager for the former Red Hat Network User: Part 4 - Understanding Subscription Manifests
- Subscription-manager for the former Red Hat Network User: Part 5 - working with subscriptions that require virt-who
- Subscription-manager for the former Red Hat Network User: Part 6 - understanding and improving the renewal experience
- Subscription-manager for the former Red Hat Network User: Part 7 - understanding the Red Hat Content Delivery Network
- Subscription-manager for the former Red Hat Network User: Part 8 - Product Certificates
- Subscription-manager for the former Red Hat Network User: Part 9 - A Case Study with activation keys.
- Subscription-manager for the former Red Hat Network User: Part 10 - Instance Based Subscriptions
- Subscription-manager for the former Red Hat Network User: Part 11 - Identity Certificates
About the author
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit