Blog

Email Monitoring and Heartbeat

ServiceNow email is very reliable and has a low occurrence of downtime.  However, for some companies, email is crucial to their business.  They rely on email to meet SLAs and OLAs, and have contracts that might explicitly state that email must be received within a certain timeframe. 

In order to insure that ServiceNow email is functioning, here are a couple of monitoring methods for email.

1. Webservices

If you have an external monitoring application, this application could use ServiceNow web services and check for emails in send-ready status. If there are so many emails over a certain threshold, say 100, the monitoring system will flag an error. 

WSDL

https://<yourinstance>.service-now.com/sys_email.do?WSDL

Example Webservice Request 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sys="http://www.service-now.com/sys_email">
 <soapenv:Header/>
 <soapenv:Body>
<sys:getRecords>
 <type>send-ready</type>
</sys:getRecords>
 </soapenv:Body>
</soapenv:Envelope>

2. Heartbeat Email

Another idea is for ServiceNow send emails to a monitoring system or person on a periodic basis.  Although not as reliable as web services in my opinion, it also is effective. Here is how to setup a heartbeat email in ServiceNow

Registry

Name: snelite.email.heartbeat
Table: Email [sys_email]
Fired by: Email Monitoring Scheduled Job
Description: Email Heartbeat

Notification

Name: Email Heartbeat
Table: Email [sys_email]
When to send?
Send when: Event is fired
Event name: snelite.email.heartbeat
Who will receive?
Users: <your user here>
What it will contain:
Subject: ServiceNow Email Heartbeat
Message: The ServiceNow email heartbeat sends email every 15 minutes. Note that network delay may affect this email. 

Scheduled Script

Name: SNElite Heartbeat Email
Trigger Type: Repeat
Repeat: Days 00 Hours 00:15:00
Script:
//Send HeartbeatEmail
sendHeartbeatEmail();
function sendHeartbeatEmail() {
    gs.eventQueue('snelite.email.heartbeat');
}

3. ServiceNow Incident

You can also use a scheduled script in ServiceNow to create an incident if email is not responding.  You would need to adjust for your ServiceNow system, but this can get you started.

Scheduled Script

Name: SNElite Email Check
Trigger Type: Repeat
Repeat: Days 00 Hours 00:15:00

//Create incident if over 100 pending emails
checkEmailQueue();
function checkEmailQueue() {
grEmail = new GlideRecord('sys_email');
grEmail.addEncodedQuery('type=send-ready');
grEmail.query();
if(grEmail.getRowCount() > 100) {
var gr = new GlideRecord("incident");
gr.initialize();
//gr.assignment = 'ServiceNowELITE.com';
gr.short_description = 'Check ServiceNow Email Queue';
gr.work_notes = 'ServiceNow Email Queue contains over 50 emails in send-ready status.Check ServiceNow email for proper operation';
gr.insert();
//this._logDebug("Created incident " + gr.number);
}
}