From c2df0f6cf0dec794e9697119b000f6d9cfa8e86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jochum?= Date: Wed, 30 Sep 2020 14:01:54 +0200 Subject: [PATCH] Improve example.sh --- example.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/example.sh b/example.sh index 862b757..4956009 100755 --- a/example.sh +++ b/example.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Example call: ./example.sh https://checkmk.myserver.com/example/lql-api "-u myuser:SuperSecretPw!#" + # Configuration SERVER="http://localhost:8080" if [ -n "$1" ]; then @@ -12,14 +14,22 @@ ARGS=$2 # Execute set -ex +CURL="/usr/bin/curl $2 -s -f" + # GET Hosts -curl $2 -X POST -d '{"method": "GET", "table": "hosts", "columns": ["name", "address", "groups"]}' $SERVER/v1/raw +# $CURL -X POST -d '{"method": "GET", "table": "hosts", "columns": ["name", "address"]}' $SERVER/v1/raw + +# Same Request but with table endpoint +$CURL "$SERVER/v1/table/hosts?columns=name,address" # GET Hosts with limit -curl $2 -X POST -d '{"method": "GET", "table": "hosts", "columns": ["name", "address", "groups"], "limit": 3}' $SERVER/v1/raw +# $CURL -X POST -d '{"method": "GET", "table": "hosts", "columns": ["name", "address", "groups"], "limit": 3}' $SERVER/v1/raw + +# Same Request but with table endpoint +$CURL "$SERVER/v1/table/hosts?columns=name&column=address&column=groups&limit=3" # host stats from the tactical_overview widget -curl $2 -X POST -d '{"method": "GET", "table": "hosts", "query": [["Stats", "state >= 0"], ["Stats", "state > 0"], ["Stats", "scheduled_downtime_depth = 0"], ["StatsAnd", "2"], ["Stats", "state > 0"], ["Stats", "scheduled_downtime_depth = 0"], ["Stats", "acknowledged = 0"], ["StatsAnd", "3"], ["Stats", "host_staleness >= 1.5"], ["Stats", "host_scheduled_downtime_depth = 0"], ["StatsAnd", "2"]]}' $SERVER/v1/raw +# $CURL -X POST -d '{"method": "GET", "table": "hosts", "query": [["Stats", "state >= 0"], ["Stats", "state > 0"], ["Stats", "scheduled_downtime_depth = 0"], ["StatsAnd", "2"], ["Stats", "state > 0"], ["Stats", "scheduled_downtime_depth = 0"], ["Stats", "acknowledged = 0"], ["StatsAnd", "3"], ["Stats", "host_staleness >= 1.5"], ["Stats", "host_scheduled_downtime_depth = 0"], ["StatsAnd", "2"]]}' $SERVER/v1/raw # Tactical overview data :) -curl $2 $SERVER/v1/stats/tactical_overview \ No newline at end of file +$CURL $SERVER/v1/stats/tactical_overview \ No newline at end of file