Enable/disable check automatically

Hi
I need to enable check automatically when the host start and disable check when the host is turned off.
Because I have any virtual machines that run or stop random when a user needs.
anyone have any idea?

use service dependency.
and depend the tests on ping.

I am also facing the same problem from many days and I have tried different solutions but they all are not working. I have tried the above solution as well but then also it has not solved my problem.