Skip to main content

Importing Servers from ServiceNow into Checkmk with CMDB Syncer

·543 words·3 mins
Feature image: Slices of fresh ripe orange

Introduction #

Managing IT assets efficiently requires robust synchronization between Configuration Management Databases (CMDB) and monitoring tools. CMDB Syncer is a powerful open-source tool designed to automate the integration of host data across various systems, including Checkmk and ServiceNow. In this post, we’ll explore how to use CMDB Syncer to import server data from ServiceNow via its REST API and sync it with Checkmk.

Prerequisites #

Before getting started, ensure you have:

  • A running instance of ServiceNow with API access (for demo purposes, I use a developer instance with demo data)
  • CMDB Syncer 3.8.x or newer installed and configured
  • Checkmk monitoring 2.3.x set up to receive host data
  • API credentials with appropriate permissions in ServiceNow

Step 1: Configuring ServiceNow API Access #

To enable CMDB Syncer to pull data from ServiceNow, follow these steps:

  1. Create a ServiceNow User for API access

    • Navigate to User Admin > Users in ServiceNow.
    • Create a new user with read permissions for the CMDB tables.
    • Assign the rest_api_explorer and cmdb_read roles.
    • Set a password.

    ServiceNow User Creation
    ServiceNow User Creation

  2. Identify the CMDB Table

    • In ServiceNow, CMDB data is stored in tables like cmdb_ci_server. If you just need Linux servers, use cmdb_ci_linux_server or cmdb_ci_win_server for Windows servers.
    • Use the REST API Explorer to test API queries (/api/now/table/cmdb_ci_server).

    ServiceNow REST API Explorer
    ServiceNow REST API Explorer

Step 2: Configuring CMDB Syncer #

CMDB Syncer allows modular imports. The REST API is best suited for importing data from ServiceNow.

  1. Within CMDB Syncer, create a new account (Accounts -> Create). Use the following parameters:

    SettingsDescriptionMy Example
    NameChoose a name for the Accountname like “ServiceNow”
    TypeType of APIuse “Remote Rest API”
    Is MasterMaster object (not overwritten)yes
    AddressHTTPS Endpointhttps://<INSTANCE>.service-now.com/api/now/table/cmdb_ci_server
    UsernameUser Loginyour ServiceNow user, e.g., “api_ro_bytingbytes”
    PasswordUser Password<your secret password>
    auth_typeAuthentication Typeuse “Basic” as auth type
    hostname_fieldField name for hostnamemost common fit will be “name”

    Everything else is set to default values.

    CMDB Syncer Account View
    CMDB Syncer Account View

Step 3: Test sync #

To test the setup, just use the cmdbsyncer command. Optionally, run the command with the parameter “–debug” to get more information in case of errors.

$ ./helper shell
Start Container Shell
/srv # ./cmdbsyncer rest import_hosts ServiceNow

If everything is set up correctly, the servers are imported:

CMDB Syncer Imported Hosts
CMDB Syncer Imported Hosts

Within the CMDB Syncer frontend, it should look like this if you go to “Hosts”:

CMDB Syncer Host Overview
CMDB Syncer Host Overview

For each server you can check the data which got imported:

CMDB Syncer Host Example
CMDB Syncer Host Example

Step 4: Automate the sync process #

To ensure regular updates, set up a cron job. This will update and sync new assets regularly.

CMDB Syncer Cronjob ServiceNow Import
CMDB Syncer Cronjob ServiceNow Import

CMDB Syncer Cronjobs
CMDB Syncer Cronjobs

In case your ServiceNow hostnames are not valid hostnames (according to the RFC), set CHECK_FOR_VALID_HOSTNAME in local_config.py to False. However, this might lead to other issues later on.

Step 5: Checkmk Exports #

For detailed instructions on exporting hosts and attributes to Checkmk, refer to the CMDB Syncer Checkmk Documentation.

Conclusion #

CMDB Syncer simplifies the process of integrating ServiceNow CMDB data with monitoring tools like Checkmk. By automating the import process, you can ensure real-time asset visibility, reduce manual intervention, and improve infrastructure monitoring efficiency.

Looking to enhance your setup? Explore CMDB Syncer’s plugin API and custom rule configurations for deeper integrations!