Script: After some lost ping, to set other channel

Can anybody help me to create script, which will change the preddefined channel, when some ping of some ip will lost?