Skip to content

Instantly share code, notes, and snippets.

@cwjohnston
Created June 19, 2019 20:17
Show Gist options
  • Save cwjohnston/169308b69af0b2eef7e1ccd5aeac4162 to your computer and use it in GitHub Desktop.
Save cwjohnston/169308b69af0b2eef7e1ccd5aeac4162 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
count=0
if [ -n "${1}" ] && [ "${1}" -eq "${1}" ] 2>/dev/null; then
count=$1
else
echo "${0}: \"${1}\" is not a number"
exit 1
fi
token=$(sensuctl entity list >/dev/null && cat ~/.config/sensu/sensuctl/cluster | jq -r '.access_token')
for i in $(seq $count) ; do
agent_name=sensu-agent-$(openssl rand -hex 6)
curl -X POST http://127.0.0.1:8080/api/core/v2/namespaces/default/entities \
-H "Authorization: Bearer ${token}" \
-H "Content-Type: application/json" \
-d "{
\"entity_class\": \"proxy\",
\"subscriptions\": [
\"web\"
],
\"deregister\": false,
\"deregistration\": {},
\"metadata\": {
\"name\": \"${agent_name}\",
\"namespace\": \"default\",
\"labels\": null,
\"annotations\": null
}
}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment