diff --git a/defaults/main.yml b/defaults/main.yml index a5698a8..cbfe8be 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -38,6 +38,7 @@ opn_check_mk_local_checks: - crash_status.py - firmware_status.py - pkg_audit.py + - pkg_check.sh - pfctl_status.sh - check_powerunit.sh diff --git a/files/pkg_check.sh b/files/pkg_check.sh new file mode 100755 index 0000000..48fd467 --- /dev/null +++ b/files/pkg_check.sh @@ -0,0 +1,21 @@ +#! /usr/local/bin/bash + +declare -i ECODE=0 +declare STATUS="OK" +declare TXT="" + +PCKCHECKDEPS="$(pkg check -d -a -n 2>&1 | sed '1d'; exit ${PIPESTATUS[0]})" +declare -ri PCKCHECKDEPSECODE=$? + +if [ $PCKCHECKDEPSECODE -gt 0 ]; then + STATUS="CRITICAL" + ECODE=2 + TXT="pkg check exit code: $PCKCHECKDEPSECODE; output: $PCKCHECKDEPS" +elif [ -n "$PCKCHECKDEPS" ]; then + STATUS="WARNING" + ECODE=1 + TXT="$(echo $PCKCHECKDEPS)" +fi + +echo "$ECODE PCK_CHECK_DEPENDENCIES - $STATUS - $TXT" +exit 0