REST API Less than sign
Posted: Wed Feb 26, 2020 9:17 am
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))"
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))"