You can monitor an agent’s state on your servers by using a Unix Domain Socket (UDS) located at:

 /var/run/cmd/diag.1.sock  


Prerequisite:

This feature is available on:

  • Cmd Control agent versions 1.4.0 or later;
  • Cmd Audit agent versions 1.0.0 or later.

Outline:

  • How to turn on the status API
  • How to read the status of the Cmd Control or Cmd Audit agent

How to turn on the API

You can enable the end point by either of these methods:

  • config.ini:
    Add the line diagnostics_interface=1 to /etc/cmd/config.ini, e.g.:
    echo diagnostics_interface=1 | sudo tee --append /etc/cmd/config.ini
  • Env. var.:
    Add the line Environment="CMD_DIAGNOSTICS_INTERFACE=1" to /etc/cmd/cmd.service , under where it says [Service].

(If they differ, the env. var. will take precedence over the config variable.)

After updating the config.ini or setting the env. var., restart the agent to apply the updates.

How to read the status

With the API turned on, you can read from the socket, e.g.:
nc -U /var/run/cmd/diag.1.sock . The agent will return a status message (a dash-delimited string), then close the connection. 

The status message has four state fields, and its format is as follows:
 <Offline DB Filtering Policy>-<High Latency Mode>-<Collector Connection State>-<Throttle State> . The Cmd Audit agent has one additional field, detailed in table 2, below.


Table 1. Agent Status API: fields and values 

For example, a status message from the Cmd Control agent could look like this:
DISCARDING-NETWORK_ISSUES-DISCONNECTED-FLOW_CONTROLLED

Note that NULL values will be omitted from status message, so a status message could also look like this:
BUFFERING-DISCONNECTED

Table 2. Agent-status API: Cmd Audit-specific fields

When a Cmd Audit agent reports its status, the Probe Load State appears at the end of the diagnostic string.

Did this answer your question?