Get host traces status from API

Hello,

Problem:
A host displays the following in the web ui:
Properties
Status Error
Build Installed
Configuration Out of sync
Errata All errata applied
System Purpose Not Specified
Subscription Fully entitled
Traces Reboot required

Using the API, I would like to capture the ‘Traces’ ‘Reboot required’ state, but I cannot find it under api/v2/hosts/:
curl -s --user ${FOREMANUSR}:${FOREMANPW} -H “Content-Type:application/json” -H “Accept:application/text” -k ${FOREMANAPI}/hosts/${FQDN} -X GET | jq -r ‘’ | egrep -i ‘trace|reboot’
“os_patching::reboot_override”: “default”,
“os_patching::reboots::reboot_required”: “unknown”,
“puppet_settings::main::trace”: “false”,
“puppet_settings::main::puppet_trace”: “false”,
“puppet_settings::transaction::evaltrace”: “false”,
“reboot_required”: “false”,
“os_patching::reboots”: null,

I see the other status components:
curl -s --user ${FOREMANUSR}:${FOREMANPW} -H “Content-Type:application/json” -H “Accept:application/text” -k ${FOREMANAPI}/hosts/${FQDN} -X GET | jq -r ‘’ | egrep -i ‘global|configuration’
“global_status”: 2,
“global_status_label”: “Error”,
“configuration_status”: 1,
“configuration_status_label”: “Out of sync”,
“subscription_global_status”: 0,

I do see that the katello/api can retrieve traces (list of services requiring restart) but I just need the global status.

Expected outcome:
The API would display the ‘Traces’ host status.

Foreman and Proxy versions:
Katello 3.12/Foreman 1.22

Foreman and Proxy plugin versions:
foreman001.zyme.zone-qpid-broker-1.0-8.noarch
foreman-1.22.1-1.el7.noarch
foreman-cli-1.22.1-1.el7.noarch
foreman-debug-1.22.1-1.el7.noarch
foreman-ec2-1.22.1-1.el7.noarch
foreman-gce-1.22.1-1.el7.noarch
foreman-installer-1.22.1-1.el7.noarch
foreman-installer-katello-1.22.1-1.el7.noarch
foreman-libvirt-1.22.1-1.el7.noarch
foreman-openstack-1.22.1-1.el7.noarch
foreman-ovirt-1.22.1-1.el7.noarch
foreman-postgresql-1.22.1-1.el7.noarch
foreman-proxy-1.22.1-1.el7.noarch
foreman-rackspace-1.22.1-1.el7.noarch
foreman-release-1.22.1-1.el7.noarch
foreman-release-scl-7-2.el7.noarch
foreman-selinux-1.22.1-1.el7.noarch
foreman-vmware-1.22.1-1.el7.noarch
katello-3.12.3-1.el7.noarch
katello-certs-tools-2.5.3-1.el7.noarch
katello-client-bootstrap-1.7.2-2.el7.noarch
katello-common-3.12.3-1.el7.noarch
katello-debug-3.12.3-1.el7.noarch
katello-repos-3.12.3-1.el7.noarch
katello-selinux-3.1.1-1.el7.noarch
katello-service-3.12.3-1.el7.noarch
pulp-katello-1.0.2-1.el7.noarch
rubygem-foreman_maintain-0.4.2-1.el7.noarch
tfm-rubygem-foreman_default_hostgroup-5.0.0-3.fm1_22.el7.noarch
tfm-rubygem-foreman_discovery-15.0.1-1.fm1_22.el7.noarch
tfm-rubygem-foreman_docker-5.0.0-2.fm1_22.el7.noarch
tfm-rubygem-foreman_hooks-0.3.15-1.fm1_22.el7.noarch
tfm-rubygem-foreman_setup-6.0.0-3.fm1_22.el7.noarch
tfm-rubygem-foreman-tasks-0.15.9-1.fm1_22.el7.noarch
tfm-rubygem-foreman-tasks-core-0.3.2-1.fm1_22.el7.noarch
tfm-rubygem-foreman_templates-6.0.3-2.fm1_22.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.17.2-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_bootdisk-0.1.3-7.el7.noarch
tfm-rubygem-hammer_cli_foreman_docker-0.0.4-4.el7.noarch
tfm-rubygem-hammer_cli_foreman_tasks-0.0.13-1.fm1_22.el7.noarch
tfm-rubygem-hammer_cli_katello-0.18.2-1.el7.noarch
tfm-rubygem-katello-3.12.3-1.el7.noarch

