Discovering Stale Agents via API
A Stale Agent is a TrustLayer Agent that has not checked into the Dashboard for some time. This article shows you how you can run a Bash Script to check for Stale Agents within your environment.
The script can be downloaded below:
Pre-requisites
In order to run this script, you will require the following:
- A physical or virtual Linux machine (Ubuntu recommended, or Windows Subsystem for Linux) with the following utilities installed:
curl: a command-line utility for transferring data to or from servers using protocols such as HTTP, HTTPS, FTP, and SFTP. This is used for the script to communicate with the TrustLayer API.jq: a command-line tool for processing, filtering, and transforming JSON data.
- Internet connectivity on TCP port 443
- An account on the Tenant with API access.
If your Linux Machine does not have these pre-requisites installed, on Ubuntu you can install them with the following commands:
$ sudo apt update
$ sudo apt install jq curl
Preparing the script
After downloading the script, you will need to edit it to allow it to run within your environment. There are two lines to edit, those starting with USERNAME and PASSWORD respectively. By default, they appear as follows:
USERNAME="${USERNAME:?Set USERNAME}
PASSWORD="${PASSWORD:?Set PASSWORD}"
For example, if you have a user called stale-agents@example.com with the password YuPfY4h2XwYVfw#F, your script should be edited as follows:
USERNAME="stale-agents@example.com"
PASSWORD="YuPfY4h2XwYVfw#F"
With these edits made, you should save your changes.
Once you have saved your changes, you will need to mark the script as executable with the following command:
chmod u+x ./stale-agents.sh
You are now ready to run the script.
Running the script
With the script in your working directory, you can run the script with the following command:
./stale-agents.sh
If there is no output, then there are no Stale Agents within your environment. Below is an example of output for Stale Agents being present:

After reviewing this information, you can now safely remove clients that you are no longer using.