REST API Developer's Guide

Downloading a Collector Installer

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: Basic Authentication is not supported for this resource currently, and only token authentication is supported - please see authentication requirements for more detail. 

HTTP Method: GET

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 & 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'
resourcePath = '/setting/collectors/221/installers/Linux64'
queryParams = '?collectorVersion=22142'
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
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.get(url, data=data, headers=headers)

#Print status and write body of response to a file
print 'Response Status:',response.status_code
file_ = open('LogicMonitorSetup.bin', 'w')
file_.write(response.content)
file_.close()

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:'L0g1cM0n' will work,  /p: 'L0g1cM0n' will not work. 

Linux

Run:

chmod +x logicmonitorsetup123.bin

and then:

./logicmonitorsetup123.bin [-h] [-y] [-p proxyHost:port] [-U proxyUser] [-P proxyPass]

-h: (Optional) show usage
-y: (Optional) install silently (don't ask questions). Defaults to false
-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