create incident when mid server fails to run

BanuMahalakshmi
Tera Contributor

Hi,

How to create scheduled job to check mid server status, if any mid servers has been stopped for 4 hours, create Incident.

 

Thanks.

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @BanuMahalakshmi 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0831557#:~:text=To%20determin....

 

 

Trigger this every 4 hours and create Incident if down.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Anand Kumar P
Giga Patron
Giga Patron

Hi @BanuMahalakshmi,

Just now i saw your ping try below script :

 

 

var gr = new GlideRecord('ecc_agent');
gr.addQuery('status', 'Down');
gr.addQuery('last_refreshed', '<', gs.hoursAgo(-6));
gr.query();

while (gr.next()) {
createIncident(gr.name.toString());
}
}

function createIncident(midServerName) {
var incGr = new GlideRecord('incident');
incGr.addQuery("active", true);
incGr.addQuery("sys_created_on", '>=', gs.beginningOfToday());
incGr.addQuery("sys_created_on", '<=', gs.endOfToday());
incGr.addQuery("short_description", 'STARTSWITH', 'Mid Server status is Down on ' + midServerName);
incGr.query();

if (!incGr.hasNext()) {
incGr.initialize();
incGr.state = 1; 
incGr.urgency = 2;
incGr.contact_type = 'self-service';
incGr.caller_id = "6816f79cc0a8016401c5a33be04be441"; 
incGr.short_description = 'Mid Server status is Down on ' + midServerName + ' at ' + gs.nowDateTime() + '.';
incGr.insert();
}
}

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand