The way the program detects the state of the modem is built into the sampling process. At each stage there is a success or failure, and if there's a failure a message is displayed to say what failed. Up to and including the result "No stats received", further actions are aborted until the next sample is due.
What I may not have got quite right is the linking of the custom commands to the various failure results, so I'll be looking more closely at that. I'm also uncomfortable about what happens during and after standby, because I have no idea in what order the different parts of the system come back to life. What I'd like to do is put DSLstats on pause immediately before the system goes into standby, and unpause it after the system has returned to life, but implementing this is beyond me at the moment.