RPC API Developer's Guide (Deprecated)

RPC API: Update a Device

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

LogicMonitor's RPC API enables you to update devices using updateHost.

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

 

updateHost

URL:
https://accountName.logicmonitor.com/santaba/rpc/updateHost?c=accountName&u=user&p=password&id=hostIdNum&hostName=hostName&displayedAs=displayName&hostGroupIds=hostGroupId1,hostGroupId2&agentId=agentIdNum&opType=add|replace|refresh&propName0=property0Name&propValue0=property0Value

 

Request Parameters: You can include the following as query parameters in an updateHost request:

Parameter

Type

Description

hostName String Required. The name of the device
displayedAs String Required. The unique display name of the device
id Integer Required. The unique Id of the device. This id value can be retrieved using getHost(), or by selecting the device in the Device Tree and then selecting the focus icon - the id will be in the URL as d-##.
agentId String Required. The unique Id of the Collector that monitors the device. Collector Ids are displayed in your account UI (Settings | Collectors).
hostGroupIds String Optional. The device Groups number(s) that this device should belong to, where multiple values must be separated by commas. Note that if it this parameter is omitted from the request, it will revert back to its default value (of 1, which corresponds to the root group)

 


To get a hostGroupId in the UI: navigate to the group, select the focus icon & the id is in the URL as dg-##.

description String Optional. The device description. Note that if it this parameter is omitted from the request, it will revert back to its default value
alertEnable Boolean Optional. true (default)|false. Note that if it this parameter is omitted from the request, it will revert back to its default value

true: Alerts will be enabled for the device.
false: Alerts will be disabled for the device.

link String Optional. The HTTP Link to the device. Note that if it this parameter is omitted from the request, it will revert back to its default value
enableNetflow Boolean Optional. true|false (default). Note that if it this parameter is omitted from the request, it will revert back to its default value

true: Netflow monitoring will be enabled for the device.
false: Netflow monitoring will be disabled for the device.

netflowAgentId String Required if Netflow is enabled. The Id of the collector that collects Netflow data for the device.
opType String Optional. add | replace | refresh (default)

add: Add a property with the given value to a device. If the property already exists, no action is taken (the existing value will not be changed).

replace: Add a property with the specified value if it does not exist, or update the property's value if it does exist.

refresh: Replace all the properties of the device (including group membership) with the properties and values provided in the updateHost call. Any properties not present in the refresh call will be deleted. Inherited properties are not affected.

Note: The opType parameter dictates how host properties are changed. Add and Replace opType values refer only to the custom device properties set by the propName, propValue fields (e.g. snmp.community, esx.user, jdbc.mssql.pass). Device properties such as displayedAs, hostGroupIds, description, alertEnable, link, and enableNetflow must be specified in the request. If these are omitted they will be reset to a default or blank value.

propName{0..n} String Optional. The Device Property Name. The list of properties specified in the request must start with propName0.
propValue{0..n} string Required if propName is specified. The Device Property Value corresponding to the Property Name

 

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

netflowAgentId The ID of the netflow agent of the added device. Defaults to 0 if non-netflow device
displayedAs The Display Name of the added device
link The HTTP Link to the added device
hgIds The device Groups the added device is in. (Does not include root group)
lastrawdatatime/lastdatatime The last time (epoch format) since the device got Netflow (raw) data
agentId The ID of the Collector monitoring the added device
id The ID of the device
createdOn The epoch time stamp when the device was added
alertEnable Boolean value that indicates whether the added device has alerting enabled
isActive

Boolean value: 

If this value is true, the device has been updated in the past hour.
If this value is false, the Host has not been updated in the past hour.

autoPropsUpdatedOn The last time (epoch) properties were updated
description The description of the added device
name The display name of the added device
hostname The hostname of the added device
autoPropsAssignedOn The assignment time (epoch) of the device properties
updatedOn The last time the added device was updated (epoch)
enableNetflow Boolean value that indicates whether netflow is enabled or not

 

Example 1

The following example updates device 10.0.1.36 in account apiAccount:

