|
| 1 | +* |
| 2 | +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 |
| 3 | +>>>>> Go to https://<your instance URL>/syslog_transaction_list.do?sysparm_query=urlLIKE<your scheduled job name> and check the "Transaction processing time" |
| 4 | +This will help to identify top contibutors that consume instance resource and can potentially cause slowness |
| 5 | +You can execute this as Background scipt or Fix script |
| 6 | +*/ |
| 7 | +topN('syslog_transaction', 'url', 10); |
| 8 | + |
| 9 | +function topN(pTable, pColumn, pCount) { |
| 10 | + var ga = new GlideAggregate(pTable); |
| 11 | + ga.addAggregate('COUNT', pColumn); |
| 12 | + ga.orderByAggregate('COUNT', pColumn); |
| 13 | + //ga.addEncodedQuery('sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()^type=scheduler'); // Schedle job executed yesterday to identify Top 10 by execution time |
| 14 | + 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 |
| 15 | + ga.query(); |
| 16 | + var i = 0; |
| 17 | + var stdout = []; |
| 18 | + var responseTime = []; |
| 19 | + stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); //Get all Top 10 ScheduleJon details |
| 20 | + while (ga.next() && (i++ < pCount)) { |
| 21 | + stdout.push('\n\n***Execution Details for the column ' + ga.getValue(pColumn) + '***\n'); |
| 22 | + 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 |
| 23 | + stdout.push('Executed total number of times : ' + ga.getValue(pColumn) + ' ' + ga.getAggregate('COUNT', pColumn)); |
| 24 | + stdout.push('\nTop 10 response times : ' + result1); |
| 25 | + } |
| 26 | + gs.print(stdout.join("\n")); |
| 27 | +} |
| 28 | + |
| 29 | +// Fetch response Time of the schedule job Execution |
| 30 | +function getResponseTimeDetails(table, query) { |
| 31 | + var responseTime = []; |
| 32 | + var gr = new GlideAggregate(table); |
| 33 | + gr.addEncodedQuery(query); |
| 34 | + gr.orderByDesc('response_time'); |
| 35 | + gr.setLimit(10); // Set limit to 10 |
| 36 | + gr.query(); |
| 37 | + |
| 38 | + while (gr._next()) { |
| 39 | + responseTime.push(gr.response_time.toString()); |
| 40 | + } |
| 41 | + return responseTime.join(','); |
| 42 | +} |
| 43 | + |
| 44 | +/* |
| 45 | +******************OUTPUT************ |
| 46 | +*** Script: |
| 47 | +Top 10 url values from syslog_transaction |
| 48 | +*** Execution Details for the column JOB: Flow Engine Event Handler *** |
| 49 | +Executed total number of times : JOB: Flow Engine Event Handler[ 290 ] |
| 50 | +Top 10 response times : 58018,57294,56949,39272,38874,38174,38085,37490,37138,36447,25947 |
| 51 | +********** Execution Details for the column JOB: BackgroundProgressJob ********** |
| 52 | +Executed total number of times : JOB: BackgroundProgressJob[ 221 ] |
| 53 | +Top 10 response times : 8671,7646,7050,7040,7035,7008,6993,6987,6880,6861,6803 |
| 54 | +********** Execution Details for the column JOB: ASYNC: AgentNowResponse********** |
| 55 | +Executed total number of times : JOB: ASYNC: AgentNowResponse [ 576 ] |
| 56 | +Top 10 response times : 17680,13488,12094,11999,11579,11281,10672,10620,9688,9552,9373 |
| 57 | +********** Execution Details for the column JOB: events process********** |
| 58 | +Executed total number of times : JOB: events process [ 075 ] |
| 59 | +Top 10 response times : 26986,14921,14102,13640,13603,3870,3808,3665,3360,3277,3001 |
| 60 | +********** Execution Details for the column JOB: Service Mapping********** |
| 61 | +Executed total number of times : JOB: Service Mapping Recomputation[ 167 ] |
| 62 | +Top 10 response times : 24035,11209,9297,8431,7857,7142,6555,6541,6218,6124,5855 |
| 63 | +********** Execution Details for the column JOB: Event Management ********** |
| 64 | +Executed total number of times : JOB: Event Management[ 64 ] |
| 65 | +Top 10 response times : 939,744,729,644,629,598,585,534,533,518,452 |
| 66 | +*/ |
0 commit comments