Files
cis/script/monitor/checks/GENERIC_ZFSPOOL_USAGE_CHECK.sh
2025-03-26 00:17:43 +01:00

27 lines
846 B
Bash
Executable File

#!/bin/bash
SERVER="${1:?"FQDN of server missing"}"
function testSpace(){
local _RESULT=$(/sbin/zpool list -H -o capacity,name | /usr/bin/sort)
local _SPACE_USED=$(echo "${_RESULT}" | /usr/bin/tail -n 1 | /usr/bin/cut -f1)
local _POOL=$(echo "${_RESULT}" | /usr/bin/tail -n 1 | /usr/bin/cut -f2)
[ -z "${_SPACE_USED}" ] \
&& echo "FAIL#NO value" \
&& return 0
[ "${1:?"Missing OK_THRESHOLD"}" -ge "${_SPACE_USED%\%*}" ] \
&& echo "OK#${_SPACE_USED} used ${_POOL}." \
&& return 0
[ "${2:?"Missing INFO_THRESHOLD"}" -ge "${_SPACE_USED%\%*}" ] \
&& echo "INFO#${_SPACE_USED} already used ${_POOL}." \
&& return 0
echo "FAIL#${_SPACE_USED} used ${_POOL}!"
return 0
}
testSpace 80 90