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:

Resource Information

URI: /setting/collectors

Resource Properties: Each Collector has the following properties.

Property Description Type
idThe id of the CollectorInteger
createdOnThe time that the Collector was created, in epoch formatInteger
updatedOnThe time that the Collector was last updated, in epoch formatInteger
upTimeThe time the Collector has been up, in secondsInteger
watchdogUpdatedOnThe time that the Watchdog Services was last updated, in epoch formatInteger
status0|1|2|3 – The registration status of the Collector. 0= unregistered, 1= registered, 2= stopped, 3= suspendedInteger
confVersionThe version of the agent.conf configuration file String
netscanVersionThe Netscan version associated with the CollectorString
buildThe Collector versionString
collectorConfThe Collector’s configuration fileString
lastSentNotificationOnThe time, in epoch format, that a notification was last sent for the CollectorInteger
platformThe OS of the Collector device (e.g. Linux, Windows)String
ackedtrue | false, whether or not the Collector is currently acknowledgedBoolean
ackedOnThe epoch at which the Collector was acknowledged (if it is in alert)Integer
ackedByThe user that acknowledged the Collector (if it is in alert)String
ackCommentThe comment associated with the Collector acknowledgement (if it is in alert and acknowledged)String
clearSentWhether or not an alert clear notifcation has been sent for this CollectorBoolean
isDownWhether or not the Collector is currently downBoolean
createdOnLocalThe time that the Collector was created, in local time formatString
updatedOnLocalThe time that the Collector was last updated, in local time formatString
watchdogUpdatedOnLocalThe time that the Collector Watchdog was last updated, in local time formatString
lastSentNotificationOnLocalThe time that a notification was last sent for this Collector, in local time formatString
ackedOnLocalThe time that the Collector was acknowledged (if it is in alert), in local time formatString
hostnameThe hostname of the device the Collector is installed onString
numberOfHostsThe number of devices monitored by the CollectorInteger
numberOfServicesThe number of services monitored by the CollectorInteger
userVisibleHostsNumThe number of devices monitored by the Collector and visible to the user that made the queryInteger
userVisibleServicesNumThe number of services monitored by the Collector and visible to the user that made the queryInteger
nextUpgradeInfoThe details of the Collector’s next upgrade, if one has been scheduledJSON object
descriptionThe Collector’s descriptionString
backupAgentIdThe Id of the backup Collector assigned to the CollectorInteger
enableFailBackWhether or not automatic failback is enabled for the CollectorBoolean
resendIvalThe interval, in minutes, after which alert notifications for the Collector will be resentInteger
suppressAlertClearWhether alert clear notifications are suppressed for the CollectorBoolean
escalatingChainIdThe Id of the escalation chain associated with this CollectorInteger
nextRecipientThe Id of the next recipient to which alert notifications will be sentInteger
onetimeUpgradeInfoThe details of the Collector’s one time upgrade, if one has been scheduledInteger
automaticUpgradeInfoThe details of the Collector’s automatic upgrade schedule, if one existsInteger
collectorGroupIdThe Id of the group the Collector is inInteger
collectorGroupNameThe name of the group the Collector is inString
userPermissionThe permission level of the user that made the API request to get Collector informationString
enableFailOverOnCollectorDeviceWhether or not the device the Collector is installed on is enabled for fail overBoolean

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
descriptionThe Collector’s descriptionNoString
backupAgentIdThe Id of the failover Collector configured for this CollectorNoInteger
enableFailBackWhether or not automatic failback is enabled for the CollectorNoBoolean
resendIvalThe interval, in minutes, after which alert notifications for the Collector will be resentNoInteger
suppressAlertClearWhether alert clear notifications are suppressed for the CollectorNoBoolean
escalatingChainIdThe Id of the escalation chain associated with this CollectorNoInteger
collectorGroupIdThe Id of the group the Collector is inNoInteger
enableFailOverOnCollectorDeviceWhether or not the device the Collector is installed on is enabled for fail overNoBoolean
needAutoCreateCollectorDeviceWhether or not the device the Collector is installed on should be automatically added into monitoringNoBoolean

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)
Python 3

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
sortsort={+ or -}propertySorts the response by the property specified in either increasing (+) or decreasing (-) order/setting/collectors?sort=-id
filterfilter=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:


  • Greater than or equals: >:
  • Less than or equals: <:
  • Greater than: >
  • Less than: <
  • Does not equal: !:
  • Equals: :
  • Includes: ~
  • Does not include: !~
/setting/collectors?filter=description~QA*
fieldsfields={list of properties separated by commas} Filters the response to only include the following fields for each object/setting/collectors?fields=id,upTime
sizesize=integerThe number of results to display/setting/collectors?size=5
offsetoffset=integerThe 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)
Python 3

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
collectorVersionThe 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
collectorSizeThe 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
useEAIf true, the latest EA Collector version will be used. Defaults to falseBoolean/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')
Python 3

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
descriptionThe Collector’s descriptionString
backupAgentIdThe Id of the failover Collector configured for this CollectorInteger
enableFailBackWhether or not automatic failback is enabled for the CollectorBoolean
resendIvalThe interval, in minutes, after which alert notifications for the Collector will be resentInteger
suppressAlertClearWhether alert clear notifications are suppressed for the CollectorBoolean
escalatingChainIdThe Id of the escalation chain associated with this CollectorInteger
collectorGroupIdThe Id of the group the Collector is inInteger
collectorGroupNameThe name of the group the Collector is inString
enableFailOverOnCollectorDeviceWhether or not the device the Collector is installed on is enabled for fail overBoolean

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)
Python 3

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)
Python 3