The management server doesn't know the hostname of the firewalls or any uniquely identifying information about the hardware.
Rather than serial number, you should track the boxes by the MAC address listed on the same label. The license is to the MAC address, as is the support contract.
You can use this script to find all of the physical cluster members and physical VSX gateways reporting to a management (up to 120 clusters or so, maybe fewer if you use a lot of VSs), then use CPRID to run commands on each:
portNumber=$(api status | grep "APACHE Gaia Port" | awk '{print $NF}')
unset cmaList
. /etc/profile.d/CP.sh
cmaList=$(mgmt_cli --port "${portNumber}" -f json -r true show domains limit 500 details-level full \
| jq -c '.objects[]|{name:.name,server:.servers[]|{host:."multi-domain-server",ipAddress:."ipv4-address"}}' \
| grep $(hostname) \
| jq -c '[.name,.server.ipAddress]')
if [ ${#cmaList} -eq 0 ];then cmaList=("[\"$(hostname)\",\"\"]");fi
for cmaRow in $cmaList; do
cmaName=$(echo "${cmaRow}" | jq '.[0]' | sed 's#"##g')
cmaAddress=$(echo "${cmaRow}" | jq '.[1]' | sed 's#"##g')
mdsenv "${cmaAddress}" 2>/dev/null
firewallList=$(mgmt_cli --port "${portNumber}" -f json -d "${cmaAddress}" -r true show gateways-and-servers limit 500 details-level full \
| jq -c '.objects[]|{type:.type,address:."ipv4-address"}' \
| grep -v CpmiGatewayCluster \
| grep -v CpmiVsClusterNetobj \
| grep -v CpmiVsxClusterNetobj \
| grep -v "checkpoint-host" \
| jq -c '.address' \
| sed 's#"##g')
for firewall in $firewallList; do
printf "%15s %15s: " "${cmaName}" "${firewall}"
cprid_util -verbose -server "${firewall}" rexec -rcmd sh -c '
########################################
### Script to run on each firewall goes here.
########################################
'
done
done
As an example of the kind of script you can run on each firewall, I use this periodically to get hostname, hardware, major version, jumbo, and uptime:
printf "%-25s %-5s %-6s %3s " \
$(hostname) \
$(clish -c "show asset system" | egrep -q "^Model";if [ $? -eq 0 ];then clish -c "show asset system" | egrep "^Model" | awk "{print $NF}";else clish -c "show asset system" | egrep "^Platform" | cut -d" " -f2 | cut -c 1-5;fi) \
$(fw ver | awk "{print $7}") \
$(cpinfo -y fw1 2>/dev/null | grep Take | awk "{print $NF}")
echo -n $(uptime | cut -d, -f1)
I wanted a table, so I used printf. If you want CSV, change all of the format specifiers to "%s" (instead of "%-25s", for example) and replace all the spaces with commas.