diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 01:35:06 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 02:11:48 +0200 |
commit | 1a64deeb894dc95e2645a75771732c6cc53a79ad (patch) | |
tree | 1b9df4838f894577a09b9b260151756272efeb53 /modules/private/monitoring/plugins/send_nrdp.sh | |
parent | fa25ffd4583cc362075cd5e1b4130f33306103f0 (diff) | |
download | Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.gz Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.zst Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.zip |
Squash changes containing private information
There were a lot of changes since the previous commit, but a lot of them
contained personnal information about users. All thos changes got
stashed into a single commit (history is kept in a different place) and
private information was moved in a separate private repository
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" | ||