aboutsummaryrefslogtreecommitdiff
path: root/modules/private/monitoring/plugins/send_nrdp.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules/private/monitoring/plugins/send_nrdp.sh')
-rwxr-xr-xmodules/private/monitoring/plugins/send_nrdp.sh57
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
3TEMPLATE='{
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
15while getopts "u:t:H:s:S:o:" option
16do
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
25done
26
27if [ -n "$servicename" ]; then
28 checktype="service"
29else
30 checktype="host"
31fi
32
33payload=$(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
42rslt=$(curl -f --silent --insecure -d "$payload" -H "Content-Type: application/json" "$url")
43ret=$?
44
45if [ $ret != 0 ];then
46 echo "ERROR: could not connect to NRDP server at $url"
47 exit 1
48fi
49
50status=$(echo "$rslt" | jq -r .status)
51message=$(echo "$rslt" | jq -r .message)
52
53if [ "$status" != "ok" ];then
54 echo "ERROR: The NRDP Server said $message"
55 exit 2
56fi
57echo "Sent 1 checks to $url"