Not sure about a script as i am unsure what properties would accurately monitor the agent health but this might help..
What you really need to do to chekc the health of an SCCM agent is make sure it is talking with its management point in the C:\WINNT\system32\CCM\Logs\clientlocation.log.
If there are no errors in there and there is communication with the management point then the agent should be working fine