Another useful SQL snippet to post today, used to identify machines where commands are stuck executing. This usually is an indication of a problem with the LabTech service on the machine, but could also mean something more underlying is broken on the client.
SELECT commands.computerid,
v_computers.computer_name,
v_computers.client_name,
Count(*) AS NumOfCommands
FROM commands
LEFT JOIN v_computers
ON commands.computerid = v_computers.computerid
WHERE status = 2
GROUP BY computerid
ORDER BY numofcommands DESC
This is great!
Since we support a LOT of laptop users, we also find this common when machines go to sleep or are closed up by the users during script execution. I’d recommend maybe adding an additional WHERE clause to ensure the system is online as well. Otherwise there’s nothing you can do about this issue anyway.