You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Princeton/pu/libexec/check_https_aws_duo

48 lines
990 B
Bash

#!/bin/bash
#
# Wrapper for check_generic
#
plugins="$1"
shift
url="$1"
timeout="$2"
name="$3"
curl='/usr/bin/curl'
perl='/usr/local/bin/perl'
#
# Example:
# check_command check_http_string!admitted.Princeton.EDU!Congratulations!403 Forbidden!OK!'=~/HTTP\/1.1 OK/'
# command $USER1$/check_http_generic $USER1$ '$ARG1$' '$ARG2$' '$ARG3$' '$ARG4$' "$ARG5$" "$SERVICEDESC$"
${plugins}/check_generic -e "$curl $url 2>/dev/null | $perl -e '
use JSON qw(decode_json);
my \$data = <>;
my \$json = decode_json (\$data);
if (\$json) {
print \"\$json->{stat}: current time: \" . localtime(\$json->{response}->{time});
} else {
print \"ERROR: Invalid output: NO JSON\";
}
' 2>&1" -o "=~ /^OK:/" -t $timeout -f c -n $name -i
#$curl $url 2>/dev/null | $perl -e '
# use JSON qw(decode_json);
#
# my $data = <>;
#
# my $json = decode_json ($data);
#
# if ($json) {
# print "$json->{stat}: $json->{response}->{time}";
# } else {
# print "ERROR: Invalid output: NO JSON";
# }
#' 2>&1