"Fossies" - the Fresh Open Source Software Archive

Member "mosshe/functions.dovecot" (9 Sep 2020, 4316 Bytes) of package /linux/privat/old/mosshe.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    4 #
    5 #   function library - please call with external script
    6 #
    7 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    8 
    9 #############################################################################
   10 # MoSSHe: remote server monitoring environment
   11 #
   12 # Copyright (C) 2013- Volker Tanger
   13 #
   14 # This program is free software; you can redistribute it and/or
   15 # modify it under the terms of the GNU General Public License
   16 # as published by the Free Software Foundation; either version 2
   17 # of the License, or (at your option) any later version.
   18 #
   19 # For bug reports and suggestions or if you just want to talk to me please
   20 # contact me at volker.tanger@wyae.de
   21 #
   22 # Updates will be available at  http://www.wyae.de/software/mosshe/
   23 # please check there for updates prior to submitting patches!
   24 #
   25 # For list of changes please refer to the HISTORY file. Thanks.
   26 #############################################################################
   27 
   28 
   29 
   30 #############################################################################
   31 # Dovecot checks - functions below
   32 #############################################################################
   33 
   34 
   35 #---------------------------------------------------------
   36 # DovecotStored - WARN ALERT
   37 #---------------------------------------------------------
   38 DovecotStored () {
   39     MossheLog "DovecotStored $1 $2"
   40     typeset -i ALERT WARN VALUE  RTN
   41     WARN=$1
   42     ALERT=$2
   43     if [ -n "$(which journalctl)" ]; then
   44     VALUE=`journalctl --since "5 minute ago" -u dovecot | fgrep lmtp | fgrep ' saved mail to ' | wc -l`
   45     if [ "$VALUE" -gt "$ALERT" ]; then 
   46         STATUS="ALERT"
   47         MESSAGE="Excessive stored mails for Dovecot $MYGROUP: $MYNAME "
   48     elif [ "$VALUE" -gt "$WARN" ]; then 
   49         STATUS="WARN"
   50         MESSAGE="High number of stored mails for Dovecot $MYGROUP: $MYNAME "
   51     else
   52         STATUS="OK"
   53         MESSAGE="Normal number of stored mail by Dovecot $MYGROUP: $MYNAME "
   54     fi
   55     echo "${DATIM};$MYGROUP;$MYNAME;DovecotStored;$STATUS;$VALUE;$MESSAGE" >> $TEMPDIR/tmp.$$.collected.tmp
   56     else
   57         echo "${DATIM};$MYGROUP;$MYNAME;DovecotStored;-5;not a SYSTEMD system" >> $TEMPDIR/tmp.$$.collected.tmp             
   58     fi
   59 }
   60 
   61 #---------------------------------------------------------
   62 # DovecotSieved - WARN ALERT
   63 #---------------------------------------------------------
   64 DovecotSieved () {
   65     MossheLog "DovecotSieved $1 $2"
   66     typeset -i ALERT WARN VALUE  RTN
   67     WARN=$1
   68     ALERT=$2
   69     if [ -n "$(which journalctl)" ]; then
   70     VALUE=`journalctl --since "5 minute ago" -u dovecot | fgrep lmtp | fgrep ' sieve: ' | wc -l`
   71     if [ "$VALUE" -gt "$ALERT" ]; then 
   72         STATUS="ALERT"
   73         MESSAGE="Excessive mails sieved for Dovecot $MYGROUP: $MYNAME "
   74     elif [ "$VALUE" -gt "$WARN" ]; then 
   75         STATUS="WARN"
   76         MESSAGE="High number of sieved mails for Dovecot $MYGROUP: $MYNAME "
   77     else
   78         STATUS="OK"
   79         MESSAGE="Normal number of sieved mail by Dovecot $MYGROUP: $MYNAME "
   80     fi
   81     echo "${DATIM};$MYGROUP;$MYNAME;DovecotSieved;$STATUS;$VALUE;$MESSAGE" >> $TEMPDIR/tmp.$$.collected.tmp
   82     else
   83         echo "${DATIM};$MYGROUP;$MYNAME;DovecotSieved;-5;not a SYSTEMD system" >> $TEMPDIR/tmp.$$.collected.tmp             
   84     fi
   85 }
   86 
   87 
   88 #---------------------------------------------------------
   89 # DovecotLoginFailed - WARN ALERT
   90 #---------------------------------------------------------
   91 DovecotLoginFailed () {
   92     MossheLog "DovecotLoginFailed $1 $2"
   93     typeset -i ALERT WARN VALUE  RTN
   94     WARN=$1
   95     ALERT=$2
   96     if [ -n "$(which journalctl)" ]; then
   97     VALUE=`journalctl --since "5 minute ago" -u dovecot | fgrep ' imap-login: Disconnected (auth failed, ' | wc -l`
   98     if [ "$VALUE" -gt "$ALERT" ]; then 
   99         STATUS="ALERT"
  100         MESSAGE="Excessive failed logins for Dovecot $MYGROUP: $MYNAME "
  101     elif [ "$VALUE" -gt "$WARN" ]; then 
  102         STATUS="WARN"
  103         MESSAGE="High number of failed logins for Dovecot $MYGROUP: $MYNAME "
  104     else
  105         STATUS="OK"
  106         MESSAGE="Normal number failed logins by Dovecot $MYGROUP: $MYNAME "
  107     fi
  108     echo "${DATIM};$MYGROUP;$MYNAME;DovecotLoginFailed;$STATUS;$VALUE;$MESSAGE" >> $TEMPDIR/tmp.$$.collected.tmp
  109     else
  110         echo "${DATIM};$MYGROUP;$MYNAME;DovecotLoginFailed;-5;not a SYSTEMD system" >> $TEMPDIR/tmp.$$.collected.tmp                
  111     fi
  112 }
  113 
  114 
  115 
  116 #############################################################################