Page 1 of 1

passing $ARG1$ / $ARG2$ values to service when creating

Posted: Tue Dec 18, 2018 4:48 pm
by lukesullivan
I'm creating services from a template using the rest api. An example of the payload I'm sending via http/post is:

payload = {'host_name' : devname,
'service_description': str(service['display_name']) + '--- interface counters',
'servicegroups' : 'huit-its-interface-counters',
'use' : 'huit-its-network-device-interface-counters',
'arg2' : str(ifIndex),
'force' : 1
}

The service template has a check_command of:

/usr/local/nagios/libexec_custom/check_ifcounters.py -hostname $HOSTADDRESS$ -previousperfdata "$SERVICEPERFDATA$" -snmpcomstring $ARG1$ -ifindex $ARG2$

the $ARG1$ value is supplied by the template, as it's the same for all the services being created, but the $ARG2$ value is different for each service.

is there a way in the http/post method to specify $ARG2$ for a specific service being created?

thanks,

-Luke

Re: passing $ARG1$ / $ARG2$ values to service when creating

Posted: Wed Dec 19, 2018 2:41 pm
by tgriep
In the API, there is not a way to just pass in the value for one of the Arguments, you will have to pass in the full command and all of the arguments in the API call.
The command and the arguments in the API call are grouped together so there is not a way to do that.