Forum Discussion
- Jake_CohenFormer Employee
Hi Shawn,
Yes, you can use our REST API to programmatically change the "Send Collector Notifications" to One Time. We have documentation on how to make the PUT request here, but you can use a PATCH request so that you're only modifying the resendIval field. Here's the code I used to execute this:
#Request Info httpVerb ='PATCH' resourcePath = '/setting/collectors/8' queryParams = '?patchFields=resendIval' data = '{"resendIval":0}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath +queryParams #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()) #Construct headers auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.patch(url, data=data, headers=headers) #Print status and body of response print 'Response Status:',response.status_code print 'Response Body:',response.content
With this, you'll loop through your collector ID's (recommend using the GET all collectors request, followed by the PATCH requests).
Hope this helps!
Jake
Hi Jake,
Good day, I have trouble in running this script. I tried to change the "Collector/8" number to one of my collectors say 86 for ex. I have updated this script in the "data source" in Logic monitor but still having trouble to run this script. it shows no results.
I use logic monitor for a long time but I am a bit new to running scripts in it. Could you please guide me on how to/where to put this script and run successfully. any kind of help/ links is appreciated.
I also have question on whether to run this in the "Data Source' logic monitor or run on the server in the powershell where logic monitor installed.
thanks for all your help.
- Jake_CohenFormer Employee
Hi Shawn,
This script would not be run as a DataSource within LogicMonitor. It would be run as a .py file from your server or workstation.
You can see our full documentation on using the REST API here: https://www.logicmonitor.com/support/rest-api-developers-guide/overview/using-logicmonitors-rest-api/
Best,
Jake
Related Content
- 4 months ago