From 69fc7ac9cd232629601d64a28d1fa358ebae19a7 Mon Sep 17 00:00:00 2001 From: deajan Date: Thu, 10 Mar 2016 10:26:26 +0100 Subject: [PATCH] Reduced log level for 3rdparty pings --- dev/debug_obackup.sh | 13 +++++++++---- dev/ofunctions.sh | 13 +++++++++---- obackup.sh | 13 +++++++++---- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/dev/debug_obackup.sh b/dev/debug_obackup.sh index d99145b..cc5ee53 100755 --- a/dev/debug_obackup.sh +++ b/dev/debug_obackup.sh @@ -8,7 +8,7 @@ PROGRAM_VERSION=2.0-pre PROGRAM_BUILD=2016030302 IS_STABLE=no -## FUNC_BUILD=2016030401 +## FUNC_BUILD=2016031001 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -154,6 +154,7 @@ function KillChilds { if [ "$self" == true ]; then kill -s SIGTERM "$pid" || (sleep 30 && kill -9 "$pid" &) fi + # sleep 30 needs to wait before killing itself } function SendAlert { @@ -162,6 +163,10 @@ function SendAlert { local mail_no_attachment= local attachment_command= + if [ "$DESTINATION_MAILS" == "" ]; then + return 0 + fi + if [ "$_DEBUG" == "yes" ]; then Logger "Debug mode, no warning email will be sent." "NOTICE" return 0 @@ -556,7 +561,7 @@ function WaitForCompletion { SendAlert fi if [ $SECONDS -gt $hard_max_time ] && [ $hard_max_time != 0 ]; then - Logger "Max hard execution time exceeded for script. Stopping current task execution." "ERROR" + Logger "Max hard execution time exceeded for script in [$caller_name]. Stopping current task execution." "ERROR" kill -s SIGTERM $pid if [ $? == 0 ]; then Logger "Task stopped succesfully" "NOTICE" @@ -698,14 +703,14 @@ function CheckConnectivity3rdPartyHosts { eval "$PING_CMD $i > /dev/null 2>&1" & WaitForTaskCompletion $! 360 360 ${FUNCNAME[0]} if [ $? != 0 ]; then - Logger "Cannot ping 3rd party host $i" "WARN" + Logger "Cannot ping 3rd party host $i" "NOTICE" else remote_3rd_party_success=1 fi done IFS=$OLD_IFS if [ $remote_3rd_party_success -ne 1 ]; then - Logger "No remote 3rd party host responded to ping. No internet ?" "CRITICAL" + Logger "No remote 3rd party host responded to ping. No internet ?" "ERROR" return 1 fi fi diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 3fb8cca..a29a678 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -1,4 +1,4 @@ -## FUNC_BUILD=2016030401 +## FUNC_BUILD=2016031001 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -144,6 +144,7 @@ function KillChilds { if [ "$self" == true ]; then kill -s SIGTERM "$pid" || (sleep 30 && kill -9 "$pid" &) fi + # sleep 30 needs to wait before killing itself } function SendAlert { @@ -152,6 +153,10 @@ function SendAlert { local mail_no_attachment= local attachment_command= + if [ "$DESTINATION_MAILS" == "" ]; then + return 0 + fi + if [ "$_DEBUG" == "yes" ]; then Logger "Debug mode, no warning email will be sent." "NOTICE" return 0 @@ -546,7 +551,7 @@ function WaitForCompletion { SendAlert fi if [ $SECONDS -gt $hard_max_time ] && [ $hard_max_time != 0 ]; then - Logger "Max hard execution time exceeded for script. Stopping current task execution." "ERROR" + Logger "Max hard execution time exceeded for script in [$caller_name]. Stopping current task execution." "ERROR" kill -s SIGTERM $pid if [ $? == 0 ]; then Logger "Task stopped succesfully" "NOTICE" @@ -688,14 +693,14 @@ function CheckConnectivity3rdPartyHosts { eval "$PING_CMD $i > /dev/null 2>&1" & WaitForTaskCompletion $! 360 360 ${FUNCNAME[0]} if [ $? != 0 ]; then - Logger "Cannot ping 3rd party host $i" "WARN" + Logger "Cannot ping 3rd party host $i" "NOTICE" else remote_3rd_party_success=1 fi done IFS=$OLD_IFS if [ $remote_3rd_party_success -ne 1 ]; then - Logger "No remote 3rd party host responded to ping. No internet ?" "CRITICAL" + Logger "No remote 3rd party host responded to ping. No internet ?" "ERROR" return 1 fi fi diff --git a/obackup.sh b/obackup.sh index 0d2f425..621f7ad 100755 --- a/obackup.sh +++ b/obackup.sh @@ -8,7 +8,7 @@ PROGRAM_VERSION=2.0-pre PROGRAM_BUILD=2016030302 IS_STABLE=no -## FUNC_BUILD=2016030401 +## FUNC_BUILD=2016031001 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -144,6 +144,7 @@ function KillChilds { if [ "$self" == true ]; then kill -s SIGTERM "$pid" || (sleep 30 && kill -9 "$pid" &) fi + # sleep 30 needs to wait before killing itself } function SendAlert { @@ -151,6 +152,10 @@ function SendAlert { local mail_no_attachment= local attachment_command= + if [ "$DESTINATION_MAILS" == "" ]; then + return 0 + fi + if [ "$_DEBUG" == "yes" ]; then Logger "Debug mode, no warning email will be sent." "NOTICE" return 0 @@ -536,7 +541,7 @@ function WaitForCompletion { SendAlert fi if [ $SECONDS -gt $hard_max_time ] && [ $hard_max_time != 0 ]; then - Logger "Max hard execution time exceeded for script. Stopping current task execution." "ERROR" + Logger "Max hard execution time exceeded for script in [$caller_name]. Stopping current task execution." "ERROR" kill -s SIGTERM $pid if [ $? == 0 ]; then Logger "Task stopped succesfully" "NOTICE" @@ -671,14 +676,14 @@ function CheckConnectivity3rdPartyHosts { eval "$PING_CMD $i > /dev/null 2>&1" & WaitForTaskCompletion $! 360 360 ${FUNCNAME[0]} if [ $? != 0 ]; then - Logger "Cannot ping 3rd party host $i" "WARN" + Logger "Cannot ping 3rd party host $i" "NOTICE" else remote_3rd_party_success=1 fi done IFS=$OLD_IFS if [ $remote_3rd_party_success -ne 1 ]; then - Logger "No remote 3rd party host responded to ping. No internet ?" "CRITICAL" + Logger "No remote 3rd party host responded to ping. No internet ?" "ERROR" return 1 fi fi