Skip to content
  • There are no suggestions because the search field is empty.

Licenseware Collector for Red Hat

Understand how to run the Collector script for RDM on one or multiple devices at the same time

0. Download the script

The script is available for Licenseware customers, request access and download the script.

1. Script Overview

The Licenseware Collector for Red Hat Deployment Manager is a versatile script designed to gather comprehensive data about the system and software environment of a Red Hat Enterprise Linux (RHEL) system. The script collects information related to hardware, installed packages, virtual machine status, and subscription details, which can be crucial for managing software assets and ensuring compliance.

2. Prerequisites

The script checks for the following utilities and proceeds even if some are missing:
rpm, lscpu, hostname, systemd-detect-virt, subscription-manager, yum, dnf, flatpak, snap

Tip: Run with sudo to avoid permission issues when querying package managers and system info.

3. Information Collected

The script performs the following tasks:

    •  Red Hat Add-on Packages (Installed)
      • Identifies installed packages that belong to Red Hat add-ons, including names that match:
        pacemaker, cluster, rh-storage-server, rhel-system-roles, rhel-high-availability, rhel-resilient-storage

      • For each matched package, the JSON includes:
        name (dot to dash normalized), signature (PGP/GPG from rpm), addon_install_date, source: "installed".

    • CPU and Topology
      • architecture from lscpu

      • model_name constructed from vendor and model name

      • socket_count, cores_per_socket, core_count = sockets × cores per socket.

    • Machine Identity and Model
      • 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 Check
      • is_virtual from systemd-detect-virt (true when not “none”).

    • OS Install Date and OS Details
      • os_install_date from rpm install time of the basesystem package, formatted YYYY-MM-DD HH:MM:SS

      • os_name from /etc/os-release PRETTY_NAME

      • os_version parsed from /etc/redhat-release.

    • RHEL Subscription Status
      • subscription_status from subscription-manager status “Overall Status:”

      • subscription_timestamp from the “Last Refreshed:” time.

    • Package Inventory (Text File)

      • Sections in the text file:

        • RPM Packages, 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 attempted with scl --list-collections (if available)

      • All content captured exactly as returned by the tools, no scanning outside package managers.

    4. Privileges Needed

    To successfully run this script, the following privileges are required:

    • Root Privileges: The script should be run as a root user or with sudo privileges. This is necessary to access system information, installed packages, and other details that are typically restricted to root users.
    • Subscription Manager Access: The user should have appropriate permissions to query the Red Hat subscription manager.

    5. Executing the Script on a Single Host

    • Ensure Necessary Privileges:

      • The script requires sudo privileges. Ensure the user running the script has sudo access.
    • Run the Script:

      • SSH into the target host:
        ssh username@target_host
      • Copy the script from your workstation (or create it directly on the server, paste into a file):
        scp licenseware-collector-rhel-script-v8-no-middleware.sh <user>@<rhel-host>:/tmp/
      • Make the script executable:
        chmod +x licenseware-collector-rhel-script-v8-no-middleware.sh
      • Navigate to the directory where the script is located and run it with sudo:
        cd /path/to/directory sudo bash licenseware-collector-rhel-script-v8-no-middleware.sh
      • Example Run (Quick Start)
        # 1) copy or create the script in /tmp, then:

        cd /tmp

        chmod +x licenseware-collector-rhel-script-v8-no-middleware.sh

        # 2) run it (recommended with sudo)

        sudo ./licenseware-collector-rhel-script-v8-no-middleware.sh

        # 3) upload both output files to the Red Hat Deployment Manager app

        #    Licenseware_Collector_-_RHEL_Script_Output_<timestamp>_<hostname>.json

        #    Licenseware_Collector_-_RHEL_Package_Inventory_<timestamp>_<hostname>.txt
     

    6. Executing the Script on Multiple Hosts

    6.1. Using SSH with a Shell Script

    This method relies on SSH access to each target machine and assumes that the user has the necessary privileges to execute the script with sudo. Additionally, it requires that the local machine has passwordless SSH configured for the target servers, or it will prompt for passwords during the execution.

    6.1.1. Steps

      1. Prepare a List of Target Machines: Create a file (servers.txt) that lists the target machines.

        server1.example.com server2.example.com server3.example.com
      2. Create the Shell Script: Write a shell script (run_licenseware_collector.sh) that reads the list of target machines and runs the Licenseware Collector script on each of them using SSH.

        #!/bin/bash

        # Path to the Licenseware Collector script on the local machine
        SCRIPT_PATH="/path/to/licenseware-collector-rhel-script-v8-no-middleware.sh"

        # Path to the Licenseware Collector script on the remote machine
        REMOTE_SCRIPT_PATH="/tmp/licenseware-collector-rhel-script-v8-no-middleware.sh"

        # Path to the file containing the list of servers
        SERVERS_LIST="servers.txt"

        # Loop through each server in the list
        while read -r SERVER; do
            echo "Processing $SERVER..."

            # Copy the Licenseware Collector script to the remote server
            scp "$SCRIPT_PATH" "$SERVER:$REMOTE_SCRIPT_PATH"

            # Execute the script on the remote server
            ssh "$SERVER" "sudo bash $REMOTE_SCRIPT_PATH"

            # Retrieve the JSON output file from the remote server
            ssh "$SERVER" "cat /tmp/Licenseware_Collector_RHEL_Script_Output_*.json" > "/path/to/output/${SERVER}_output.json"

            # Retrieve the package dump file from the remote server
            ssh "$SERVER" "cat /tmp/Licenseware_Collector_RHEL_Package_Inventory_*.txt" > "/path/to/output/${SERVER}_package_dump.txt"

            echo "Completed processing $SERVER"
        done < "$SERVERS_LIST"

        echo "All servers processed."
      3. Run the Shell Script: Execute the shell script on your local machine.

        chmod +x run_licenseware_collector.sh ./run_licenseware_collector.sh

    6.1.2. Explanation

      • Servers List: The servers.txt file contains the hostnames or IP addresses of the target machines.
      • Loop Through Servers: The shell script reads each server from servers.txt and performs the following actions:
        • Copy Script: Uses scp to copy the Licenseware Collector script to the remote server.
        • Execute Script: Uses ssh to run the script on the remote server with sudo privileges.
        • Retrieve Outputs: Uses ssh to retrieve the JSON output and package dump files from the remote server to the local machine.

    6.2 Using Ansible

    To execute the script on multiple machines simultaneously, tools like Ansible, Puppet, or other configuration management tools can be used. Below is an example of how to use Ansible to run the script on multiple RHEL machines.

    6.2.1. Steps

      1. Prepare the Inventory File: Create an inventory file (hosts) with the list of target machines.

        [rhel_servers]
        server1.example.com
        server2.example.com
      2. Create the Ansible Playbook: Create a playbook (run_licenseware_collector.yml) to copy the script to target machines and execute it.

        ---

        - name: Run Licenseware Collector on RHEL Servers

          hosts: rhel_servers

          become: yes

          tasks:

            - name: Copy the Licenseware Collector script to the remote server

              copy:

              src: /path/to/licenseware-collector-rhel-script-v8-no-middleware.sh

              dest: /tmp/licenseware-collector-rhel-script-v8-no-middleware.sh

                mode: '0755'

            - name: Execute the Licenseware Collector script

            command: sudo /tmp/licenseware-collector-rhel-script-v8-no-middleware.sh

              register: script_output

            - name: Save the script output to a local file

              local_action:

                module: copy

                content: ""

                dest: "/path/to/output/_output.txt"
      3. Run the Playbook: Execute the playbook using the following command.

        ansible-playbook -i hosts run_licenseware_collector.yml

    6.2.2. Explanation

      • Inventory File: Lists the RHEL servers where the script will be executed.
      • Playbook Tasks:
        • Copy Script: Transfers the Licenseware Collector script to the target machines.
        • Execute Script: Runs the script on the target machines with sudo privileges.
        • Save Output: Collects the script output and saves it to a local file for each server.

    7. Common Issues and Fixes

    Missing command warnings

    • The script logs utilities that aren’t installed, but continues. Install missing tools as needed, for example:

      sudo dnf install -y redhat-lsb-core dmidecode subscription-manager

      (Adjust per environment.)

    Subscription manager access

    • If subscription-manager isn’t configured or available, subscription_status fields may be null or absent. This won’t stop the run.

    Flatpak or Snap not present

    • Their sections will show errors or be empty in the package inventory file. This is expected if those frameworks aren’t used.

    8. Data Handling and Security

    Read-only system queries, no package modifications, no service restarts, no network exfiltration, files saved locally only, you control what gets uploaded, remove the files any time with rm *.json *.txt in the working directory.


    By using Ansible, you can efficiently run the Licenseware Collector script on multiple machines simultaneously, streamlining the data collection process across many systems.