Request:
curl "https://apiAccount.logicmonitor.com/santaba/rpc/updateHost?c=apiAccount&u=apiUser&p=example&hostName=10.0.1.36&displayedAs=MyDevice&id=208&agentId=85&alertEnable=false" 
Response:
{
  "status": 200,
  "data": {
    "relatedDeviceId": -1,
    "netflowAgentId": 0,
    "displayedAs": "MyDevice",
    "link": "",
    "hgIds": "",
    "lastrawdatatime": 0,
    "agentId": 85,
    "scanConfigId": 0,
    "deletedOnMillis": 0,
    "groupd": true,
    "id": 208,
    "createdOn": 1447886410,
    "alertEnable": false,
    "isActive": false,
    "lastdatatime": 0,
    "toDeleteOnMillis": 0,
    "autoPropsUpdatedOn": 1447886531,
    "deviceType": 0,
    "description": "",
    "name": "MyDevice",
    "hostName": "10.0.1.36",
    "autoPropsAssignedOn": 1447886410,
    "updatedOn": 1447886410,
    "enableNetflow": false
  },
  "errmsg": "OK"
} 

 

Example 2

The following request adds the location property to device ip-172-31-37-162.us-west-2.compute.interal in account apiAccount.logicmonitor.com, and sets the value to 12 E. Carrillo, Santa Barbara, CA.  All other devices properties are left alone.

Request:
curl "https://apiAccount.logicmonitor.com/santaba/rpc/updateHost?c=apiAccount&u=username&p=password&hostName=ip-172-31-37-162.us-west-2.compute.interal&displayedAs=ip-172-31-37-162.us-west-2.compute.interal&id=39&agentId=85&alertEnable=true&hostGroupIds=7&description=myDeviceDescription&opType=add&propName0=location&propValue0=12%20E.%20Carrillo,Santa%20Barbara,CA" 
Response:
{
  "status": 200,
  "data": {
    "relatedDeviceId": -1,
    "netflowAgentId": 0,
    "displayedAs": "ip-172-31-37-162.us-west-2.compute.interal",
    "link": "",
    "hgIds": "7",
    "lastrawdatatime": 0,
    "agentId": 85,
    "scanConfigId": 0,
    "deletedOnMillis": 0,
    "groupd": true,
    "id": 39,
    "createdOn": 1431975317,
    "alertEnable": true,
    "isActive": false,
    "lastdatatime": 0,
    "toDeleteOnMillis": 0,
    "autoPropsUpdatedOn": 1462327761,
    "deviceType": 0,
    "description": "myDeviceDescription",
    "name": "ip-172-31-37-162.us-west-2.compute.interal",
    "hostName": "ip-172-31-37-162.us-west-2.compute.interal",
    "autoPropsAssignedOn": 1462327761,
    "updatedOn": 1462395313,
    "enableNetflow": false
  },
  "errmsg": "OK"
} 

 

Example 3

The following request updates the value of the location property for device ip-172-31-37-162.us-west-2.compute.interal in account apiAccount.logicmonitor.com to 1002 Anacapa, Santa Barbara, CA.  All other devices properties are left alone.

Request:
curl "https://apiAccount.logicmonitor.com/santaba/rpc/updateHost?c=apiAccount&u=username&p=password&hostName=ip-172-31-37-162.us-west-2.compute.interal&displayedAs=ip-172-31-37-162.us-west-2.compute.interal&id=39&agentId=85&alertEnable=true&hostGroupIds=7&description=myDeviceDescription&opType=replace&propName0=location&propValue0=1002%20Anacapa,Santa%20Barbara,CA" 
Response:
{
  "status": 200,
  "data": {
    "relatedDeviceId": -1,
    "netflowAgentId": 0,
    "displayedAs": "ip-172-31-37-162.us-west-2.compute.interal",
    "link": "",
    "hgIds": "7",
    "lastrawdatatime": 0,
    "agentId": 85,
    "scanConfigId": 0,
    "deletedOnMillis": 0,
    "groupd": true,
    "id": 39,
    "createdOn": 1431975317,
    "alertEnable": true,
    "isActive": false,
    "lastdatatime": 0,
    "toDeleteOnMillis": 0,
    "autoPropsUpdatedOn": 1462313262,
    "deviceType": 0,
    "description": "myDeviceDescription",
    "name": "ip-172-31-37-162.us-west-2.compute.interal",
    "hostName": "ip-172-31-37-162.us-west-2.compute.interal",
    "autoPropsAssignedOn": 1462399662,
    "updatedOn": 1462395313,
    "enableNetflow": false
  },
  "errmsg": "OK"
}