RPC API Developer's Guide (Deprecated)

RPC API: Add a Collector

Note that LogicMonitor does have an available REST API equivalent for this API call.

Collectors are used to gather data from your hosts and send it to LogicMonitor. They are installed and run on a host within your infrastructure. The LogicMonitor API allows you to manage collectors programmatically.  With the addAgent RPC API call you can add and install a collector.

Note: As with all of our API calls, authentication is required.

New collectors can be added with three steps:

  1. Create the collector record in your LogicMonitor account
  2. Download the collector installer
  3. Run the install file on the selected host

Note: Once a collector record is created, the corresponding installer is only valid for two hours.

 

Step 1. Add a Collector record into your account

URL:
https://accountName.logicmonitor.com/santaba/rpc/addAgent?c=accountName&u=user&p=password&autogen=trueOrFalse&credential=collectorCredential&description=collectorDescription&backupAgentId=backupCollectorId

 

Request Parameters: You can include the following as query parameters in an addAgent RPC call:

Parameter

Type

Description

credential String Required if autogen is not specified or set to false. The credential for the new collector. Note that the credential cannot include spaces, % or / characters, and you should URL encode the credential when making the addAgent request.
autogen Boolean Required if a credential is not specified. When true, a random 8 character credential will be generated for the collector.
description String Optional. The collector description.
backupAgentId Integer Optional. The Id of the collector to be used as a back-up for the new collector.

 

 
Note: The -v flag for curl makes the output more verbose and descriptive. This may be necessary for things like finding the collector id as well as the collector credentials:
 
curl -v "https://accountName.logicmonitor.com/santaba/rpc/addAgent?c=accountName&u=user&p=password&autogen=true"

 

All outputs will be in the format: { [status], [data], [errmsg] }, where status is the status of the response, errmsg is the error message associated with the response, and the data object includes the following:

Value

Description

nextRecipient The next recipient to be notified if the collector is in alert
clearSent Whether or not a clear notification was sent for the last alert
lastSentNotification The time (in epoch format) that the last noticiation was sent for this collector
netScanVersion The version of netscan configured for the collector
suppressAlertClear Whether or not notifications indicating that a collector alert has cleared should be suppressed
build The collector version
lastSentNotificationOnLocal The local date and time that the last notification was sent for this collector
id The collector id
resendIval How frequently alert notifications should be re-sent for this collector (until they are acknowledged)
watchdogUpdatedOn The last date and time the LogicMonitor Watchdog Service was updated
escalatingChainId The id of the escalation chain that alert notifications will be sent to for this colelctor
description The collector description
ackComment The comment submitted with the alert acknowledgement for this collector
updatedOn The time (in epoch format) that the collector was last updated
updatedOnLocal The local date and time that the collector was last updated
agentConf The configuration file for the collector
platform The platform the collector is compatible with (Linux or Windows)
ackedBy The user who acknowledged the alert for this collector
isDown Whether or not the collector is down
escalatingChain The escalation chain configured for this collector
status The registration status of the collector. Status can be 0 | 1 | 2| 3:

0 : Unregistered collector
1 : Registered collector
2 : Stopped collector
3 : Suspended collector

ackedOn The time that the collector alert was acknowledged
confVersion The collector configuration file version
uptime The collector uptime
hostname The hostname for the device the collector is installed on
createdOnLocal The date and time the collector was added to your account
credential The collector credential, used for communicating with LogicMonitor's data centers
createdOn The time (in epoch format) the collector was added to your account
numOfHosts The number of hosts monitored by this collector
backupAgentId The Id of the backup (failover) collector, if one is configured
acked Whether or not there is a collector alert that is acknowlodged

 

Step 2. Download the Installer

After the collector is created and registered in your LogicMonitor account an install file must be downloaded and executed.

1. For a Windows server:

https://accountName.logicmonitor.com/santaba/do/LogicMonitorSetup.exe?id=123&
c=accountName&u=user&p=password&arch=machineArchitecture

 
2. For a Linux server:

https://accountName.logicmonitor.com/santaba/do/logicmonitorsetup?id=123&c=accountName&u=user&p=password&arch=machineArchitecture

or:

curl -o outputFileName.bin "https://accountName.logicmonitor.com/santaba/do/logicmonitorsetup?id=123&c=accountName&u=user&p=password&arch=machineArchitecture

 

Note: The binary will be hardcoded with the identifier of the collector created in step 1 - each collector installation requires a separate download.

 

Parameter

Type

Description

outputFileName String The desired name for your collector installer
id Integer The unique id of the collector you are trying to install. This will download the installer for the specific collector. 
arch Integer The architecture of the bundled JVM required for the collector to run. Valid inputs include 32 and 64, where this value corresponds to architecture of the operating system. If this value is not specified, it defaults to 32.

 

Step 3. Silent 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.

For 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.
/p: (Required if /a is given) This is the password to use that corresponds to the user account specified.
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.

For 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

 

Example

addAgent:

Request:
curl "https://apiAccount.logicmonitor.com/santaba/rpc/addAgent?c=apiAccount&u=apiUser&p=example&autogen=true"
  Response:
{
  "status": 200,
  "data": {
    "nextRecipient": 0,
    "clearSent": true,
    "lastSentNotificationOn": 0,
    "netscanVersion": "0",
    "suppressAlertClear": "false",
    "build": "0",
    "lastSentNotificationOnLocal": "",
    "id": 132,
    "resendIval": 15,
    "watchdogUpdatedOn": "2015-11-17 14:35:39 PST",
    "escalatingChainId": 0,
    "description": "",
    "ackComment": "",
    "credential2": "",
    "updatedOn": 1447799739,
    "updatedOnLocal": "2015-11-17 14:35:39 PST",
    "agentConf": "",
    "platform": "n/a",
    "ackedBy": "",
    "isDown": false,
    "status": 0,
    "ackedOn": "",
    "confVersion": "0",
    "uptime": 0,
    "createdOnLocal": "2015-11-17 14:35:39 PST",
    "credential": "gi{ppwC8",
    "createdOn": 1447799739,
    "numberOfHosts": 0,
    "backupAgentId": 0,
    "company": "sarah",
    "server": "sarah.logicmonitor.com",
    "acked": false
  },
  "errmsg": "OK"
} 

 

Download the installer

Request:
curl -o lmSetup.bin "https://sarah.logicmonitor.com/santaba/do/logicmonitorsetup?c=sarah&u=sarah&p=example&id=132&arch=64" 
  Response:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  101M  100  101M    0     0   717k      0  0:02:24  0:02:24 --:--:--  589k 

 

Install the Collector

[[email protected] sterry]# chmod +x lmSetup.bin
[[email protected] sterry]# ./lmSetup.bin
Enter the installation parent directory [/usr/local/logicmonitor]:
Extracting installer files ...
Extracting bundled JRE files ...
Detecting proxy, please wait ...
Registering collector, please wait ...
Starting LogicMonitor Watchdog ...
Congratulations! LogicMonitor Collector has been installed successfully!