|
1 | | -/* |
2 | | -Top 10 scheduled jobs by processing time |
| 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 |
3 | 6 | */ |
4 | 7 | topN('syslog_transaction', 'url', 10); |
| 8 | + |
5 | 9 | function topN(pTable, pColumn, pCount) { |
6 | 10 | var ga = new GlideAggregate(pTable); |
7 | 11 | ga.addAggregate('COUNT', pColumn); |
8 | 12 | ga.orderByAggregate('COUNT', pColumn); |
9 | | - //ga.addEncodedQuery('sys_created_onONYesterday@javascript:gs.beginningOfYesterday()@javascript:gs.endOfYesterday()^type=scheduler'); |
10 | | - ga.addEncodedQuery('type=scheduler^sys_created_onONLast 15 minutes@javascript:gs.beginningOfLast15Minutes()@javascript:gs.endOfLast15Minutes()'); |
| 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 |
11 | 15 | ga.query(); |
12 | 16 | var i = 0; |
13 | 17 | var stdout = []; |
14 | 18 | var responseTime = []; |
15 | | - 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 |
| 19 | + stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); //Get all Top 10 ScheduleJon details |
16 | 20 | while (ga.next() && (i++ < pCount)) { |
17 | | - stdout.push('\n\n********** Execution Details for the column ' + ga.getValue(pColumn) + ' **********\n'); |
18 | | - 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 |
19 | | - 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 |
20 | | - stdout.push('\nTop 10 response times : ' + result1); // this willl return the response time |
| 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); |
21 | 25 | } |
22 | 26 | gs.print(stdout.join("\n")); |
23 | 27 | } |
| 28 | + |
| 29 | +// Fetch response Time of the schedule job Execution |
24 | 30 | function getResponseTimeDetails(table, query) { |
25 | 31 | var responseTime = []; |
26 | 32 | var gr = new GlideAggregate(table); |
27 | 33 | gr.addEncodedQuery(query); |
28 | 34 | gr.orderByDesc('response_time'); |
29 | | - gr.setLimit(10); |
| 35 | + gr.setLimit(10); // Set limit to 10 |
30 | 36 | gr.query(); |
| 37 | + |
31 | 38 | while (gr._next()) { |
32 | 39 | responseTime.push(gr.response_time.toString()); |
33 | 40 | } |
34 | 41 | return responseTime.join(','); |
35 | 42 | } |
36 | 43 |
|
37 | 44 | /* |
38 | | -****************OUTPUT************** |
| 45 | +******************OUTPUT************ |
39 | 46 | *** Script: |
40 | 47 | Top 10 url values from syslog_transaction |
41 | | -
|
42 | | -
|
43 | | -
|
44 | | -********** Execution Details for the column JOB: Check Glide Service Status ********** |
45 | | -
|
46 | | -Executed total number of times : JOB: Check Glide Service Status 1 |
47 | | -
|
48 | | -Top 10 response times : 45300 |
49 | | -
|
50 | | -
|
51 | | -********** Execution Details for the column JOB: Regenerate CRL and Flush CRL Cache ********** |
52 | | -
|
53 | | -Executed total number of times : JOB: Regenerate CRL and Flush CRL Cache 1 |
54 | | -
|
55 | | -Top 10 response times : 1462 |
56 | | -
|
57 | | -
|
58 | | -********** Execution Details for the column JOB: SC - Calculate Compliance ********** |
59 | | -
|
60 | | -Executed total number of times : JOB: SC - Calculate Compliance 1 |
61 | | -
|
62 | | -Top 10 response times : 5401 |
63 | | -
|
64 | | -
|
65 | | -********** Execution Details for the column JOB: [ITSM Analytics] Daily Data Collection ********** |
66 | | -
|
67 | | -Executed total number of times : JOB: [ITSM Analytics] Daily Data Collection 1 |
68 | | -
|
69 | | -Top 10 response times : 16341 |
70 | | -
|
71 | | -[0:00:00.048] Total Time |
| 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 |
72 | 66 | */ |
0 commit comments