• 0

How to change "Send Collector Down Notification" to more then 60 collectors using script



I have more then 100 collectors. I want to change "Send Collector Down Notification" to "One Time" all at once. Is it possible using script or do we have any other option rather then going into one by one manually to do it. At the moment they all in a single group say "Group A" most of them are set to 15 minutes. I want to change them all into "One Time" any suggestions..

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 1
  • LogicMonitor Staff

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!


Link to post
Share on other sites
  • 1
  • LogicMonitor Staff

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/



Link to post
Share on other sites
  • 0

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.