Fix postfix check routine #6

Closed
opened 2020-05-09 10:08:24 +02:00 by patrick · 1 comment
Owner

Following code block does not always work:

# 2) try the postfix way
if (( _RC > 0 ))
then
    _POSTFIX_BIN="$(command -v postfix 2>>${HC_STDERR_LOG})"
    if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]]
    then
        if (( $(${_POSTFIX_BIN} status 2>>${HC_STDERR_LOG} | grep -c -i 'is running' 2>/dev/null) == 0 ))
        then
            _RC=1

        fi
    else
        warn "postfix is not installed here"
        return 1
    fi
fi

Reason: postfix status does not always return output on STDOUT/STDERR. Instead it hands its results to the postlog tool (-> syslog)

To fix: add an additional pgrep check:

# 3) try the pgrep way (note: old pgreps do not support '-c')
if (( _RC > 0 ))
then
    (( $(pgrep -u postfix pickup 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1
fi
Following code block does not always work: ``` # 2) try the postfix way if (( _RC > 0 )) then _POSTFIX_BIN="$(command -v postfix 2>>${HC_STDERR_LOG})" if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]] then if (( $(${_POSTFIX_BIN} status 2>>${HC_STDERR_LOG} | grep -c -i 'is running' 2>/dev/null) == 0 )) then _RC=1 fi else warn "postfix is not installed here" return 1 fi fi ``` Reason: `postfix status` does not always return output on STDOUT/STDERR. Instead it hands its results to the `postlog tool` (-> syslog) To fix: add an additional pgrep check: ``` # 3) try the pgrep way (note: old pgreps do not support '-c') if (( _RC > 0 )) then (( $(pgrep -u postfix pickup 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1 fi ```
patrick added the buglinux labels 2020-05-09 10:08:24 +02:00
patrick self-assigned this 2020-05-09 10:08:24 +02:00
Author
Owner

Fixed in 2020-05-08

Fixed in 2020-05-08
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kudos/check_health#6