Pi losing wifi connectivity - how to detect if still printing

I can reboot or re-start the network (by script) when the network wifi fails. I believe the router is the culprit reassigning the channel. However this has happened mid print and I worry that if I reset the networking (or worse re-boot) the pi may stop a print that is still running. Can someone confirm that the last line in the octoprint.log file being a heartbeat indicates that the system is idle? If that is not what is being indicated then is there someway a script could determine that the system is idle?

You get a heartbeat message every fifteen seconds as seen below while a client is connected.

2020-01-17 10:55:49,359 - octoprint.server.heartbeat - INFO - Server heartbeat <3
2020-01-17 11:10:49,359 - octoprint.server.heartbeat - INFO - Server heartbeat <3
2020-01-17 11:25:49,360 - octoprint.server.heartbeat - INFO - Server heartbeat <3

An abrupt end without those heartbeats—to me—suggests that the server stopped or the connection to the client was lost perhaps.

If that implies connected and operational, but not currently printing, that message would do. If that message comes up during printing, then I have the possibility of accedntly rebooting while printing. The PI is not locking up, the router is changing channels and the PI is not following, thus it loses wifi connectivity. If I leave it alone it will finish the print, I just cannot monitor it.

That message comes up as long as the server is running, regardless of the state. Take a look at the command line options, there's a while API client built in that you could use directly on the machine.

Thanks, I will. I did come up with a script that analyzed the logs to see if there was a "Finished" line after the last "Start" line, but a status from the application would be better.