#!/bin/bash trap "exit" INT TERM ERR trap "kill 0" EXIT HOSTS=${1:-50000} SLEEP_TIME="0.05" RUN_DATE=`date` #$BASE_URL="tower2.thezengarden.net" BASE_URL="10.10.42.225" AAP_INVENTORY=42 POST_PAYLOAD_PATH="post.add_host" POST_PAYLOAD_TYPE="application/json" #TOWER_TOKEN="jQwHURhs9fNNyombPLEAK8a2vRmmBQ" TOWER_TOKEN="YtLStVtkMGKxnWinslNiqDgYwZqKfM" echo "Script start time: $(date '+%F %T %Z')" for i in $(seq $HOSTS) do DESC_DATE=`date "+%F %T %Z"` /usr/bin/time -f "%e" curl -s -k -H "Authorization: Bearer ${TOWER_TOKEN}" \ -H "Content-type: ${POST_PAYLOAD_TYPE}" \ -X POST \ -d "{\"name\": \"new-sample-host-${i}\", \"description\": \"added ${DESC_DATE}\"}" \ "https://${BASE_URL}/api/v2/inventories/${AAP_INVENTORY}/hosts/" | jq '{created_time:.["created"], hostname:.["name"], inventory:.["summary_fields"]["inventory"]["name"]}' & sleep ${SLEEP_TIME} echo done wait echo "Script end time: $(date '+%F %T %Z')"