Skip to main content
Version: 20.04

ServiceNow Event Manager

Before starting​

  • You can send events from a central server, a remote server or a poller.
  • By default, this stream connector sends host_status and service_status events. The event format is shown there.
  • Aformentioned events are fired each time a host or a service is checked. Various parameters let you filter out events.

Installation​

Dependencies​

Install Epel repository.

yum -y install epel-release

Install dependencies.

yum install luarocks make gcc lua-curl lua-devel

Lua modules​

Install Centreon lua modules.

luarocks install centreon-stream-connectors-lib

Download Service Now events stream connector​

wget -O /usr/share/centreon-broker/lua/servicenow-events-apiv2.lua https://raw.githubusercontent.com/centreon/centreon-stream-connector-scripts/master/centreon-certified/servicenow/servicenow-events-apiv2.lua
chmod 644 /usr/share/centreon-broker/lua/servicenow-events-apiv2.lua

Configuration​

To configure your stream connector, you must head over the configuration --> Poller --> Broker configuration menu. Select the central-broker-master configuration (or the appropriate broker configuration if it is a poller or a remote server that will send events) and click the Output tab when the broker form is displayed.

Add a new generic - stream connector output and set the following fields as follow:

FieldValue
NameServicenow events
Path/usr/share/centreon-broker/lua/servicenow-events-apiv2.lua
Filter categoryNeb

Add Service Now mandatory parameters​

Each stream connector has a set of mandatory parameters. To add them you must click on the +Add a new entry button located below the filter category input.

TypeNameValue explanationValue exemple
stringinstancethe name of the service now instanceMyCompany
stringclient_idThe Oauth client_id
stringclient_secretThe Oauth client_secret
stringusernameThe Oauth user
stringpasswordThe Oauth pasword

Add Service Now optional parameters​

Some stream connectors have a set of optional parameters dedicated to the Software that they are associated with. To add them you must click on the +Add a new entry button located below the filter category input.

TypeNameValue explanationdefault value
stringlogfilethe file in which logs are written/var/log/centreon-broker/servicenow-stream-connector.log
numberlog_levellogging level from 1 (errors) to 3 (debug)1

Standard parameters​

All stream connectors can use a set of optional parameters that are made available through Centreon stream connectors lua modules.

All those parameters are documented here.

Some of them are overridden by this stream connector.

TypeNameDefault value for the stream connector
stringaccepted_categoriesneb
stringaccepted_elementshost_status,service_status

Event bulking​

This stream connector is compatible with event bulking. Meaning that it is able to send more that one event in each call to the Service Now REST API.

To use this feature you must add the following parameter in your stream connector configuration.

TypeNameValue
numbermax_buffer_sizemore than one

Event format​

This stream connector will send event with the following format.

service_status event​

{
'records': ['{
'source': 'centreon',
'event_class': 'centreon',
'severity': 5,
'node': 'my_host',
'resource': 'my_service',
'time_of_event': '2022-09-06 11:52:12',
'description': 'CRITICAL: USB cable behaving like a water hose'
}']
}

host_status event​

{
'records': ['{
'source': 'centreon',
'event_class': 'centreon',
'severity': 5,
'node': 'my_host',
'resource': 'my_host',
'time_of_event': '2022-09-06 11:52:12',
'description': 'DOWN: someone plugged an UPS on another UPS to create infinite energy'
}']
}

Custom event format​

You can't change the format of the event for this stream connector (the feature was created after this stream connector).

Curl commands​

Here is the list of all the curl commands that are used by the stream connector.

You must replace all the <xxxx> inside the below commands with their appropriate value. <instance> may become MyCompany.

Get OAuth tokens​

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" 'https://<instance_name>.service-now.com/oauth_token.do' -d 'grant_type=password&client_id=<client_id>&client_secret=<client_secret>&username=<username>&password=<password>'

Refresh OAuth tokens​

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" 'https://<instance_name>.service-now.com/oauth_token.do' -d 'grant_type=refresh_token&client_id=<client_id>&client_secret=<client_secret>&username=<username>&password=<password>&refresh_token=<refresh_token>'

The <refresh_token> is obtained thanks to this curl.

Send events​

curl -X POST -H 'content-type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer <access_token>' 'https://<instance_name>.service-now.com/api/global/em/jsonv2' -d "{'records':['{'source': 'centreon','event_class': 'centreon','severity': 5,'node': 'my_host','resource': 'my_service','time_of_event': '2022-09-06 11:52:12','description': 'CRITICAL: USB cable behaving like a water hose'}']}"

The <access_token> is obtained thanks to this curl.