@@ -66,7 +66,7 @@ time_to_seconds() {
6666 || { [ " ${time% h} " -ge 1 ] 2> /dev/null && seconds=$(( ${time% h} * 3600 )) ; } \
6767 || { [ " ${time% d} " -ge 1 ] 2> /dev/null && seconds=$(( ${time% d} * 86400 )) ; }
6868
69- echo $seconds
69+ echo " $seconds "
7070 unset seconds
7171 unset time
7272}
@@ -100,7 +100,7 @@ collect_data() {
100100 until [ " $n " -ge 5 ]; do
101101 /usr/sbin/netjson-monitoring --dump " $MONITORED_INTERFACES " && break
102102
103- [ " $n " -eq 5 ] && log -e -v " Collecting data failed!"
103+ [ " $n " -eq 4 ] && log -e -v " Collecting data failed!"
104104 n=$(( n + 1 ))
105105 sleep 5
106106 done
@@ -181,8 +181,7 @@ send_data() {
181181 if [ -f " $filename " ]; then
182182 data=$( cat " $filename " )
183183 else
184- [ " $VERBOSE_MODE " -eq " 1" ] && logger -s " data file $filename not found." \
185- -p daemon.info
184+ log -i -v " data file $filename not found."
186185 continue
187186 fi
188187 while true ; do
@@ -201,6 +200,7 @@ send_data() {
201200 # send data
202201 response_code=$( $CURL_COMMAND -H " Content-Type: application/json" -d " $data " " $url " )
203202 if [ " $response_code " = " 200" ]; then
203+ success=$(( success + 1 ))
204204 log -i -v " Data sent successfully."
205205 # check if agent was already failing or not to avoid repeating log messages
206206 if [ " $FAILING " -eq " 1" ]; then
@@ -224,9 +224,7 @@ send_data() {
224224 # Controller. We check if openwisp-config agent is running to determine if the device has been
225225 # deleted. If openwisp-config agent is not running, the monitoring agent will also exit.
226226 if ! pgrep -x " openwisp-config" > /dev/null; then
227- logger -s " Giving up and shutting down: the device may have been deleted from OpenWISP Controller" \
228- -t openwisp-monitoring \
229- -p daemon.err
227+ log -e -n " Giving up and shutting down: the device may have been deleted from OpenWISP Controller"
230228 # get process id of the process collecting data
231229 pid=$( pgrep -f " openwisp-monitoring.*--mode collect" )
232230 kill -SIGKILL " $pid "
0 commit comments