Script to get active transactions from all nodes to identify long-running transactions

matt_kean
Tera Guru

'Active Transactions (all nodes)' dynamically creates a list of transactions from all nodes.  Every time you hit refresh, the same thread will get a new sys_id.  With this in mind, I want a script that will identify long-running transactions to alert our platform support team, but a script can't see transactions on all nodes.  It will only see transactions on the current node. Does anyone know how to script getting active transactions from all nodes?

1 ACCEPTED SOLUTION

matt_kean
Tera Guru

I was able to find an answer here.  I put the following in a scheduled job that runs every couple hours

refreshTransactions();
findLongRunning();

function refreshTransactions() {
var vct = new VClusterTransaction('v_cluster_transaction');
vct.deleteTransactions();
var id = vct.informOtherNodes();
vct.refreshTransactions(gs.getSessionID());
gs.sleep(35000);
}

function findLongRunning() {
var tran = new GlideRecord('v_cluster_transaction');
tran.addEncodedQuery("age>javascript:gs.getDurationDate('0 10:0:0')");
tran.query();
while(tran.next()) {
createIncident(tran);
}
}

View solution in original post

6 REPLIES 6

Great! Thanks.

 

Do you know about any documentation regarding the OOTB script? What can be called and methods description?

Hello, thank you for the response, it works but i'm wondering why exactly 35seconds of gs.sleep, is there a reason why 35 no more no less ?