How can we write the service that check status of SAP system down or up

Dear all,

I want to write the monitoring service that check the SAP system is currently up or down and make sure that SAP is really down not from the SAP Adapter down. How can we get the status of SAP System?


sap.admin.listener:list in SAP Package lists the listeners for a server. Also the status of the Listener is returned.