Get info for running scripts like how "gateway status / running scripts" shows them

Has someone ever attempted to get info about a gateways running script in a format that is similar to how the gateway webpage shows.

I have a gateway that I want to be able to do certain things only if a script is actually running. I looked at the thread dumps, but those are really hard to parse.

Basically I'd like to to put in some automated based on the information that is displayed here