Hi,
I'm fairly new to working with the API.
I'm trying to create a new service via the REST API, POST config/service
I originally tried this:
curl -XPOST "http://nagiosserver/nagiosxi/api/v1/con ... y&pretty=1" -d 'host_name=new_server&service_description=Disk Usage - C&use=xiwizard_itassistwindowsserver_nrpe_service&check_command=check_nrpe\!check_drivesize\!-a "warning=((free<10%) and (free<4G))" "critical=((free<5%) and (free<2G))" "top-syntax=%(status) %(problem_list)" "detail-syntax=%(drive) Total: %(size) - Used: %(used) (%(used_pct)%) - Free: %(free) (%(free_pct)%)" "drive=c"&check_interval=5&retry_interval=1&max_check_attempts=5&check_period=xi_timeperiod_24x7&contact_groups=Application Support Team - Monitoring,Server Hosting - Windows¬ification_interval=1440¬ification_period=xi_timeperiod_24x7&_xiwizard=nrpewindows&applyconfig=1'
But found that it didn't like the < symbol.
If I looked at the service in Core Config it only showed part of the string in $ARG2$ field : -a "warning=((free
I then tried to substitute the < symbol with it's hexadecimal code (%3C) :
curl -XPOST "http://nagiosserver/nagiosxi/api/v1/con ... y&pretty=1" -d 'host_name=new_server&service_description=Disk Usage - C&use=xiwizard_itassistwindowsserver_nrpe_service&check_command=check_nrpe\!check_drivesize\!-a "warning=((free%3C10%) and (free%3C4G))" "critical=((free%3C5%) and (free%3CG))" "top-syntax=%(status) %(problem_list)" "detail-syntax=%(drive) Total: %(size) - Used: %(used) (%(used_pct)%) - Free: %(free) (%(free_pct)%)" "drive=c"&check_interval=5&retry_interval=1&max_check_attempts=5&check_period=xi_timeperiod_24x7&contact_groups=Application Support Team - Monitoring,Server Hosting - Windows¬ification_interval=1440¬ification_period=xi_timeperiod_24x7&_xiwizard=nrpewindows&applyconfig=1'
This didn't work either.
I then tried adding a space before and after %3C
This worked:
curl -XPOST "http://nagiosserver/nagiosxi/api/v1/con ... y&pretty=1" -d 'host_name=new_server&service_description=Disk Usage - C&use=xiwizard_itassistwindowsserver_nrpe_service&check_command=check_nrpe\!check_drivesize\!-a "warning=((free %3C 10%) and (free %3C 4G))" "critical=((free %3C 5%) and (free %3C G))" "top-syntax=%(status) %(problem_list)" "detail-syntax=%(drive) Total: %(size) - Used: %(used) (%(used_pct)%) - Free: %(free) (%(free_pct)%)" "drive=c"&check_interval=5&retry_interval=1&max_check_attempts=5&check_period=xi_timeperiod_24x7&contact_groups=Application Support Team - Monitoring,Server Hosting - Windows¬ification_interval=1440¬ification_period=xi_timeperiod_24x7&_xiwizard=nrpewindows&applyconfig=1'
However, I'm wondering if there is a way of using the < symbol without adding a space before and after %3C
E.g I've been asked if I can make the string in $ARG2$ to look like: -a "warning=((free<10%) and (free<4G))" etc rather than a "warning=((free < 10%) and (free < 4G))"
REST API Less than sign
Re: REST API Less than sign
We've tried a number of things to replicate what you're doing, and I see how the command gets cut off, as you noted.
Because the less-than is a special character, it has to have a space before and after it in the command. The way you did it with percent-3C is the only way that seems to work, other than also replacing the space with percent-20. Either way, though, there's got to be a space before and after the less-than.
Sorry this isn't how you wanted it to work...
--Jeffrey
Because the less-than is a special character, it has to have a space before and after it in the command. The way you did it with percent-3C is the only way that seems to work, other than also replacing the space with percent-20. Either way, though, there's got to be a space before and after the less-than.
Sorry this isn't how you wanted it to work...
--Jeffrey
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: REST API Less than sign
Thank you for your response Jeffrey. At least now I know that I wasn't doing it incorrectly and there isn't a workaround. Everyday is a learning day
Thanks again,
Andy
Thanks again,
Andy
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: REST API Less than sign
Have a great day!andyb4u wrote:Thank you for your response Jeffrey. At least now I know that I wasn't doing it incorrectly and there isn't a workaround. Everyday is a learning day![]()
Thanks again,
Andy
Locking thread