Custom query for dynamic group
Hi I want create dynamic groups based on server role like print servers, AD servers, file servers etc. Could you please help me to to find out how can i create a custom query for the groupings or custom query if a service is running. Thank you Tanvir11Views0likes1CommentCreating dynamic group
Hi All I am trying to create groups with a pythonscript which read a CSV file. my txt file has following information {"name":1","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"} {"name":2","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"} {"name":3","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"} {"name":4","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"} when I run the script bellow I receiveInvalid JSON body message Response Status: 200 Response Body: b'{"data":null,"errmsg":"Invalid json body","status":1007}' I can create the group if I assign value directly like data ='{"name":1","parentId":462,"appliesTo": "Type==\\"Test Server\\\"\"}' Script is Quote Quote import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='tba' AccessKey ='XXX' Company = 'YYY' #Request Info httpVerb ='POST' resourcePath = '/device/groups' with open('test.txt', 'r') as file: #csv_reader = csv.reader(csv_file) for line in file: data =line print (data) url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #Get current time in milliseconds epoch = str(int(time.time() * 1000)) #Concatenate Request details requestVars = httpVerb + epoch + data + resourcePath #Construct signature hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest() signature = base64.b64encode(hmac1.encode()) #Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.post(url, data=data, headers=headers) #Print status and body of response print ('Response Status:',response.status_code) print ('Response Body:',response.content)1View0likes0CommentsCreate Dynamic group by Script
Hi Members I am trying to create 'Device Dynamic Groups' with Python script. but I am failing. Could you pleas me what I am missing: Conditions of the groups name: If Device display name starts with prod, all device should group. data = '{"name":"test111","parentId":111,"appliesTo":"startsWith("system.displayname","Prod")"}' I have attached the full script too. I am running Python 3.6.5 #!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='XXXXXX' AccessKey ='XXXXXX' Company = 'contoso' #Request Info httpVerb ='POST' resourcePath = '/device/groups' data = '{"name":"test111","parentId":111,"appliesTo":"startsWith("system.displayname","Prod")"}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #Get current time in milliseconds epoch = str(int(time.time() * 1000)) #Concatenate Request details requestVars = httpVerb + epoch + data + resourcePath #Construct signature #signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest()) hmac = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest() signature = base64.b64encode(hmac.encode()) #Construct headers #auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch #headers = {'Content-Type':'application/json','Authorization':auth} auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.post(url, data=data, headers=headers) Please assist Thank you.7Views0likes3Comments