Task to Start Service based on a database server being online

I am struggling to come up with a fixlet that can start a service on a computer only if the associated database server is online.

Anyone have any suggestions? For testing i am using the service: “atashost” and so far I have tried this relevance to determine if the server is online before running the action with no luck:

(version of client >= “6.0.0.0”) AND ((exists true whose (if true then (Windows of operating system AND exists services whose (service name of it = “atashost” AND state of it as string != “running”)) else false)) AND (exists true whose (if true then ((( IDs of it, Names of it, concatenation "; " of (it as string) of IP Addresses of it, Operating Systems of it, value of results from (bes property whose (name of it = “Boot Time”)) of it | “Not reported” ) of DBServer) > 1*day) else false)))

In your example above, you are mixing client relevance and session relevance, which isn’t possible. Is there any way you can determine whether the database server is online from your target computer?

The first way that comes to my mind is to have a fixlet relevant on your target computer when the service is not running. It would reapply whenever relevant and check if it could successfully ping the other server, then continue the fixlet if it could. Maybe not the prettiest solution, but conceptually I think it should work.

delete C:\tmp\ping.txt
wait ping dbserver > C:\tmp\ping.txt 

continue if {exists file "C:\tmp\ping.txt" whose (exists lines containing "Received = 4" of it)}
wait net start atashost

Good idea. I recall another utility, either tcpping or rcpping I think, that could check whether the specific port used by the database service is responding.