diff options
Diffstat (limited to 'modules/private/monitoring/plugins/send_nrdp.sh')
-rwxr-xr-x | modules/private/monitoring/plugins/send_nrdp.sh | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/modules/private/monitoring/plugins/send_nrdp.sh b/modules/private/monitoring/plugins/send_nrdp.sh deleted file mode 100755 index c83c8cb..0000000 --- a/modules/private/monitoring/plugins/send_nrdp.sh +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | TEMPLATE='{ | ||
4 | "cmd": "submitcheck", | ||
5 | "token": $token, | ||
6 | "checkresult": [{ | ||
7 | "hostname": $hostname, | ||
8 | "state": $state, | ||
9 | "output": $output, | ||
10 | "type": $type, | ||
11 | "servicename": $servicename | ||
12 | }] | ||
13 | }' | ||
14 | |||
15 | while getopts "u:t:H:s:S:o:" option | ||
16 | do | ||
17 | case $option in | ||
18 | u) url=$OPTARG ;; | ||
19 | t) token=$OPTARG ;; | ||
20 | H) hostname=$OPTARG ;; | ||
21 | s) servicename=$OPTARG ;; | ||
22 | S) state=$OPTARG ;; | ||
23 | o) output=$OPTARG ;; | ||
24 | esac | ||
25 | done | ||
26 | |||
27 | if [ -n "$servicename" ]; then | ||
28 | checktype="service" | ||
29 | else | ||
30 | checktype="host" | ||
31 | fi | ||
32 | |||
33 | payload=$(jq -n \ | ||
34 | --arg type "$checktype" \ | ||
35 | --arg hostname "$hostname" \ | ||
36 | --arg servicename "$servicename" \ | ||
37 | --arg output "$output" \ | ||
38 | --arg token "$token" \ | ||
39 | --arg state "$state" \ | ||
40 | "$TEMPLATE") | ||
41 | |||
42 | rslt=$(curl -f --silent --insecure -d "$payload" -H "Content-Type: application/json" "$url") | ||
43 | ret=$? | ||
44 | |||
45 | if [ $ret != 0 ];then | ||
46 | echo "ERROR: could not connect to NRDP server at $url" | ||
47 | exit 1 | ||
48 | fi | ||
49 | |||
50 | status=$(echo "$rslt" | jq -r .status) | ||
51 | message=$(echo "$rslt" | jq -r .message) | ||
52 | |||
53 | if [ "$status" != "ok" ];then | ||
54 | echo "ERROR: The NRDP Server said $message" | ||
55 | exit 2 | ||
56 | fi | ||
57 | echo "Sent 1 checks to $url" | ||