Skip to content

Commit 9f68497

Browse files
authored
Top10schedluejobcount (#2159)
* Create script.js Identify top 10 contributors from schedule jobs by processing time * 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. * Update README.md Output updated * Update script.js comment has been updated * Update script.js output commented and updated * Update script.js
1 parent 03c8e7b commit 9f68497

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
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.
2+
3+
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.
4+
5+
OUTPUT:
6+
*** Script:
7+
Top 10 url values from syslog_transaction
8+
9+
10+
11+
********** Execution Details for the column JOB: Check Glide Service Status **********
12+
13+
Executed total number of times : JOB: Check Glide Service Status 1
14+
15+
Top 10 response times : 45300
16+
17+
18+
********** Execution Details for the column JOB: Regenerate CRL and Flush CRL Cache **********
19+
20+
Executed total number of times : JOB: Regenerate CRL and Flush CRL Cache 1
21+
22+
Top 10 response times : 1462
23+
24+
25+
********** Execution Details for the column JOB: SC - Calculate Compliance **********
26+
27+
Executed total number of times : JOB: SC - Calculate Compliance 1
28+
29+
Top 10 response times : 5401
30+
31+
32+
********** Execution Details for the column JOB: [ITSM Analytics] Daily Data Collection **********
33+
34+
Executed total number of times : JOB: [ITSM Analytics] Daily Data Collection 1
35+
36+
Top 10 response times : 16341
37+
38+
[0:00:00.048] Total Time
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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

Comments
 (0)