Event collection via script

You can create a scripted integration with Event Management to push external events from monitoring tools such as Icinga and Nagios. You can use the cURL command-line tool to send one or more events to a ServiceNow instance.

Before you begin

For Mac, cURL is automatically available.

For Unix, Linux, or Windows, make sure that the cURL command-line tool is installed. You can download it at http://curl.haxx.se/download.html.

Role required: evt_mgmt_integration

About this task

For scripted integration, no configuration is required. If your monitoring tool is a supported event source, you can instead select a connector and configure an instance to pull events using a MID Server. In either case, the system uses a web service API to add events to the Event [em_event] table.

Procedure

  1. Use a text editor to create a shell (.sh) file with event records.
    curl -v -H "Accept: application/json" -H "Content-Type: application/json" -X POST --data "{
         \"records\":
         [
         {
         \"source\" : \"Simulated\", 
         \"node\" : \"nameofnode\" , 
         \"type\" : \"High Virtual Memory\",  
         \"resource\" : \"C:\", 
         \"severity\" : \"5\", 
         \"description\" : \"Virtual memory usage exceeds 98%\", 
         \"ci_type\":\"cmdb_ci_app_server_tomcat\", 
         \"additional_info\":\"{"name":"My Airlines"}\"
         },
         {
         \"source\" : \"Simulated\", 
         \"node\" : \"01.myairlines.com\" , 
         \"type\" : \"High CPU Utilization\",  
         \"resource\" : \"D:\", 
         \"severity\" : \"5\", 
         \"description\" : 
         \"CPU on 01.my.com at 60%\"
         }  
        ] 
         }" -u myUserID:myPassword "https://my-instance.service-now.com/em_event.do?JSONv2&sysparm_action=insertMultiple"
    
    
  2. Use the -H option. For the POST parameter, start the data block with an open bracket and delimit the data with backslashes. For example:
    POST --data "{\"records\":[{\"source\" :  [. . .]}"
    Table 1. Header parameters for use with -H option
    Parameter Type Description
    Accept String The acceptable type for this message.

    The default value is application/json.

    Content-Type String The content type for this message.

    The default value is application/json.

    POST String The request type is POST with one or more trailing records.
  3. Use the -u option and the instance URL with login credentials. For example:
     -u myUserID:myPassword "https://my-instance.service-now.com/em_event.do?
        JSONv2&sysparm_action=insertMultiple"
  4. Test the scripted integration.