Cannot create a monitoring profile using MCS Webservices

Document ID : KB000111421
Last Modified Date : 16/08/2018
Show Technical Document Details
Issue:
we can’t create MCS profiles using the MCS webservices call.

To illustrate
1. Create a group in USM
a. This is done from the server 10.xxx.xxx.xxx, running the previous UIMAPI v9.0, where we can still define within the payload which group type we want to create:
b. Post Command
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
"name": "Test 1",
"type": "DYNAMIC",
"elementType": "SYSTEM",
"description": "Test - creation of profile fails",
"parentId": 0,
"accountId": 0,
"criteria": ""
}' 'http://10.xxx.xxx.xxx/uimapi/groups'
 
c. Response Body
{
"id": 87,
"name": "Test 1",
"self": "http://10.xxx.xxx.xxx/uimapi/groups/87",
"type": "DYNAMIC",
"elementType": "SYSTEM",
"description": "Test - creation of profile fails",
"parentId": 0,
"criteria": "{\"isCsFilter\":true,\"criteriaOperator\":\"AND\",\"subCriteria\":[{\"isCsFilter\":true,\"negated\":false,\"attribute\":\"DisplayName\",\"filterOperator\":\"UNDEFINED\",\"value\":[\"\"]}]}"
}


2. Create a monitoring profile
a. This is run against the UMP server (10.xxx.xxx.xxx) using the MCS Webservices API
b. Create the profile
curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/plain' -d '{
<See attached file>
}' 'http://10.xxx.xxx.xxx/mcsws/v1/groups/87/profiles'
 
c. Response
Group 87 not found
Environment:
UIM 9.0 and earlier
UIMAPI 9.0
mcs_ws.8.5.8-HF8
Cause:
The UIMAPI create group creates an entry in the cm_group table.
The MCS_WS ( Monitoring_config_server_Web_services) create profile is expecting the group ID from the ssrv2devicegroup table.
When the group is created in cm_group a trigger is activated that creates the entry in the ssrv2devicegroup table.
Normally these ID values in these tables will be the same.

When they are off that is when you run into this issue.
 
Resolution:
There are a couple of options.
Option 1:
you can manually increase the records in either the cm_group or the ssrv2devicegroup table using the below sql examples until the record number in both tables are the same.

Option 1a:
when the cm_group table ID column is higher than the ssrv2devicegroup ID number

Do a select * from ssrv2devicegroup to find the last record ID.
Change the below query and added 1 to the number to insert the next record
 
-- SET IDENTITY_INSERT to ON.  
SET IDENTITY_INSERT dbo.SSRV2DeviceGroup ON;  
GO  

-- Try to insert an explicit ID value of X where X is one greater than the last value IE highest value was 10 so X will be 11. 
INSERT INTO dbo.SSRV2DeviceGroup (grp_id,Name) VALUES (11, 'Filler group Record11');  
GO
Repeat the query until the you have the same ID field record in SSRV2DeviceGroup as you do in CM_GROUP.

Then make sure to run the following:
-- SET IDENTITY_INSERT to OFF. 
SET IDENTITY_INSERT dbo.SSRV2DeviceGroup OFF; 
GO

Option 1b:
when the cm_group table ID column is lower than the ssrv2devicegroup ID number

Do a select * from cm_group to find the last record ID.
Change the below query and added 1 to the number to insert the next record
-- SET IDENTITY_INSERT to ON.  
SET IDENTITY_INSERT dbo.CM_GROUP ON;  
GO  

-- Try to insert an explicit ID value of X where X is one greater than the last value IE highest value was 10 so X will be 11. 
INSERT INTO dbo.CM_GROUP (grp_id, grp_type, pgrp_id,Name) VALUES (11, 1, 0  'Filler group Record11');  
GO
Repeat the query until the you have the same ID field record in SSRV2DeviceGroup as you do in CM_GROUP.

Then make sure to run the following:
-- SET IDENTITY_INSERT to OFF. 
SET IDENTITY_INSERT dbo.CM_GROUP OFF; 
GO


Option 2:
After creating the group using the UIMAPI you can then use the MCS_WS get group call back to retrieve the ID of the new group
and then use that group ID value to create the new profile