Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bash-rest-api-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
bash-rest-api-client
Commits
b4e13b0b
Commit
b4e13b0b
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update icinga2 example
parent
c91aec74
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/30_Examples.md
+5
-4
5 additions, 4 deletions
docs/30_Examples.md
with
5 additions
and
4 deletions
docs/30_Examples.md
+
5
−
4
View file @
b4e13b0b
...
...
@@ -65,7 +65,7 @@ url_effective:http://www.iml.unibe.ch/
```
# Icinga API
# Icinga
2
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment