Thank you for your answer Thomas.
I've coded a simple C program which does what you said. It can be called from ARexx as any regular CLI command to get the info.
Here's the link in case anyone else wants to use it on his/her own ARexx scripts.
https://aminet.net/package/util/cli/gcr10