Machines Failed For Scheduled Scripts
I have a number of scheduled scripts with Smart Labels of machines attached. Does anyone have a SQL query for determining which machines failed, or did not report back the KBOT_LOG. I want to build a report for a specific time range and script name to determine failures. Some of what I have figured out is if a machine fails no entry will be written to the ORGX.KBOT_LOG table. But I cannot find a table that has failures for scheduled scripts. One direction I was going to try was checking the machines in the label that do not have entries in the ORGX.KBOT_LOG table using the following tables. ORGX.MACHINE_LABLEL_JT, ORGX.LABEL, ORGX.MACHINE, and ORGX.KBOT_LOG. Thanks!
Answers (3)
Build a Smart Label that looks for machines with that label AND does not have whatever you are possibly deploying if it is a software title.
You could also have it log a message with whatever you want to search for and after running the script go to Scripting > Search Logs and search for that special text you have logged based on the outcome of that script.
Comments:
-
Going with this scenario... if you change your script to log a message, it will be searchable after the next scheduled run. You will only want to search the default history selection of 'Search only the most resent logs for each machine'. - worzie 11 years ago
This will get you all machines that have a LOG_ID of NULL, and that have attempted deployment in the past 7 days. I did push a script out to a machine that was off so it did fail, but it did return a LOG_ID. So maybe looking for NULL doesn't determine if it did fail? I think determining what the numbers in KBOT_RUN_MACHINE.REQUEST_STATUS represent. I'm assuming 200=Success. For the one I tested on the off machine it returned a 404 (failure?). I don't use scripts very often. Maybe support can better answer what those numbers are. I'm sure there's one for pending as well.
SELECT DISTINCT M.NAME, IP, USER_LOGGED, KM.REQUEST_TIME FROM MACHINE M LEFT JOIN KBOT_RUN_MACHINE KM ON M.ID=KM.MACHINE_ID LEFT JOIN KBOT_RUN K ON K.ID=KM.KBOT_RUN_ID LEFT JOIN KBOT KB ON KB.ID=K.KBOT_ID LEFT JOIN MACHINE_LABEL_JT MLJT ON MLJT.MACHINE_ID = M.ID LEFT JOIN LABEL L ON L.ID = MLJT.LABEL_ID WHERE KM.KBOT_LOG_ID IS NULL AND KB.NAME LIKE '%<ENTER SCRIPT NAME>%' AND L.NAME LIKE '%<ENTER LABEL NAME>%' AND KM.REQUEST_TIME > DATE_SUB(NOW(), INTERVAL 7 DAY)
If you did want to look for machines that did have a status of 404 replace KM.KBOT_LOG_ID IS NULL with KM.REQUEST_STATUS = '404'.
Comments:
-
Nevermind on that 200=Success. I just found one that had 200, but did not return a log file. So I guess the best bet would be to add an OR KM.REQUEST_STATUS = '404'. Make sure to enclose (KM.KBOT_LOG_ID IS NULL OR KM.REQUEST_STATUS = '404') in parenthesis. - dugullett 11 years ago
The scripts I am trying to determine failures for are scheduled. If I am thinking about this correctly the KBOT_RUN_MACHINE only contains information on scripts kicked off by Run Now. There has to be a better way to determine failures.
Comments:
-
Maybe I'm misunderstanding your question? If you take out the KB.NAME LIKE '%<ENTER SCRIPT NAME>%' AND L.NAME LIKE '%<ENTER LABEL NAME>%' portion, and adjust the date settings you should see what you need. - dugullett 11 years ago