get_number_of_deferred_mailqueue.sh: add support for configuration file.
This commit is contained in:
parent
c1934d5bde
commit
b497e29755
25
conf/get_number_of_deferred_mailqueue.conf.sample
Normal file
25
conf/get_number_of_deferred_mailqueue.conf.sample
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# ----------------------------------------------------
|
||||||
|
# ---
|
||||||
|
# - Parameter Settings for script 'get_number_of_deferred_mailqueue.sh'.
|
||||||
|
# ---
|
||||||
|
# ----------------------------------------------------
|
||||||
|
|
||||||
|
# - notification_addresses
|
||||||
|
# -
|
||||||
|
# - Where to send notifications
|
||||||
|
# -
|
||||||
|
# - Defaults to argus@oopen.de
|
||||||
|
# -
|
||||||
|
#notification_addresses="argus@oopen.de"
|
||||||
|
|
||||||
|
|
||||||
|
# - count_warn
|
||||||
|
# -
|
||||||
|
# - If number of deferred e-mails exceeds give parameter 'count_warn'
|
||||||
|
# - an e-mail will be written to adresse(s) given at parameter
|
||||||
|
# - 'notification_addresses'.
|
||||||
|
# -
|
||||||
|
# - Defaults to 100
|
||||||
|
# -
|
||||||
|
#count_warn=100
|
||||||
|
|
@ -1,9 +1,14 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
declare -i count_warn
|
script_name="$(basename $(realpath $0))"
|
||||||
declare -i count_warn_default=100
|
working_dir="$(dirname $(realpath $0))"
|
||||||
|
|
||||||
notification_addresses="ckubu-adm@oopen.de"
|
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Some variables
|
||||||
|
# ----------
|
||||||
|
|
||||||
host_name=`hostname -f`
|
host_name=`hostname -f`
|
||||||
from_address="postfix@$host_name"
|
from_address="postfix@$host_name"
|
||||||
@ -11,12 +16,37 @@ content_type='Content-Type: text/plain;\n charset="utf-8"'
|
|||||||
|
|
||||||
postfix_queue_dir=/var/spool/postfix
|
postfix_queue_dir=/var/spool/postfix
|
||||||
|
|
||||||
|
declare -i count_warn
|
||||||
|
|
||||||
if [[ $1 =~ ^-?[0-9]+$ ]];then
|
default_notification_addresses="argus@so36.net"
|
||||||
count_warn=$1
|
declare -i default_count_warn=100
|
||||||
else
|
|
||||||
count_warn=$count_warn_default
|
|
||||||
fi
|
# ----------
|
||||||
|
# Base Function(s)
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
info (){
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e " [ \033[32m\033[1mInfo\033[m ]: $*"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
warn (){
|
||||||
|
if $terminal ; then
|
||||||
|
echo ""
|
||||||
|
echo -e " [ \033[33m\033[1mWarn\033[m ] $*"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# - Some checks ..
|
||||||
|
# ----------
|
||||||
|
|
||||||
if [[ -t 1 ]] ; then
|
if [[ -t 1 ]] ; then
|
||||||
terminal=true
|
terminal=true
|
||||||
@ -24,6 +54,31 @@ else
|
|||||||
terminal=false
|
terminal=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
# Read Configurations from $conf_file
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
|
||||||
|
# - Give your default values here
|
||||||
|
# -
|
||||||
|
|
||||||
|
if [[ -f "$conf_file" ]]; then
|
||||||
|
source "$conf_file"
|
||||||
|
else
|
||||||
|
warn "No configuration file '$conf_file' present.\n
|
||||||
|
Loading default values.."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# - Commandline parameter overwrites those given at configuration file
|
||||||
|
# -
|
||||||
|
if [[ $1 =~ ^-?[0-9]+$ ]];then
|
||||||
|
count_warn=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -n "$notification_addresses" ]] || notification_addresses="$default_notification_addresses"
|
||||||
|
[[ -n "$count_warn" ]] || count_warn=$default_count_warn
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## - Get number of "deferred" mails in postfix queue
|
## - Get number of "deferred" mails in postfix queue
|
||||||
@ -84,18 +139,15 @@ if [[ $count -gt $count_warn ]]; then
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
info "$count messages in postfix deferred queue"
|
||||||
|
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo ""
|
echo ""
|
||||||
#echo "*${host_name}* - $(date +"%d.%m.%Y %H:%M h")"
|
echo -e " \033[1mRecipient domain and time (age in minutes)\033[m:"
|
||||||
echo ""
|
|
||||||
echo "[ Info ]: $count messages in postfix deferred queue"
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
echo "Recipient domain and time (age in minutes):"
|
|
||||||
echo "$(qshape deferred)"
|
echo "$(qshape deferred)"
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Sender domain and time (age in minutes):"
|
echo -e " \033[1mSender domain and time (age in minutes)\033[m:"
|
||||||
echo "$(qshape -s deferred)"
|
echo "$(qshape -s deferred)"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user