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.
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.
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.
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.
| var gr = new GlideAggregate(table); | ||
| gr.addEncodedQuery(query); | ||
| gr.orderByDesc('response_time'); | ||
| gr.setLimit(10); |
There was a problem hiding this comment.
Why are you using 10 hardcoded here and in the rest of the code the pCount?
There was a problem hiding this comment.
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.
Remove commented out code. If this is an optional line people can enable, please describe it.
There was a problem hiding this comment.
@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