host.massupdate

Description

object host.massupdate(object **parameters**)

This method allows to simultaneously replace or remove related objects and update properties on multiple hosts.

Parameters

(object) Parameters containing the IDs of the hosts to update and the properties that should be updated.

Additionally to the standard host properties, the method accepts the following parameters.

ParameterTypeDescription
hosts
(required)
object/arrayHosts to be updated.

The hosts must have the hostid property defined.
groupsobject/arrayHost groups to replace the current host groups the hosts belong to.

The host groups must have the groupid property defined.
interfacesobject/arrayHost interfaces to replace the current host interfaces on the given hosts.
inventoryobjectHost inventory properties.

Host inventory mode cannot be updated using the inventory parameter, use inventory_mode instead.
macrosobject/arrayUser macros to replace the current user macros on the given hosts.
templatesobject/arrayTemplates to replace the currently linked templates on the given hosts.

The templates must have the templateid property defined.
templates_clearobject/arrayTemplates to unlink and clear from the given hosts.

The templates must have the templateid property defined.

Return values

(object) Returns an object containing the IDs of the updated hosts under the hostids property.

Examples

Enabling multiple hosts

Enable monitoring of two hosts, i.e., set their status to 0.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "host.massupdate",
  4. "params": {
  5. "hosts": [
  6. {
  7. "hostid": "69665"
  8. },
  9. {
  10. "hostid": "69666"
  11. }
  12. ],
  13. "status": 0
  14. },
  15. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  16. "id": 1
  17. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "hostids": [
  5. "69665",
  6. "69666"
  7. ]
  8. },
  9. "id": 1
  10. }

See also

Source

CHost::massUpdate() in ui/include/classes/api/services/CHost.php.