Hi guys!
I need to disable notifications for several services on a lot of hosts.
Yeah, through Director it’s easy for one or two hosts but I have over 50 hosts and this simple task become a monkey job(
Could you advise how I can disable notification for a particular service on a host using API?
Thanks for any help!
Hmm, as a variant if API can’t
If I can GET attr on a service:
curl -k -s -u 'director' -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X GET 'https://localhost:5665/v1/objects/services/HOST!check_cpu_load' -d '{ "attrs": ["enable_notifications" ], "pretty": true }'
Enter host password for user 'director':
{
"results": [
{
"attrs": {
"enable_notifications": true
},
"joins": {},
"meta": {},
"name": "HOST!check_cpu_load",
"type": "Service"
}
]
}
Then I can change it, but no( :
curl -k -s -u 'director' -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/services/HOST!check_cpu_load' -d '{ "attrs": { "enable_notifications": false }, "pretty": true}'
Enter host password for user 'director':
{
"error": 400.0,
"status": "Invalid type for 'attrs' attribute specified. Array type is required."
}
Tried as an array but also no
curl -k -s -u 'director' -H 'Accept: application/json' -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/services/HOST!check_cpu_load' -d '{ "attrs": { "enable_notifications": false }, "pretty": true}'
You are still sending a GET
request this way and not POST
, since you are overriding the actual post request with X-HTTP-Method-Override: GET
. You might want to try it this way, then it should work.
curl -k -s -u 'director' -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/objects/services/HOST!check_cpu_load' -d '{ "attrs": { "enable_notifications": false }, "pretty": true}'
1 Like