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/6] 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/6] 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. From 26f2a642e85f03b9719832ef77fea57513909ede Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <91930405+bird-03@users.noreply.github.com> Date: Tue, 14 Oct 2025 22:54:16 +0530 Subject: [PATCH 3/6] Update README.md Output updated --- .../Top10jobsbyprocessingtime/README.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/README.md b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/README.md index 71d501f60c..9e3717d90e 100644 --- a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/README.md +++ b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/README.md @@ -1,3 +1,38 @@ 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. + +OUTPUT: +*** Script: +Top 10 url values from syslog_transaction + + + +********** Execution Details for the column JOB: Check Glide Service Status ********** + +Executed total number of times : JOB: Check Glide Service Status 1 + +Top 10 response times : 45300 + + +********** Execution Details for the column JOB: Regenerate CRL and Flush CRL Cache ********** + +Executed total number of times : JOB: Regenerate CRL and Flush CRL Cache 1 + +Top 10 response times : 1462 + + +********** Execution Details for the column JOB: SC - Calculate Compliance ********** + +Executed total number of times : JOB: SC - Calculate Compliance 1 + +Top 10 response times : 5401 + + +********** Execution Details for the column JOB: [ITSM Analytics] Daily Data Collection ********** + +Executed total number of times : JOB: [ITSM Analytics] Daily Data Collection 1 + +Top 10 response times : 16341 + +[0:00:00.048] Total Time From e5e0dd4e64a22b68354e6d53678c07b42b5f8a5f Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <91930405+bird-03@users.noreply.github.com> Date: Tue, 14 Oct 2025 23:04:22 +0530 Subject: [PATCH 4/6] Update script.js comment has been updated --- .../Scheduled Jobs/Top10jobsbyprocessingtime/script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js index b4a4b3e084..7cab024a12 100644 --- a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js +++ b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js @@ -12,12 +12,12 @@ function topN(pTable, pColumn, pCount) { var i = 0; var stdout = []; var responseTime = []; - stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); + stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); // creates a readable header line that will be show in the script output Rg. Top 10 url values from syslog_transaction 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); + var result1 = getResponseTimeDetails(pTable, 'type=scheduler^sys_created_onONLast 15 minutes@javascript:gs.beginningOfLast15Minutes()@javascript:gs.endOfLast15Minutes()^url=' + ga.getValue(pColumn)); // get output for job executed last 15min + stdout.push('Executed total number of times : ' + ga.getValue(pColumn) + ' ' + ga.getAggregate('COUNT', pColumn)); // this will give result like last 15 min how many time a particular job has been executed EG. 'JOB: Check Glide Service Status' executed 'n' times + stdout.push('\nTop 10 response times : ' + result1); // this willl return the response time } gs.print(stdout.join("\n")); } From b3c4f6aad23bb1470c64bbe0472c8d1f14bafb03 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <91930405+bird-03@users.noreply.github.com> Date: Tue, 14 Oct 2025 23:05:14 +0530 Subject: [PATCH 5/6] Update script.js output commented and updated --- .../Top10jobsbyprocessingtime/script.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js index 7cab024a12..c295317cd9 100644 --- a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js +++ b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js @@ -33,3 +33,40 @@ function getResponseTimeDetails(table, query) { } return responseTime.join(','); } + +/* +****************OUTPUT************** +*** Script: +Top 10 url values from syslog_transaction + + + +********** Execution Details for the column JOB: Check Glide Service Status ********** + +Executed total number of times : JOB: Check Glide Service Status 1 + +Top 10 response times : 45300 + + +********** Execution Details for the column JOB: Regenerate CRL and Flush CRL Cache ********** + +Executed total number of times : JOB: Regenerate CRL and Flush CRL Cache 1 + +Top 10 response times : 1462 + + +********** Execution Details for the column JOB: SC - Calculate Compliance ********** + +Executed total number of times : JOB: SC - Calculate Compliance 1 + +Top 10 response times : 5401 + + +********** Execution Details for the column JOB: [ITSM Analytics] Daily Data Collection ********** + +Executed total number of times : JOB: [ITSM Analytics] Daily Data Collection 1 + +Top 10 response times : 16341 + +[0:00:00.048] Total Time +*/ From d9f19ccdb4a9cb1179920f6f0026629fefe77f35 Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <91930405+bird-03@users.noreply.github.com> Date: Tue, 14 Oct 2025 23:15:43 +0530 Subject: [PATCH 6/6] Update script.js --- .../Top10jobsbyprocessingtime/script.js | 78 +++++++++---------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js index c295317cd9..b8f73480da 100644 --- a/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js +++ b/Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime/script.js @@ -1,33 +1,40 @@ -/* -Top 10 scheduled jobs by processing time +* +Query the table SYS_LOG_TRANSACTION to identify the TOP 10 Schedule Job by Number of times it executed in one day and How much processing time it took to complete the execution +>>>>> Go to https:///syslog_transaction_list.do?sysparm_query=urlLIKE and check the "Transaction processing time" +This will help to identify top contibutors that consume instance resource and can potentially cause slowness +You can execute this as Background scipt or Fix script */ 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.addEncodedQuery('sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()^type=scheduler'); // Schedle job executed yesterday to identify Top 10 by execution time + ga.addEncodedQuery('type=scheduler^sys_created_onONLast 15 minutes@javascript:gs.beginningOfLast15Minutes()@javascript:gs.endOfLast15Minutes()'); // Schedle job executed in last 15 min to identify Top 10 by execution time ga.query(); var i = 0; var stdout = []; var responseTime = []; - stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); // creates a readable header line that will be show in the script output Rg. Top 10 url values from syslog_transaction + stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); //Get all Top 10 ScheduleJon details 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)); // get output for job executed last 15min - stdout.push('Executed total number of times : ' + ga.getValue(pColumn) + ' ' + ga.getAggregate('COUNT', pColumn)); // this will give result like last 15 min how many time a particular job has been executed EG. 'JOB: Check Glide Service Status' executed 'n' times - stdout.push('\nTop 10 response times : ' + result1); // this willl return the response time + 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)); // Schedle job executed in last 15 min to identify Top 10 by execution time + 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")); } + +// Fetch response Time of the schedule job Execution function getResponseTimeDetails(table, query) { var responseTime = []; var gr = new GlideAggregate(table); gr.addEncodedQuery(query); gr.orderByDesc('response_time'); - gr.setLimit(10); + gr.setLimit(10); // Set limit to 10 gr.query(); + while (gr._next()) { responseTime.push(gr.response_time.toString()); } @@ -35,38 +42,25 @@ function getResponseTimeDetails(table, query) { } /* -****************OUTPUT************** +******************OUTPUT************ *** Script: Top 10 url values from syslog_transaction - - - -********** Execution Details for the column JOB: Check Glide Service Status ********** - -Executed total number of times : JOB: Check Glide Service Status 1 - -Top 10 response times : 45300 - - -********** Execution Details for the column JOB: Regenerate CRL and Flush CRL Cache ********** - -Executed total number of times : JOB: Regenerate CRL and Flush CRL Cache 1 - -Top 10 response times : 1462 - - -********** Execution Details for the column JOB: SC - Calculate Compliance ********** - -Executed total number of times : JOB: SC - Calculate Compliance 1 - -Top 10 response times : 5401 - - -********** Execution Details for the column JOB: [ITSM Analytics] Daily Data Collection ********** - -Executed total number of times : JOB: [ITSM Analytics] Daily Data Collection 1 - -Top 10 response times : 16341 - -[0:00:00.048] Total Time +*** Execution Details for the column JOB: Flow Engine Event Handler *** +Executed total number of times : JOB: Flow Engine Event Handler[ 290 ] +Top 10 response times : 58018,57294,56949,39272,38874,38174,38085,37490,37138,36447,25947 +********** Execution Details for the column JOB: BackgroundProgressJob ********** +Executed total number of times : JOB: BackgroundProgressJob[ 221 ] +Top 10 response times : 8671,7646,7050,7040,7035,7008,6993,6987,6880,6861,6803 +********** Execution Details for the column JOB: ASYNC: AgentNowResponse********** +Executed total number of times : JOB: ASYNC: AgentNowResponse [ 576 ] +Top 10 response times : 17680,13488,12094,11999,11579,11281,10672,10620,9688,9552,9373 +********** Execution Details for the column JOB: events process********** +Executed total number of times : JOB: events process [ 075 ] +Top 10 response times : 26986,14921,14102,13640,13603,3870,3808,3665,3360,3277,3001 +********** Execution Details for the column JOB: Service Mapping********** +Executed total number of times : JOB: Service Mapping Recomputation[ 167 ] +Top 10 response times : 24035,11209,9297,8431,7857,7142,6555,6541,6218,6124,5855 +********** Execution Details for the column JOB: Event Management ********** +Executed total number of times : JOB: Event Management[ 64 ] +Top 10 response times : 939,744,729,644,629,598,585,534,533,518,452 */