Skip to content

Commit d9f19cc

Browse files
authored
Update script.js
1 parent b3c4f6a commit d9f19cc

File tree

1 file changed

+36
-42
lines changed
  • Server-Side Components/Scheduled Jobs/Top10jobsbyprocessingtime

1 file changed

+36
-42
lines changed
Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,66 @@
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
36
*/
47
topN('syslog_transaction', 'url', 10);
8+
59
function topN(pTable, pColumn, pCount) {
610
var ga = new GlideAggregate(pTable);
711
ga.addAggregate('COUNT', pColumn);
812
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
1115
ga.query();
1216
var i = 0;
1317
var stdout = [];
1418
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
1620
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);
2125
}
2226
gs.print(stdout.join("\n"));
2327
}
28+
29+
// Fetch response Time of the schedule job Execution
2430
function getResponseTimeDetails(table, query) {
2531
var responseTime = [];
2632
var gr = new GlideAggregate(table);
2733
gr.addEncodedQuery(query);
2834
gr.orderByDesc('response_time');
29-
gr.setLimit(10);
35+
gr.setLimit(10); // Set limit to 10
3036
gr.query();
37+
3138
while (gr._next()) {
3239
responseTime.push(gr.response_time.toString());
3340
}
3441
return responseTime.join(',');
3542
}
3643

3744
/*
38-
****************OUTPUT**************
45+
******************OUTPUT************
3946
*** Script:
4047
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
7266
*/

0 commit comments

Comments
 (0)