From 395d66ed8090058137aa5ac3f1758ed602235ead Mon Sep 17 00:00:00 2001 From: Kapil Bansal Date: Sat, 16 Oct 2021 02:27:42 +0530 Subject: [PATCH] [chores] Minor fix --- openwrt-openwisp-monitoring/files/monitoring.agent | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/openwrt-openwisp-monitoring/files/monitoring.agent b/openwrt-openwisp-monitoring/files/monitoring.agent index 5c5b13d..e4eff92 100755 --- a/openwrt-openwisp-monitoring/files/monitoring.agent +++ b/openwrt-openwisp-monitoring/files/monitoring.agent @@ -48,8 +48,7 @@ log() { -w) level=daemon.warn ;; -e) level=daemon.err ;; -*) - echo "Invalid message level : $level" - exit 1 + echoerr "Invalid message level : $level" ;; esac @@ -138,7 +137,7 @@ send_data() { while true; do for file in "$TMP_DIR"/*; do if [ ! -f "$file" ]; then - log -v -i "No data file found to send" + log -i -v "No data file found to send" trap handle_sigusr1 USR1 # SIGUSR1 signal received, interrupt sleep and continue sending data sleep "$INTERVAL" & @@ -171,7 +170,7 @@ send_data() { # check if agent was already passing or not to avoid repeating log messages if [ "$FAILING" -eq "0" ]; then FAILING=1 - log -e -n "Data not sent successfully. Response code is \"$response_code\"." \ + [ "$VERBOSE_MODE" -ne "1" ] && log -e -n "Data not sent successfully. Response code is \"$response_code\"." \ "Run with verbose mode to find more." fi break @@ -182,7 +181,7 @@ send_data() { log -i -v "Data sent successfully" # check if agent was already failing or not to avoid repeating log messages if [ "$FAILING" -eq "1" ]; then - log -i -n "Data sent successfully" + [ "$VERBOSE_MODE" -ne "1" ] && log -i -n "Data sent successfully" FAILING=0 rm -f "$RESPONSE_FILE" fi @@ -253,8 +252,7 @@ main() { shift ;; -*) - echo "Invalid option: $1" - exit 1 + echoerr "Invalid option: $1" ;; *) break ;; esac