The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Will Hallam
ServiceNow Employee
ServiceNow Employee

Disclaimer: The examples and procedures included herein are for informational purposes and come with no support or warranty, explicit or implied.

Introduction

I was excited when I heard the San Diego platform release was going to include MID server profiles from which a MID server could be automatically provisioned.  I was a little put out when I saw the fairly manual process for adding all of the settings into the MID profile, however, so I decided to try and automate that process.  The result is the subject of this article.

The MID Profile

I started by looking at the different parts of a MID profile inside my San Diego instance.

find_real_file.png

For each of the related list tabs, I tracked the underlying table being populated.  For each of those tables, I found the corresponding table which was populated when an actual MID server is created.  For example, MID Profile Properties reside in mid_profile_property, MID server properties are in ecc_agent_property.  The one tab for which I didn't see a corresponding table for running MIDs was mid_profile_wrapper_config, which is used to capture entries for the wrapper-override.conf file.

The Automation

In order to make the activities done by my automation easiest to follow, I chose a low-code approach versus a scripted solution.  I created the following building blocks:

Subflows

For each of the tables related to a MID profile, I created a simple subflow which takes as input one MID server record and one MID profile record and then finds all records in the corresponding ecc_agent_* table and creates a corresponding record in the matching mid_profile_* table.  For example, here is a look at the "Copy MID Properties" subflow.

find_real_file.png

I start with a "Look up Records" action to find any MID property records in ecc_agent_property which match the MID server I selected to be profiled.

find_real_file.png

 I then run the result of that lookup through a "For Each Item" loop.

find_real_file.png

The "For Each Item" loop calls a "Create or Update Records" action to create/update the corresponding record in the mid_profile_property table.

find_real_file.png

I followed this same approach to create a subflow for each of the applicable tabs in the MID Server Profile page.

Actions

I defined the following custom actions for my automation:

"Ingest Windows MID File" - an action with a PowerShell step to retrieve the contents of a MID server config file from a Windows-based MID.

"Ingest Linux MID File" - an action with an SSH step to retrieve the contents of a MID server config file from a Linux-based MID. (NOTE: in order to make this work I had to place a suitable SSH credential on any Linux-based MIDs and store it in my SN instance)

"Parse Wrapper Override" - an action with a Script step to take the contents of a MID server wrapper-override.conf file and parse it into records for the mid_profile_wrapper_config table.

Main Subflow

I tied my component parts together with a main subflow -- this could also be a flow which runs from a catalog item or other appropriate trigger.  The main subflow, named "Create MID Profile", takes a MID server record as an input and does the following:

Deletes any existing MID profile with a name matching the MID server name

Creates an empty MID profile named after the MID server

Retrieves the wrapper-override.conf file from the MID server using the applicable action based on the MID OS type

Parses any wrapper-override.conf settings into the mid_profile_wrapper_config table

Calls each table-specific subflow to copy applicable records from the existing MID into the profile

Conclusion

I'm finding this automation to be a nice time-saver as I play around with the new MID profile capability in San Diego.   The automation is available as a scoped app via the following GitHub repo: https://github.com/willhallam-sn/sn-mid-profiler.

 

Comments
Will Hallam
ServiceNow Employee
ServiceNow Employee

In order for this to work, I did have to allow my scoped app to have "Delete" permission against table mid_server_profile.

Version history
Last update:
‎04-21-2022 08:46 AM
Updated by: