Hey! These docs are for version 6.3, which is no longer officially supported. Click here for the latest version, 6.7!

Some examples for the config endpoints

Examples

Updating Multiple Service Checks

The restapi can be used to update multiple servicechecks in one go:

  • Obtain the list of check to be modified and store in a file, i.e. all service checks with 'foo' in the name.
opsview_rest --username=USER --password=PASS --pretty --data-format=json GET 'config/servicecheck?json_filter={"name":{"-like":"%25foo%25"}}' > checks.json
  • Edit the checks.json file as necessary.
  • Import the contents of the file back into Opsview.
opsview_rest --username=USER --password=PASS --pretty --data-format=json --content-file=checks.json --pretty PUT config/servicecheck

Note: the ID's within the checks.json file must be left unchanged else new checks will be created, not current checks updated.

Note: Amending service check names could lose historical (graphing) information

Determining If A Host Exists

To see if the host 'foo' already exists:

opsview_rest --username=USER --password=PASS GET 'config/host/exists?name=foo'

Will return ”{'exists' ⇒ '0'}” if the host does not exist, ”{'exists' ⇒ '1'}” if it does.