Distribution and version:
EL 7.6

Hi,

I could not verify if the information is actually there, since I currently have not found a host requiring reboot, but I think the API endpoint you are looking for is GET /api/hosts/:host_id/traces.
You can get the full API documentation of your installation including all plugins from yourforeman.example.com/apidoc, just in case you did not know :wink:

Regards

1 Like

Unfortunately that lists the actual services that need to be restarted.

curl -s --user ${FOREMANUSR}:${FOREMANPW}      -H "Content-Type:application/json"      -H "Accept:application/text"      -k ${FOREMANAPI}/hosts/1155/traces      -X GET | jq -r '' 
{
  "total": 35,
  "subtotal": 35,
  "page": 1,
  "per_page": 20,
  "error": null,
  "search": null,
  "sort": {
    "by": "application",
    "order": "asc"
  },
  "results": [
    {
      "id": 163955,
      "application": "auditd",
      "helper": "systemctl restart auditd",
      "app_type": "daemon"
    },
    {
      "id": 163985,
      "application": "autofs",
      "helper": "systemctl restart autofs",
      "app_type": "daemon"
    },
    {
      "id": 163979,
      "application": "bash",
      "helper": "You will have to log out & log in again",
      "app_type": "session"
    },
    {
      "id": 163972,
      "application": "chronyd",
      "helper": "systemctl restart chronyd",
      "app_type": "daemon"
    },
    {
      "id": 163976,
      "application": "collectd",
      "helper": "systemctl restart collectd",
      "app_type": "daemon"
    },
    {
      "id": 163978,
      "application": "crond",
      "helper": "systemctl restart crond",
      "app_type": "daemon"
    },
    {
      "id": 163983,
      "application": "dbus",
      "helper": "You will have to reboot your computer",
      "app_type": "static"
    },
    {
      "id": 163962,
      "application": "getty@tty1",
      "helper": "You will have to log out & log in again",
      "app_type": "session"
    },
    {
      "id": 163974,
      "application": "goferd",
      "helper": "systemctl restart goferd",
      "app_type": "daemon"
    },
    {
      "id": 163953,
      "application": "gssproxy",
      "helper": "systemctl restart gssproxy",
      "app_type": "daemon"
    },
    {
      "id": 163970,
      "application": "irqbalance",
      "helper": "systemctl restart irqbalance",
      "app_type": "daemon"
    },
    {
      "id": 163951,
      "application": "kernel",
      "helper": "You will have to reboot your computer",
      "app_type": "static"
    },
    {
      "id": 163971,
      "application": "mcollective",
      "helper": "systemctl restart mcollective",
      "app_type": "daemon"
    },
    {
      "id": 163966,
      "application": "network",
      "helper": "systemctl restart network",
      "app_type": "daemon"
    },
    {
      "id": 163954,
      "application": "oddjobd",
      "helper": "systemctl restart oddjobd",
      "app_type": "daemon"
    },
    {
      "id": 163975,
      "application": "polkit",
      "helper": "systemctl restart polkit",
      "app_type": "daemon"
    },
    {
      "id": 163981,
      "application": "postfix",
      "helper": "systemctl restart postfix",
      "app_type": "daemon"
    },
    {
      "id": 163968,
      "application": "rhsmcertd",
      "helper": "systemctl restart rhsmcertd",
      "app_type": "daemon"
    },
    {
      "id": 163952,
      "application": "rpcbind",
      "helper": "systemctl restart rpcbind",
      "app_type": "daemon"
    },
    {
      "id": 163957,
      "application": "rpc-gssd",
      "helper": "systemctl restart rpc-gssd",
      "app_type": "daemon"
    }
  ]
}

Not ideal, but it looks like I can use the “total” field to determine if the host has any services / packages requiring restarts.

Thanks!

You’ve found a bug. It was a quick fix so I filed an issue and opened a PR: Bug #29721: Show Traces status in hosts API - Katello - Foreman

You should see this address in Katello 3.16 !

3 Likes