Skip to content

Commit

Permalink
ipmplemented pkg check dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
zerwes committed Jan 5, 2024
1 parent 77557e2 commit a6e927e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 21 additions & 0 deletions files/pkg_check.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a6e927e

Please sign in to comment.