[icinga-checkins] icinga.org: icinga2-api-examples/master: Add PAW API calls

git at icinga.org git at icinga.org
Wed Oct 19 01:16:40 CEST 2016


Module: icinga2-api-examples
Branch: master
Commit: 485f023597463d1dab81c9accf1d535081520741
URL:    https://git.icinga.org/?p=icinga2-api-examples.git;a=commit;h=485f023597463d1dab81c9accf1d535081520741

Author: Michael Friedrich <michael.friedrich at icinga.com>
Date:   Wed Oct 19 01:07:34 2016 +0200

Add PAW API calls

---

 README.md         |    2 +-
 paw/api_calls.paw |  Bin 0 -> 55648 bytes
 paw/api_calls.sh  |  102 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 580d9d6..4c42b64 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ If any tool or script is missing, please send a patch/PR :)
 ## REST API Clients
 
 * Browser plugins
-* [Paw for OSX](https://luckymarmot.com)
+* [Paw for MacOS](https://paw.cloud), examples [here](paw/)
 * [Icinga Studio](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/icinga2-api#icinga2-api-clients-icinga-studio)
 * [icinga2 console](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/icinga2-api#icinga2-api-clients-cli-console)
 
diff --git a/paw/api_calls.paw b/paw/api_calls.paw
new file mode 100755
index 0000000..a88cd1e
Binary files /dev/null and b/paw/api_calls.paw differ
diff --git a/paw/api_calls.sh b/paw/api_calls.sh
new file mode 100644
index 0000000..4378ecb
--- /dev/null
+++ b/paw/api_calls.sh
@@ -0,0 +1,102 @@
+## List all hosts
+curl -X "GET" "https://192.168.33.5:5665/v1/objects/hosts?attrs=__name&attrs=address6" \
+     -u root:icinga
+
+## List localhost
+curl -X "GET" "https://192.168.33.5:5665/v1/objects/hosts?host=icinga2" \
+     -H "Content-Type: application/octet-stream" \
+     -u root:icinga
+
+## List localhost service
+curl -X "GET" "https://192.168.33.5:5665/v1/objects/services?service=icinga2!ping6" \
+     -u root:icinga
+
+## Process checkresult
+curl -X "POST" "https://192.168.33.5:5665/v1/actions/process-check-result?service=icinga2!ping6&type=Service" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:icinga \
+     -d "{\"exit_status\":2,\"plugin_output\":\"PING CRITICAL - Packet loss = 100%\",\"performance_data\":[\"rta=5000.000000ms;3000.000000;5000.000000;0.000000\",\"pl=100%;80;100;0\"],\"check_source\":\"example.localdomain\"}"
+
+## Reschedule check
+curl -X "POST" "https://192.168.33.5:5665/v1/actions/reschedule-check?filter=true&type=Service" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:icinga \
+     -d "{}"
+
+## Add comment
+curl -X "POST" "https://192.168.33.5:5665/v1/actions/add-comment" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:icinga \
+     -d "{\"type\":\"Service\",\"filter\":\"service.name==\\\"ping6\\\"\",\"author\":\"michi\",\"comment\":\"I don't care. Gin 4 the win\"}"
+
+## Create host icinga.com
+curl -X "PUT" "https://192.168.33.5:5665/v1/objects/hosts/icinga.com" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:icinga \
+     -d "{\"templates\":[\"generic-host\"],\"attrs\":{\"address\":\"192.168.1.1\",\"check_interval\":30,\"check_command\":\"hostalive\",\"vars.os\":\"Linux\"}}"
+
+## Modify host icinga.com
+curl -X "POST" "https://192.168.33.5:5665/v1/objects/hosts/icinga.com" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:icinga \
+     -d "{\"attrs\":{\"address\":\"192.168.33.5\"}}"
+
+## Create host github.com
+curl -X "PUT" "https://192.168.33.5:5665/v1/objects/hosts/github.com" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:icinga \
+     -d "{\"templates\":[\"generic-host\"],\"attrs\":{\"address\":\"192.168.1.1\",\"check_command\":\"hostalive\",\"vars.os\":\"Linux\"}}"
+
+## Delete multiple hosts
+curl -X "DELETE" "https://192.168.33.5:5665/v1/objects/hosts" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:***** Hidden credentials ***** \
+     -d "{\"filter\":\"match(\\\"*com*\\\", host.name)\",\"cascade\":true}"
+
+## Acknowledge all problems
+curl -X "POST" "https://192.168.33.5:5665/v1/actions/acknowledge-problem" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:icinga \
+     -d "{\"type\":\"Service\",\"filter\":\"service.state!=ServiceOK\",\"author\":\"michi\",\"comment\":\"Global outage. Working on it.\",\"notify\":true}"
+
+## Remove all acknowledgements
+curl -X "POST" "https://192.168.33.5:5665/v1/actions/remove-acknowledgement" \
+     -H "Accept: application/json" \
+     -H "Content-Type: text/plain; charset=utf-8" \
+     -u root:icinga \
+     -d $'{
+  "type": "Service",
+  "filter": "service.state!=ServiceOK"
+}'
+
+## Create realtime load check
+curl -X "PUT" "https://192.168.33.5:5665/v1/objects/services/icinga2!load-realtime" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:***** Hidden credentials ***** \
+     -d "{\"templates\":[\"generic-service\"],\"attrs\":{\"check_command\":\"load\",\"check_interval\":1,\"retry_interval\":1}}"
+
+## Delete realtime load check
+curl -X "DELETE" "https://192.168.33.5:5665/v1/objects/services/icinga2!load-realtime?cascade=1" \
+     -H "Accept: application/json" \
+     -H "Content-Type: application/json; charset=utf-8" \
+     -u root:***** Hidden credentials ***** \
+     -d "{}"
+
+## Delete all service comments
+curl -X "POST" "https://192.168.33.5:5665/v1/actions/remove-comment?type=Service&filter=true" \
+     -H "Accept: application/json" \
+     -u root:icinga
+
+## Delete all host comments
+curl -X "POST" "https://192.168.33.5:5665/v1/actions/remove-comment?type=Host&filter=true" \
+     -H "Accept: application/json" \
+     -u root:icinga



More information about the icinga-checkins mailing list