-
Notifications
You must be signed in to change notification settings - Fork 15
Examples
Crapworks edited this page Dec 9, 2012
·
8 revisions
Here are some example api calls via Curl. Of course the response depends on your configuration.
Find all host objects
$ curl -H "content-type: application/json" 'http://admin:password@localhost:5000/host'
[
{
"check_command": "check-host-alive",
"name": "generic-host",
"notification_interval": "0",
"retain_nonstatus_information": "1",
"failure_prediction_enabled": "1",
"notifications_enabled": "1",
"contact_groups": "admins",
"retain_status_information": "1",
"notification_period": "24x7",
"event_handler_enabled": "1",
"process_perf_data": "1",
"max_check_attempts": "10",
"flap_detection_enabled": "1",
"notification_options": "d,u,r",
"register": "0"
},
{
"alias": "localhost",
"use": "generic-host",
"host_name": "localhost",
"address": "127.0.0.1"
},
[...]
]
Get all hosts with testhost in the host_name
field
$ curl -H "content-type: application/json" 'http://admin:password@localhost:5000/host?host_name=testhost'
[
{
"alias": "testhost2",
"use": "generic-host",
"host_name": "testhost2",
"address": "127.0.0.3"
},
{
"alias": "testhost1",
"use": "generic-host",
"host_name": "testhost1",
"address": "127.0.0.2"
},
{
"alias": "testhost3",
"use": "generic-host",
"host_name": "testhost3",
"address": "127.0.0.4"
}
]
Delete all host objects with testhost in the host_name
field
$ curl -X DELETE -H "content-type: application/json" 'http://admin:password@localhost:5000/host?host_name=testhost'
{
"results": [
{
"200": "successfully deleted host object: testhost2"
},
{
"200": "successfully deleted host object: testhost1"
},
{
"200": "successfully deleted host object: testhost3"
}
],
"summary": {
"failed": 0,
"total": 3,
"succeeded": 3
}
}
$ curl -X POST -H "content-type: application/json" 'http://admin:password@localhost:5000/control?restart'
{
"result": "successfully sent command to command file"
}