create incident when mid server fails to run
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:22 AM
Hi, How to create scheduled job to check mid server status, if any mid servers has been stopped for 4 hours, create Incident.
Thanks. |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:24 AM
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 10:11 AM - edited 01-11-2024 10:15 AM
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