diff --git a/docs/30_Examples.md b/docs/30_Examples.md index 096bc616567c55eae5554b26961fed874fc78ab5..eaa02b28f1cae1bba98f6f4124f38abd4b6fa832 100644 --- a/docs/30_Examples.md +++ b/docs/30_Examples.md @@ -65,7 +65,7 @@ url_effective:http://www.iml.unibe.ch/ ``` -# Icinga API +# Icinga2 API In that example we have a config for an api access with url, user and password. The docs url is not required for functionality. It will be shown on errors. @@ -80,7 +80,8 @@ RestApiPassword="password-of-Icinga-Api-User" RestApiDocs="https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/" ``` -And now let's access the Icinga API... +And now let's access the Icinga API and try to find out if the current host +is available in Icinga2. Therefor we make a GET request to `[API url]/objects/hosts/[my hostname]`. ```sh myHost=( hostname -f ) @@ -95,13 +96,13 @@ http.setDocs "${RestApiDocs}" # Because we set a base url we can operate with the part behind it http.makeRequest GET "objects/hosts/${myHost}" -# --- show a result +# --- show http response body (some JSON) http.getResponse # set return code of GET action ... $? is 0 on success (2xx status code) http.isOk >/dev/null if [ $? -ne 0 ]; then - if [ "`http.getStatuscode`" = "000" ]; then + if [ "$( http.getStatuscode )" = "000" ]; then echo "ERROR: Unable to reach the Icinga node." exit 1 fi