Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Contributor

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.

Copy link
Contributor Author

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

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)) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
Copy link
Contributor

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?

Copy link
Contributor Author

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

gr.query();
while (gr._next()) {
responseTime.push(gr.response_time.toString());
Copy link
Contributor

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

}
return responseTime.join(',');
}
Loading