aboutsummaryrefslogtreecommitdiff
path: root/files/usr/local/libexec/nagios
diff options
context:
space:
mode:
authorCullum Smith <cullum@sacredheartsc.com>2024-10-26 00:07:03 -0400
committerCullum Smith <cullum@sacredheartsc.com>2024-10-26 00:07:03 -0400
commit6e2a5993ce470341bed0e0c6ba8e44de3712d50e (patch)
tree7a6bad35bac69e5f9264a5dde460335b1068ec9e /files/usr/local/libexec/nagios
parent7bb5176a0e1d3a7d8a119b92758404d514f59be9 (diff)
downloadinfrastructure-6e2a5993ce470341bed0e0c6ba8e44de3712d50e.tar.gz
more icinga stuff
Diffstat (limited to 'files/usr/local/libexec/nagios')
-rw-r--r--files/usr/local/libexec/nagios/check_eapol.icinga_server56
1 files changed, 56 insertions, 0 deletions
diff --git a/files/usr/local/libexec/nagios/check_eapol.icinga_server b/files/usr/local/libexec/nagios/check_eapol.icinga_server
new file mode 100644
index 0000000..47ecf16
--- /dev/null
+++ b/files/usr/local/libexec/nagios/check_eapol.icinga_server
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+PROG=check_eapol
+USAGE="USAGE: ${PROG} -c CONFIGFILE -a ADDRESS -s SECRET [-p PORT] [-t TIMEOUT] [-d]"
+
+OK=0
+WARN=1
+CRIT=2
+UNKNOWN=3
+
+usage(){
+ printf 'USAGE: %s -c CONFIGFILE -a ADDRESS -s SECRET [-p PORT] [-t TIMEOUT] [-d]' "$PROG"
+ exit "$UNKNOWN"
+}
+
+die(){
+ printf '%s: %s\n' "$PROG" "$1" 1>&2
+ exit "$UNKNOWN"
+}
+
+port=1812
+timeout=5
+debug=false
+
+while getopts :a:c:dp:s:t: opt; do
+ case $opt in
+ a) address=$OPTARG ;;
+ c) config=$OPTARG ;;
+ d) debug=true ;;
+ p) port=$OPTARG ;;
+ s) secret=$OPTARG ;;
+ t) timeout=$OPTARG ;;
+ :|?) usage ;;
+ esac
+done
+shift $((OPTIND - 1 ))
+
+[ $# -eq 0 ] || usage
+[ -r "$config" ] || die "config file not readable: ${config}"
+if [ -z "$address" ] || [ -z "$config" ] || [ -z "$secret" ]; then
+ usage
+fi
+
+if [ "$debug" = true ]; then
+ eapol_test -c "$config" -a "$address" -p "$port" -s "$secret" -t "$timeout"
+else
+ eapol_test -c "$config" -a "$address" -p "$port" -s "$secret" -t "$timeout" > /dev/null
+fi
+
+if [ $? -eq 0 ]; then
+ echo "authentication to ${address}:${port} using ${config} succeeded"
+ exit "$OK"
+else
+ echo "authentication to ${address}:${port} using ${config} failed"
+ exit "$CRIT"
+fi