I'm aware the top level is called an MDS. That's why I called it an MDS. When run on an MDS, that smaller script only runs in the current environment. It doesn't run over the CMAs which are on that MDS. Nice if you want to get data only for that CMA, but needs an additional loop if you want to iterate over all the CMAs on the box.
It doesn't provide feedback on what it's trying to do, which provides important context for failures. For example, here's slightly redacted output from one of my CMAs:
vsxMember2
Check Point Gaia R80.20
vsxMember1
Check Point Gaia R80.20
(NULL BUF)
(NULL BUF)
(NULL BUF)
(NULL BUF)
(NULL BUF)
(NULL BUF)
Which devices did it fail to talk to? By changing 'do cprid_util' to 'do echo "$i:";cprid_util', I found that it tries to connect to a bunch of VSs and switch contexts, but those fail silently because their IP address is 0.0.0.0. It tries to connect to the standby CMA, but that CMA's representation in objects.C has the IP address before the SIC name, so the 'grep -A 1 sic_name' instead gets the IP address of some random other object which happens to be next in the file. Same thing happens with my CLMs and my SmartEvent server. My firewall in FIPS mode at least gets an address from its topology table, but it's nowhere close to the right one. These connections fail, which wouldn't ordinarily be a problem, but now my logs show my management server trying to connect out to things it isn't managing. That makes people in my SOC ask if the MDS has been compromised.
Here's the output from mine trimmed down to the same CMA:
myFirstCMA 10.20.30.41: vsxMember1 R80.20 211 11:12:13 up 61 days
myFirstCMA 10.20.30.42: vsxMember2 R80.20 211 11:12:14 up 61 days
myFirstCMA 10.20.30.44: (NULL BUF)
myFirstCMA 10.20.30.45: (NULL BUF)
Shorter, with context for the failures. It also got the right IP address for the members of my firewall in FIPS mode. If I wanted to run commands via CPRID on a standby SmartCenter, a log server, or a SmartEvent server, the shorter script would just fail, since it's getting IPs for completely incorrect objects. My script could be easily modified to do so by removing the '| grep -v "checkpoint-host" \' line.