-
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
Conversation
Identify top 10 contributors from schedule jobs by processing time
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.
WillemZeiler
left a comment
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.
Thank you for your submission. Please double check your code. I have added some comments to guide you.
| gr.setLimit(10); | ||
| gr.query(); | ||
| while (gr._next()) { | ||
| responseTime.push(gr.response_time.toString()); |
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.
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
| var stdout = []; | ||
| var responseTime = []; | ||
| stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); | ||
| while (ga.next() && (i++ < pCount)) { |
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.
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.
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.
Added
| var gr = new GlideAggregate(table); | ||
| gr.addEncodedQuery(query); | ||
| gr.orderByDesc('response_time'); | ||
| gr.setLimit(10); |
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.
Why are you using 10 hardcoded here and in the rest of the code the pCount?
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.
to get the number of execution a particule job has been executed for given query Eg. last 15 min
| 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'); |
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
PR Description:
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.
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions