K1000: Reporting for Scripting Logs
Hello,
We currently have a few scripts that run on a schedule. Is there a way I can run a report to check the Scripting Logs for all machines to see if they were successfull or not? Right now the only way for me to check if the script ran is to individually go to the inventory for each machine and check the "Scripting Logs" under the Logs category to see if the scripts ran on a machine. I can't seem to find any option in the reporting to run such report, perhaps I am missing something simple. Any suggestions are welcome.
Thank you,
Answers (1)
See if something like this will work for you. Let me know if you need it modified.
http://www.itninja.com/question/scripting-report
Comments:
-
This seems to work, but only if the script is run now. Anything that is on a schedule does not seem to be displayed. - pregiec 11 years ago
-
Hmmm.... just noticed that. Try this. I'm not sure what all info you need. I don't have a ton of scheduled scripts to test this off of. One thing I did notice is that when you do pull up the scripting logs if the script was successful it had a status of "2". Looks like if it was not it has a "3" it was not. So if you were wanting to limit the results you could add KL.STATUS = '2'.
SELECT DISTINCT M.NAME, K.NAME, KL.START_TIME, KL.STOP_TIME, KL.STATUS
FROM MACHINE M
LEFT JOIN KBOT_LOG KL ON M.ID= KL.MACHINE_ID
LEFT JOIN KBOT K ON K.ID =KL.KBOT_ID
WHERE K.NAME LIKE 'FORCE CHECK-IN NEW%'
AND K.ENABLED ='1'
ORDER BY M.NAME - dugullett 11 years ago-
Do you know if it is possible to pull data into this report? Specifically I am having a script check for some information in a file. The output log of the script show the file info, I just do not know how to get that data to show up on this report. - drknite 7 years ago
-
You are uploading a file at the end of the script, or you have a custom inventory reading the file? - dugullett 7 years ago
-
@drknite, you need to add a JOIN to the table KBOT_LOG_DETAIL to get the logged output of a script:
LEFT JOIN KBOT_LOG_DETAIL KLD ON KL.STATUS_DETAIL_ID = KLD.ID
Then I added KLD.TEXT to the Select, and it returned what was in the items logged to Status.
Note that there are four options for report output, and thus four options for the column you use to join KBOT_LOG_DETAIL:
STATUS_DETAIL_ID
DEBUG_DETAIL_ID
OUTPUT_DETAIL_ID
ACTIVITY_DETAIL_ID
You could join KBOT_LOG_DETAIL on more than of these separately, if you wanted to get more than one section of the log in one report, just give the table a different alias (KLD2, KLD3, &C.). - ondrar 7 years ago
-
That seemed to work well. Although, from a few tests, it would look like a status of 1 would be successful. Thanks for the help, much appreciated. - pregiec 11 years ago