Overview
The collector resource allows you to programmatically manage your LogicMonitor Collectors. As with all of our API calls, authentication is required.
Using LogicMonitor’s REST API you can:
- Get a list of Collectors
- Get information about a particular Collector
- Add a Collector
- Download a Collector installer
- Update a Collector
- Delete a Collector
Resource Information
URI: /setting/collectors
Resource Properties: Each Collector has the following properties.
Property | Description | Type |
id | The id of the Collector | Integer |
createdOn | The time that the Collector was created, in epoch format | Integer |
updatedOn | The time that the Collector was last updated, in epoch format | Integer |
upTime | The time the Collector has been up, in seconds | Integer |
watchdogUpdatedOn | The time that the Watchdog Services was last updated, in epoch format | Integer |
status | 0|1|2|3 – The registration status of the Collector. 0= unregistered, 1= registered, 2= stopped, 3= suspended | Integer |
confVersion | The version of the agent.conf configuration file | String |
netscanVersion | The Netscan version associated with the Collector | String |
build | The Collector version | String |
collectorConf | The Collector’s configuration file | String |
lastSentNotificationOn | The time, in epoch format, that a notification was last sent for the Collector | Integer |
platform | The OS of the Collector device (e.g. Linux, Windows) | String |
acked | true | false, whether or not the Collector is currently acknowledged | Boolean |
ackedOn | The epoch at which the Collector was acknowledged (if it is in alert) | Integer |
ackedBy | The user that acknowledged the Collector (if it is in alert) | String |
ackComment | The comment associated with the Collector acknowledgement (if it is in alert and acknowledged) | String |
clearSent | Whether or not an alert clear notifcation has been sent for this Collector | Boolean |
isDown | Whether or not the Collector is currently down | Boolean |
createdOnLocal | The time that the Collector was created, in local time format | String |
updatedOnLocal | The time that the Collector was last updated, in local time format | String |
watchdogUpdatedOnLocal | The time that the Collector Watchdog was last updated, in local time format | String |
lastSentNotificationOnLocal | The time that a notification was last sent for this Collector, in local time format | String |
ackedOnLocal | The time that the Collector was acknowledged (if it is in alert), in local time format | String |
hostname | The hostname of the device the Collector is installed on | String |
numberOfHosts | The number of devices monitored by the Collector | Integer |
numberOfServices | The number of services monitored by the Collector | Integer |
userVisibleHostsNum | The number of devices monitored by the Collector and visible to the user that made the query | Integer |
userVisibleServicesNum | The number of services monitored by the Collector and visible to the user that made the query | Integer |
nextUpgradeInfo | The details of the Collector’s next upgrade, if one has been scheduled | JSON object |
description | The Collector’s description | String |
backupAgentId | The Id of the backup Collector assigned to the Collector | Integer |
enableFailBack | Whether or not automatic failback is enabled for the Collector | Boolean |
resendIval | The interval, in minutes, after which alert notifications for the Collector will be resent | Integer |
suppressAlertClear | Whether alert clear notifications are suppressed for the Collector | Boolean |
escalatingChainId | The Id of the escalation chain associated with this Collector | Integer |
nextRecipient | The Id of the next recipient to which alert notifications will be sent | Integer |
onetimeUpgradeInfo | The details of the Collector’s one time upgrade, if one has been scheduled | Integer |
automaticUpgradeInfo | The details of the Collector’s automatic upgrade schedule, if one exists | Integer |
collectorGroupId | The Id of the group the Collector is in | Integer |
collectorGroupName | The name of the group the Collector is in | String |
userPermission | The permission level of the user that made the API request to get Collector information | String |
enableFailOverOnCollectorDevice | Whether or not the device the Collector is installed on is enabled for fail over | Boolean |
Overview
With LogicMonitor’s REST API you can programmatically add Collectors to your account. Once you add a Collector resource to your account, you’ll need to download the Collector installer and run the resulting executable (Windows) or binary (Linux).
As with all of our API calls, authentication is required.
Request Information
HTTP Method: POST
URI: /setting/collectors
Request parameters: You can POST the following properties for each Collector.
Property | Description | Required? | Type |
description | The Collector’s description | No | String |
backupAgentId | The Id of the failover Collector configured for this Collector | No | Integer |
enableFailBack | Whether or not automatic failback is enabled for the Collector | No | Boolean |
resendIval | The interval, in minutes, after which alert notifications for the Collector will be resent | No | Integer |
suppressAlertClear | Whether alert clear notifications are suppressed for the Collector | No | Boolean |
escalatingChainId | The Id of the escalation chain associated with this Collector | No | Integer |
collectorGroupId | The Id of the group the Collector is in | No | Integer |
enableFailOverOnCollectorDevice | Whether or not the device the Collector is installed on is enabled for fail over | No | Boolean |
needAutoCreateCollectorDevice | Whether or not the device the Collector is installed on should be automatically added into monitoring | No | Boolean |
Example
The following Python script adds a Collector.
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'
#Request Info
httpVerb ='POST'
resourcePath = '/setting/collectors'
queryParams = ''
data = '{"description":"prodCollector1","escalatingChainId":20,"collectorGroupId":4,"backupAgentId":85}'
#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
# 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)
Overview
You can use LogicMonitor’s REST API to get information about the Collectors in your account. Specifically, you can get a list of Collectors or information on a specific Collector.
As with all of our API calls, authentication is required.
Get a List of All Collectors
HTTP Method: GET
URI: /setting/collectors
Request Parameters: By default, a list of 50 Collectors will be returned. You can include sort, filter, fields, size, and offset parameters in your request to control what data is included in the response and how it is formatted.
Property | Syntax | Description | Example URI |
sort | sort={+ or -}property | Sorts the response by the property specified in either increasing (+) or decreasing (-) order | /setting/collectors?sort=-id |
filter | filter=property{operator}value | Filters the response according to the operator and value specified. Note that you can use * to match on more than one character. You can use the ‘.’ character to filter values within an object (e.g. custom properties), and multiple filters can be separated by a comma. Operators include:
| /setting/collectors?filter=description~QA* |
fields | fields={list of properties separated by commas} | Filters the response to only include the following fields for each object | /setting/collectors?fields=id,upTime |
size | size=integer | The number of results to display | /setting/collectors?size=5 |
offset | offset=integer | The number of results to offset the displayed results by | /setting/collectors?offset=2 |
Example
The following Python script returns the description, hostname and id for all collectors in the account api.logicmonitor.com.
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'
#Request Info
httpVerb ='GET'
resourcePath = '/setting/collectors'
queryParams = '?fields=id,description,hostname'
data = ''
#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
# Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}
#Make request
response = requests.get(url, data=data, headers=headers)
# Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Get Information About a Particular Collector
HTTP Method: GET
URI: /setting/collectors/<id>
Introduction
You can use LogicMonitor’s REST API to download a Collector Installer. This should result in a binary for Linux Collectors or an executable for Windows Collectors, which you can then run to install the Collector.
Note: For security reasons, the downloaded installer file will expire after two hours.
HTTP Method: GET
Note: Basic Authentication is not supported for this resource currently. Token authentication is supported. See authentication requirements for more details.
Resource URI: /setting/collectors/{id}/installers/{platform+architecture}
(where id is the Collector Id, which can be found via a GET call to the Collectors resource, and platform + architecture is one of Linux64, Linux32, Win64 or Win32; note that for a Linux installer, you should output to a .bin file and for a Windows installer, you should output to a .exe file)
Request Parameters: You can optionally include the following query parameters in your request.
Property | Description | Type | Example |
collectorVersion | The version of the installer you’d like to download. This defaults to the latest GD Collector, unless useEA is true. | String | /setting/collectors/12/installers/Linux64?collectorVersion=22142 |
collectorSize | The size of the Collector you’d like to install. Options are nano, small (requires 2GB memory), medium (requires 4GB memory), large (requires 8GB memory). Requires collector version 22.180 or higher. Defaults to small. | String | /setting/collectors/12/installers/Linux64?collectorSize=nano |
useEA | If true, the latest EA Collector version will be used. Defaults to false | Boolean | /setting/collectors/12/installers/Linux64?useEA=true |
Note: Because they are encoded and concatenated separately, the resource path and query parameter cannot be combined when used in scripts. For example, the correct resource path is /setting/collectors/31/installers/Win64, NOT /setting/collectors/31/installers/Win64?collectorSize=nano. See the scripting example in the following section for correct formatting within scripts.
Scripting Example
Next is an example of performing the HTTP Get within a script (Python). This script illustrates downloading a 64 bit Linux installer, version 22.142, for Collector 221.
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'
#Request Info
httpVerb ='GET'
collectorId='6'
collectorVersion='30001'
resourcePath = '/setting/collectors/' + collectorId + '/installers/Linux64'
queryParams = '?collectorVersion=' + collectorVersion
data = ''
#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
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.get(url, data=data, headers=headers)
# Print Response status
print('Response Status:',response.status_code)
# Print response body if status code is not 200
if(response.status_code != 200):
print('Response Body:',response.content)
else:
file_ = open('LogicMonitorSetup.bin', 'wb')
file_.write(response.content)
file_.close()
print('Collector installer has been downloaded successfully')
Installation
The last step in adding a collector is running the install file on the selected server. The device where the collector resides will need to be a Windows or Linux (physical or virtual) server with an outgoing SSL connection over port 443 to the LogicMonitor servers.
Windows
Run:
LogicMonitorSetup123.exe /q /d:"" /a: /p:
/d:(Optional) This is the path to install the collector into. It defaults to /Program Files/LogicMonitor/Collector/
/a:(Optional) This is the account the windows service will run as. Defaults to LocalSystem. The installer requires a Domain\User format. Ex: /a:’Domain\User’
/p: (Required if /a is given) This is the password to use that corresponds to the user account specified. Ex: /p:’p@$$w0rd’
Note: If you do not specify the collector to run as a privileged user it will install and run as local system. Local system may not have sufficient permissions to monitor other windows hosts remotely.
/PROXYHOST: (Optional) Proxy server address Ex: /PROXYHOST:”proxy.net”
/PROXYPORT: (Optional) Proxy server port
/PROXYUSER: (Optional) Username to authenticate to proxy server if any
/PROXYPASS: (Optional) Password to authenticate to proxy server if required
Be sure there is no space following any colon if parameters are being specified.
For example, /p:’Ex@ml!eP@5Sw0rd’ will work, /p: ‘Ex@ml!eP@5Sw0rd’ will not work.
Linux
Run:
chmod +x logicmonitorsetup123.bin
and then:
./logicmonitorsetup123.bin [-h] [-n] [-y] [-p user] [-p proxyHost:port] [-U proxyUser] [-P proxyPass]
-h: (optional) display a list of flags, their defaults, and their options
-n: (optional) display Collector version number
-y: (optional) install silently (don’t ask questions); defaults to false
-u user: (optional) user or root; defaults to “logicmonitor”
-p proxyAddr:port: (optional) proxy server in form of address:port (e.g. 10.0.0.1:8080)
-U proxyUser: (optional) username to authenticate to proxy server if any
-P proxyPass: (optional) password to authenticate to proxy server if required
Overview
With LogicMonitor’s REST API you can programmatically update the Collectors in your account. As with all of our API resources, authentication is required.
Request Information
HTTP Method: PUT
(consistent with REST standards, any properties not specified in a PUT request will revert back to their default values)
URI: /setting/collectors/{id}
Request Parameters: You can include the following parameters in your PUT request.
Property | Description | Type |
description | The Collector’s description | String |
backupAgentId | The Id of the failover Collector configured for this Collector | Integer |
enableFailBack | Whether or not automatic failback is enabled for the Collector | Boolean |
resendIval | The interval, in minutes, after which alert notifications for the Collector will be resent | Integer |
suppressAlertClear | Whether alert clear notifications are suppressed for the Collector | Boolean |
escalatingChainId | The Id of the escalation chain associated with this Collector | Integer |
collectorGroupId | The Id of the group the Collector is in | Integer |
collectorGroupName | The name of the group the Collector is in | String |
enableFailOverOnCollectorDevice | Whether or not the device the Collector is installed on is enabled for fail over | Boolean |
Example
The following Python script updates Collector 223.
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'
#Request Info
httpVerb ='PUT'
resourcePath = '/setting/collectors/223'
queryParams = ''
data = '{"description":"prodCollector1","escalatingChainId":20,"collectorGroupId":4,"backupAgentId":85}'
#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
# Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}
#Make request
response = requests.put(url, data=data, headers=headers)
# Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
The Collector resource allows you to programmatically delete your LogicMonitor Collectors. As with all of our API calls, authentication is required.
HTTP Method: DELETE
URI: /setting/collectors/{id}
Overview
You can use LogicMonitor’s REST API to acknowledge Collector down alerts. As with all of our API calls, authentication is required.
Request Information
HTTP Method: POST
URI: /setting/collectors/{id}/ackdown
Request Parameters: You must include an acknowledgement comment in your request.
Property | Description | Required? | Type |
comment | The comment to be associated with the acknowledgement | Yes | String |
Example
The following Python script acknowledges the Collector down alert for Collector 165 in api.logicmonitor.com, and leaves the comment “upgrading server”.
#!/bin/env python
import requests
import json
import hashlib
import base64
import time
import hmac
#Account Info
AccessId ='YQQ75w6Mxx9zWIeAMq5H'
AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8'
Company = 'api'
#Request Info
httpVerb ='POST'
resourcePath = '/setting/collectors/165/ackdown'
data = '{"comment":"upgrading server"}'
#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
# 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)