From 5c2cd43a5a89c857035358a3df8d3cf247508883 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <91930405+bird-03@users.noreply.github.com> Date: Mon, 6 Oct 2025 00:49:28 +0530 Subject: [PATCH 1/2] Create script.js Identify top 10 contributors from schedule jobs by processing time --- .../Top10jobsbyprocessingtime/script.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js diff --git a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js new file mode 100644 index 0000000000..b4a4b3e084 --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js @@ -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)) { + 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); + gr.query(); + while (gr._next()) { + responseTime.push(gr.response_time.toString()); + } + return responseTime.join(','); +} From c2be4be92d7a790f986a88197ba815a3a5f3b47c Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <91930405+bird-03@users.noreply.github.com> Date: Mon, 6 Oct 2025 00:52:39 +0530 Subject: [PATCH 2/2] Create README.md 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. --- .../Scheduled Jobs/Top10jobsbyprocessingtime/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/README.md diff --git a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/README.md b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/README.md new file mode 100644 index 0000000000..71d501f60c --- /dev/null +++ b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/README.md @@ -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.