Page 1 of 1

HTTP post request to create new service with arguments

Posted: Tue Dec 07, 2021 5:27 am
by deltares_infracore
Hello,

Currently I am trying to create checks via HTTP POST and I was wondering if it is possible to pass arguments for the check since I don't see any variables for this in the help section. From the help section:
Optional Parameters Value Type
config_name config name (in CCM)
host_name host name
service_description service name
check_command command_name
max_check_attempts #
check_interval #
retry_interval #
check_period timeperiod_name
notification_interval #
notification_period timeperiod_name
contacts or contact_groups contacts or contact_groups
Is there a variable that let's me post arguments for my new check? My payload for the HTTP post will look something like this:

{'check_period': '24x7', 'config_name': 'My new check', 'notification_interval': '5', 'notification_period': '24x7', 'retry_interval': '1', 'check_command': 'My check', 'check_arg1': 'My arguments to the check', 'host_name': 'host.test.com', 'check_interval': '600', 'service_description': 'My new check', 'max_check_attempts': '1'}

Thanks in advance!

Posted: Tue Dec 07, 2021 11:53 am
by dchurch
The POST request updates the configuration database, adding a new service.

The arguments to the check command are contained in the "check_command" URL parameter, separated by "!". The parameter is in the form of

Code: Select all

{COMMAND}[!{ARG}]...
For example, sending

Code: Select all

check_command=check_ping!3000,80%!5000,100%
Would set up a service check where:

Code: Select all

command = check_ping
arg1 = 3000,80%
arg2 = 5000,100%

Re: HTTP post request to create new service with arguments

Posted: Wed Dec 08, 2021 2:49 am
by deltares_infracore
Thank you!

Re: HTTP post request to create new service with arguments

Posted: Wed Dec 08, 2021 2:05 pm
by dchurch
Glad to hear you resolved it!

Let us know if you have any related questions or if we're okay to lock this up and mark it as resolved.