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

5 REPLIES 5

Sitrix
Tera Guru

Apologise, don't have the answer - but I'd like to bump this thread, having the same question.

 

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);
}
}

Hi matt_kean,

would you mind the sharing the script include VClusterTransaction what you call or the entire functionality?

 

Thank you!

VClusterTransaction is an out-of-box backend script that we don't have access to.  However, calling it should work in your instance.