You probably don't need to write such a search yourself. You should start with the overview dashboard in the Distributed Management Console. It will show you your deployment topology and whether any indexers are down. If you have not configured the Distributed Management Console, see the Distributed Management Console documentation.
If you are using indexer clustering, the cluster master dashboard will also show you what indexers are up and down.
The DMC has preconfigured alerts for what you want. Enable the "Search Peer Not Responding" alert.
DMC Alert - Abnormal State of Indexer Processor 
One or more of your indexers is reporting an abnormal state.
DMC Alert - Critical System Physical Memory Usage 
One or more instances has exceeded 90% memory usage.
DMC Alert - Expired and Soon To Expire Licenses 
You have licenses that expire or will expire within two weeks.
DMC Alert - Missing forwarders 
One or more forwarders are missing.
DMC Alert - Near Critical Disk Usage 
You have used 80% of your disk capacity.
DMC Alert - Saturated Event-Processing Queues 
One or more of your indexer queues is reporting a fill percentage, averaged over the last 15 minutes, of 90% or more.
DMC Alert - Search Peer Not Responding 
One or more of your search peers is currently down.
DMC Alert - Total License Usage Near Daily Quota