Skip to content
Sign in

Collect Red Hat subscription data

The Red Hat collector is a script for Red Hat Deployment Manager, not the Licenseware Collector agent. It gathers the hardware, installed packages, virtual machine status and subscription detail RDM uses to decide which subscriptions a host needs. The operating system install date it records is what backdating depends on.

Request the script from support@licenseware.io. The file name in these steps is licenseware-collector-rhel-script-v8-no-middleware.sh.

The script checks for these utilities and proceeds even if some are missing:

rpm, lscpu, hostname, systemd-detect-virt, subscription-manager, yum, dnf, flatpak, snap

Red Hat add-on packages. It looks for installed packages whose names match pacemaker, cluster, rh-storage-server, rhel-system-roles, rhel-high-availability, or rhel-resilient-storage. RDM recognizes those paid add-ons. For each match the JSON includes name (dots changed to dashes), signature (PGP/GPG from rpm), addon_install_date, and source set to installed.

CPU and topology. architecture from lscpu. model_name from the vendor and model name. socket_count, cores_per_socket, and core_count (sockets multiplied by cores per socket).

Machine identity. name and machine_name from hostname. machine_model from /sys/devices/virtual/dmi/id/sys_vendor and /sys/devices/virtual/dmi/id/product_name, with “None” stripped.

Virtualization. is_virtual from systemd-detect-virt. It is true when the result is not none.

Operating system. os_install_date from the rpm install time of the basesystem package, formatted YYYY-MM-DD HH:MM:SS. os_name from PRETTY_NAME in /etc/os-release. os_version parsed from /etc/redhat-release.

Subscription status. subscription_status from the “Overall Status:” line of subscription-manager status. subscription_timestamp from “Last Refreshed:”. Without that status, RDM cannot backdate a subscription.

Package inventory. A second file, with these sections, captured exactly as the tools return them:

  • RPM Packages, from rpm -qa, with version and release
  • YUM Packages, from yum list installed
  • DNF Apps, from dnf list installed
  • Flatpak Apps, from flatpak list
  • Snap Apps, from snap list
  • Appstream Modules, from dnf module list --enabled
  • Red Hat Subscription Manager Apps, from subscription-manager repos --list-enabled
  • SCL List, from scl --list-collections when that command exists

Run it as root, or with sudo. That is what can read system information and installed packages. The user also needs permission to query Red Hat subscription manager.

  1. SSH to the host: ssh username@target_host
  2. Copy the script: scp licenseware-collector-rhel-script-v8-no-middleware.sh <user>@<rhel-host>:/tmp/
  3. Make it executable: chmod +x licenseware-collector-rhel-script-v8-no-middleware.sh
  4. Run it: sudo bash licenseware-collector-rhel-script-v8-no-middleware.sh

Or, from /tmp:

Terminal window
chmod +x licenseware-collector-rhel-script-v8-no-middleware.sh
sudo ./licenseware-collector-rhel-script-v8-no-middleware.sh

The script writes two files. Upload both to the RDM - Custom Collector source. That source is listed on Data sources.

  • Licenseware_Collector_-_RHEL_Script_Output_<timestamp>_<hostname>.json
  • Licenseware_Collector_-_RHEL_Package_Inventory_<timestamp>_<hostname>.txt

This needs SSH to each machine, sudo on each machine, and passwordless SSH from the machine you run it on (otherwise each host prompts for a password).

  1. Put one hostname or IP per line in servers.txt.
  2. Save a script such as run_licenseware_collector.sh that, for each line, copies the collector script to /tmp on that host, runs it with sudo, and copies both output files back.
  3. Run chmod +x run_licenseware_collector.sh and then ./run_licenseware_collector.sh.

The loop copies the script with scp, runs it with ssh and sudo bash, then uses ssh and cat to pull Licenseware_Collector_RHEL_Script_Output_*.json and Licenseware_Collector_RHEL_Package_Inventory_*.txt into a local output folder, one pair per server.

An inventory file named hosts:

[rhel_servers]
server1.example.com
server2.example.com

A playbook that copies the script to /tmp with mode 0755, runs it with sudo, and saves the output locally. Then:

Terminal window
ansible-playbook -i hosts run_licenseware_collector.yml

The playbook’s tasks are: copy the script, execute it, and save the output for each server.

Missing command warnings. The script logs utilities that are not installed, and continues. Install what you need, for example sudo dnf install -y redhat-lsb-core dmidecode subscription-manager. Adjust that for the environment.

Subscription manager. If subscription-manager is not configured or not available, subscription_status may be null or absent. That does not stop the run. Without the status, RDM cannot backdate.

Flatpak or Snap. If those frameworks are not used, their sections in the package inventory are empty or show an error. That is expected.

The Licenseware Collector agent, for general hardware and software inventory, is documented at licenseware-collector.com.