Skip to content
Snippets Groups Projects
Commit b4e13b0b authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update icinga2 example

parent c91aec74
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment