Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Keeping track of my subscriptions using the Red Hat Content Delivery Network API

August 2, 2016
John Herr
Related topics:
DevOpsPython
Related products:
Red Hat OpenShift

    In a previous post, where-have-all-my-subscriptions-gone, I mentioned that you can access the Red Hat Content Delivery Network (CDN) using its API --- allowing you to query CDN for subscriptions and their usage, registered hosts, and more as well as unregistering hosts, and more.

    I wanted to do some analysis for my own subscription usage, so I wrote some scripts that let me more easily tell where my subscriptions are being used.

    Since Python scripting is still fairly new to me, and I wanted to learn something new, I decided I would write the primary script using Python 3.

    For my use, I needed the scripts to:

    • Tell me which systems are using my subscriptions and pool IDs.
    • When did the system last check in.
    • List any systems with duplicate names. This is an indication that the systems were re-installed without first being unregistered.
    • When did the systems last check in. A system that no longer checks in may no longer exist.

    After a little work, I had a script that could give me what I wanted. The script can generate 3 basic reports for me.

    • A pool/subscription usage report
    • A duplicate systems report
    • A report of when systems last checked in and can show me only reports that have not checked in longer than some determined number of days.

    Here are some sample reports generated by my Python script. The script accepts the --help option to give details on its options.

    Pool Usage Report

                Name                 | Pool ID      | Quantity | Consumed | Exported
    --------------------------------------------------------------------------------
    Subscription 1                   | 123456abcdef | 300      | 101      | 30
         Attached Systems: | System ID              | Name
                           | 12345678-abcd-1a2b3c4d | system-1 Last Checkin (days): 50
                           | 12345678-abcd-1a2eeeee | system-2 Last Checkin (days): 0
    
    Subscription 2                   | aabbcc1122dd | 10 | 8 | 0
         Attached Systems: | System ID              | Name
                           | bcdef678-af5d-1a2cfd4d | system-3 Last Checkin (days): 9
                           | 12346fde-aeed-1a2abdce | system-4 Last Checkin (days): 5

    Duplicate Systems Report

    Hosts with duplicates: 197
    Duplicate systems: 276
    Freeable systems: 79
    Count | Name         Last Checkin (EPOCH) |    ID 
    -------------------------------------------------------------------
    # 11  system-1         1466648032           12345678-abcd-1a2b3c4d
                           1466639184           1b2b32b3-1234-867ab210
                           1466132041           3b2ds525-abdd-a1b1c1d1
                           1465339439           3232bb32-43bc-abcdabcd
                           1464219749           423443dd-7652-12341234
    # 10  system-2         1466649410           12345678-abcd-1a2eeeee
                           1466638967           3421dd11-abcd-bdcdeeed
                           1465339174           787dbb8a-42dc-abcdef11
    # 10  system-3         1466649256           bcdef678-af5d-1a2cfd4d
                           1466638709           678acb26-6421-bcccad12
                           1464196357           5673ffff-ab12-123bcddd

     

    Last Check-In Report

    Host     | ID                     | Last Checking (Days) | Entitlements Consumed
    --------------------------------------------------------------------------------------------
    system-1 | 12345678-abcd-1a2b3c4d | 162                  | 1
    system-2 | 12345678-abcd-1a2eeeee | 156                  | 1
    system-3 | bcdef678-af5d-1a2cfd4d | 156                  | 0
    system-4 | 23422323-1234-11223344 | 155                  | 0
    system-5 | ababaaba-4321-aabbccdd | 153                  | 1
    system-2 | 3421dd11-abcd-bdcdeeed | 153                  | 0
    
    

    Now that I have my reports, I can see that I have hundreds of systems I need to remove. That is a lot of pointing and clicking in the Red Hat Content Delivery Network (CDN) portal.

    API to the rescue again! It allows me to remove systems and free up the subscriptions as well. This is awesome, life is good.

    I wrote a bash script to remove systems from being registered. Sorry no Python here, I am being a bit lazy and I know I can get the bash script done quicker than writing another Python script. It uses the following curl command to remove a host from being registered to CDN, I wrote a bash script that will take a list of system UUIDs from standard input.

    curl --silent -X DELETE -u CDN_USER:CDN_PASSWORD -k "https://subscription.rhn.redhat.com/subscription/consumers/SYSTEM_UUID"

    I went back and added an option to the Python script to tell it to not print the header information. I also modified the output of the duplicate systems report to add a hash mark in front of the most recently checked in system. This will allow me to pass the -v option to grep so it ignores the most recently checked in system in each set of duplicates. With a little help from awk, piping the output of the duplicates report through grep and then awk gives me a list of system UUIDs  that can be used as input to the list of hosts to remove.

    The Last Check-In report can either display the last check-in for all the registered systems by using the --checkin option alone. Or the report can be generated to list the systems that have not registered within a certain number of days by using --checkin and --days options.

    Now I can easily remove all my duplicate systems, except the most recently registered one, and I can remove all systems that have not checked in recently.

    I imagine others might find these scripts useful as well, so I am making them available via GitHub.

    https://github.com/jobbler/cdn_reports

    The README file should be fairly explanatory on how to use the scripts, so I am not including the information here since it would make this blog post very long.

    Please be careful using these scripts, they are only tested when I need to clean up my systems in CDN.

    Enjoy and I hope others find them useful as well. Better yet, make something even better from them.

    Last updated: September 5, 2023

    Recent Posts

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI