Skip to content

Instantly share code, notes, and snippets.

@SuriyaRuk
Last active July 21, 2023 19:32
Show Gist options
  • Save SuriyaRuk/71dd1d7b5d568b8ab8a02367b4a2e046 to your computer and use it in GitHub Desktop.
Save SuriyaRuk/71dd1d7b5d568b8ab8a02367b4a2e046 to your computer and use it in GitHub Desktop.
counting object on kong
#!/bin/bash
host=127.0.0.1
port=8001
for object in services routes plugins consumers certificates upstreams snis tags;do
cout=$(curl -sL $host:$port/$object | jq .data | jq .[] | jq .id | wc -l)
offset=$(curl -sL $host:$port/$object | grep -o '"offset":"[^"]*' | grep -o '[^"]*$');
while [ "$offset" != "" ];do
cout=$(($cout + $(curl -sL $host:$port/$object?offset=$offset | jq .data | jq .[] | jq .id | wc -l)))
offset=$(curl -sL $host:$port/$object?offset=$offset | grep -o '"offset":"[^"]*' | grep -o '[^"]*$')
done
echo $object=$cout
cout=0
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment