Check Worker Status from BASH

Pliant has an extensive API (See https://your.instance/api for your Pliant API Swagger) that allows much of the same functions that can be performed via the UI.

The following steps illustrate how to authenticate to the Pliant API via curl and get a list of active workers. Please update the variables and curl arguments as needed for your environment

You must have the jq utility available

# authenticate:

TOKEN=`curl -ks "https://$PLIANT_HOST/api/oauth/token" -H 'Authorization: Basic cGxpYW50LmlvLXNwYTpWN1VPR3pBbHZ4V0xVWDhGYzVhVA==' -d "grant_type=password&username=$PLIANT_USER&password=$PLIANT_PASS" | grep -Po '(?<="access_token":").*?[^\\\\](?=")'`

You can now check for a long alphanumeric token in the $TOKEN variable

echo $TOKEN

If you have a valid token, you have authenticated to the API and are ready to perform a request

# request:
curl -s -k -X GET "https://${PLIANT_HOST}:443/api/v1/workers" -H  "accept: */*" -H  "authorization: Bearer ${TOKEN}" | jq -r '.[] | select(.type != "SYNTHETIC" and .status == "ACTIVE") | "\(.workerGroup) \(.version) \(.workerId)"' | sort

The curl command will have output like this if successful, showing what workers are active in each worker group with their version and unique Id:

Delaware 1.107.0 2f534525-9c81-4c10-9725-200c9f1075ac
Delaware 1.107.0 cdeb770c-167c-498f-9303-06c60bac25b7
default 1.107.0 2922a999-2e54-4fc4-9716-b233d5fbed71
default 1.107.0 e154d128-8b28-42b1-9e65-f663fc238e05