Skip to content

Commit 9c26311

Browse files
committed
updating readme and adding scripts
1 parent 822f8d7 commit 9c26311

File tree

9 files changed

+526
-2
lines changed

9 files changed

+526
-2
lines changed

README.md

Lines changed: 429 additions & 2 deletions
Large diffs are not rendered by default.

create_hostgroups.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash -e
2+
3+
. icinga2_env_vars
4+
5+
echo "creating hostgroups"
6+
7+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
8+
-H 'Accept: application/json' -X PUT \
9+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/hostgroups/api_dummy_hostgroup" \
10+
-d '{ "attrs": { "display_name": "api_dummy_hostgroup" } }' | python -m json.tool
11+
12+
sleep 5

create_hosts.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash -e
2+
3+
. icinga2_env_vars
4+
5+
echo "creating hosts"
6+
7+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
8+
-H 'Accept: application/json' -X PUT \
9+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/hosts/api_dummy_host_1" \
10+
-d '{ "templates": [ "generic-host" ], "attrs": { "address": "8.8.8.8", "vars.os" : "Linux", "vars.hostgroups": "X,api_dummy_hostgroup,X", "groups": ["api_dummy_hostgroup"] } }' | python -m json.tool
11+
12+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
13+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/hosts/api_dummy_host_2" \
14+
-H 'Accept: application/json' -X PUT \
15+
-d '{ "templates": [ "generic-host" ], "attrs": { "address": "8.8.4.4", "vars.os" : "Linux", "vars.hostgroups": "X,api_dummy_hostgroup,X", "groups": ["api_dummy_hostgroup"] } }' | python -m json.tool
16+
17+
sleep 5

create_services.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash -e
2+
3+
. icinga2_env_vars
4+
5+
echo "creating services"
6+
7+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
8+
-H 'Accept: application/json' -X PUT \
9+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/services/api_dummy_host_1!api_dummy_service_1" \
10+
-d '{ "templates": [ "generic-service" ], "attrs": { "display_name": "api_dummy_service_1", "check_command" : "dns", "vars.dns_lookup": "google-public-dns-a.google.com.", "vars.dns_expected_answer": "8.8.8.8", "host_name": "api_dummy_host_1" } }' | python -m json.tool
11+
12+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
13+
-H 'Accept: application/json' -X PUT \
14+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/services/api_dummy_host_2!api_dummy_service_2" \
15+
-d '{ "templates": [ "generic-service" ], "attrs": { "display_name": "api_dummy_service_2", "check_command" : "dns", "vars.dns_lookup": "google-public-dns-b.google.com.", "vars.dns_expected_answer": "8.8.4.4", "host_name": "api_dummy_host_2" } }' | python -m json.tool
16+
17+
sleep 5

delete_hostgroups.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash -e
2+
3+
. icinga2_env_vars
4+
5+
echo "deleting hostgroups"
6+
7+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
8+
-H 'Accept: application/json' -H 'X-HTTP-Method-Override: DELETE' -X POST \
9+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/hostgroups/api_dummy_hostgroup?cascade=1" | python -m json.tool
10+
11+
sleep 5

delete_hosts.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash -e
2+
3+
. icinga2_env_vars
4+
5+
echo "deleting hosts"
6+
7+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
8+
-H 'Accept: application/json' -H 'X-HTTP-Method-Override: DELETE' -X POST \
9+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/hosts/api_dummy_host_1?cascade=1" | python -m json.tool
10+
11+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
12+
-H 'Accept: application/json' -H 'X-HTTP-Method-Override: DELETE' -X POST \
13+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/hosts/api_dummy_host_2?cascade=1" | python -m json.tool
14+
15+
sleep 5

delete_services.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash -e
2+
3+
. icinga2_env_vars
4+
5+
echo "deleting services"
6+
7+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
8+
-H 'Accept: application/json' -H 'X-HTTP-Method-Override: DELETE' -X POST \
9+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/services/api_dummy_host_1!api_dummy_service_1" | python -m json.tool
10+
11+
curl -s -u $ICINGA2_API_USER:$ICINGA2_API_PASSWORD \
12+
-H 'Accept: application/json' -H 'X-HTTP-Method-Override: DELETE' -X POST \
13+
-k "https://$ICINGA2_HOST:$ICINGA2_API_PORT/v1/objects/services/api_dummy_host_2!api_dummy_service_2" | python -m json.tool
14+
15+
sleep 5

setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
. icinga2_env_vars
3+
./create_hostgroups.sh
4+
./create_hosts.sh
5+
./create_services.sh

teardown.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
. icinga2_env_vars
3+
./delete_services.sh
4+
./delete_hosts.sh
5+
./delete_hostgroups.sh

0 commit comments

Comments
 (0)