Page MenuHomePhabricator
Paste P7881

Netbox extract serial and asset tag
ActivePublic

Authored by Volans on Dec 3 2018, 11:56 PM.
Tags
None
Referenced Files
F27369772: Netbox extract serial and asset tag
Dec 3 2018, 11:56 PM
Subscribers
None
#!/bin/bash
TOKEN=""
if [[ -z "${1}" ]]; then
echo "Usage: ${0} SERVER_NAME"
exit 1
fi
NAME="${1}"
curl -sH "Authorization: Token ${TOKEN}" -H "Accept: application/json;" https://netbox.wikimedia.org/api/dcim/devices/?name=${NAME} | jq '.results[] | .name + " | " + .serial + " | " + .asset_tag'