-
Notifications
You must be signed in to change notification settings - Fork 908
Top10schedluejobcount #1832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Top10schedluejobcount #1832
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| This is script will be useful to montior your system performance by identifying the top contributors from schedule jobs by processing time to take necessary action. | ||
|
|
||
| In this script time intervalis updated as last 15 min but in ideal scenario this should be scheduled everyday to get the count report and montior the schedule job that is take more time to get completed. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /* | ||
| Top 10 scheduled jobs by processing time | ||
| */ | ||
| topN('syslog_transaction', 'url', 10); | ||
| function topN(pTable, pColumn, pCount) { | ||
| var ga = new GlideAggregate(pTable); | ||
| ga.addAggregate('COUNT', pColumn); | ||
| ga.orderByAggregate('COUNT', pColumn); | ||
| //ga.addEncodedQuery('sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()^type=scheduler'); | ||
| ga.addEncodedQuery('type=scheduler^sys_created_onONLast 15 minutes@javascript:gs.beginningOfLast15Minutes()@javascript:gs.endOfLast15Minutes()'); | ||
| ga.query(); | ||
| var i = 0; | ||
| var stdout = []; | ||
| var responseTime = []; | ||
| stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); | ||
| while (ga.next() && (i++ < pCount)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment here to explain what you are doing and why? This will help others understand. Perhaps even easier: give an example output in the readme.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
| stdout.push('\n\n********** Execution Details for the column ' + ga.getValue(pColumn) + ' **********\n'); | ||
| var result1 = getResponseTimeDetails(pTable, 'type=scheduler^sys_created_onONLast 15 minutes@javascript:gs.beginningOfLast15Minutes()@javascript:gs.endOfLast15Minutes()^url=' + ga.getValue(pColumn)); | ||
| stdout.push('Executed total number of times : ' + ga.getValue(pColumn) + ' ' + ga.getAggregate('COUNT', pColumn)); | ||
| stdout.push('\nTop 10 response times : ' + result1); | ||
| } | ||
| gs.print(stdout.join("\n")); | ||
| } | ||
| function getResponseTimeDetails(table, query) { | ||
| var responseTime = []; | ||
| var gr = new GlideAggregate(table); | ||
| gr.addEncodedQuery(query); | ||
| gr.orderByDesc('response_time'); | ||
| gr.setLimit(10); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you using 10 hardcoded here and in the rest of the code the pCount?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to get the number of execution a particule job has been executed for given query Eg. last 15 min |
||
| gr.query(); | ||
| while (gr._next()) { | ||
| responseTime.push(gr.response_time.toString()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are using glideAggregate, should this be a glideRecord instead? As you want to use setLimit and get the value of response_time for 10 records only |
||
| } | ||
| return responseTime.join(','); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented out code. If this is an optional line people can enable, please describe it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WillemZeiler
Line-9 has been commented on purpose to not run this script for all records executed yesterday as 'syslog_transaction' is a system table that stores logs for various transactions in the platform. This is kept and commet to give an option to schedule this script if required and can run every night out-of-business hours to get the list of top 10 contributors by type 'scheduler'.
Hope this help, if still needs to be remove happy to do that