From fa470d31c37e93f400da1d6301e34734e463a4a0 Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Wed, 26 May 2021 22:48:49 +0100 Subject: [PATCH 1/6] tidy up logging --- ukmonPostProc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ukmonPostProc.py b/ukmonPostProc.py index 03e121c..603bc0e 100644 --- a/ukmonPostProc.py +++ b/ukmonPostProc.py @@ -71,8 +71,12 @@ def installUkmonFeed(): def rmsExternal(cap_dir, arch_dir, config): # called from RMS to trigger the UKMON specific code - initLogging(config, 'ukmon_') + # clear existing log handlers log = logging.getLogger("logger") + while log.hasHandlers(): + log.removeHandler(log.handlers[0]) + + initLogging(config, 'ukmon_') log.info('ukmon external script started') rebootlockfile = os.path.join(config.data_dir, config.reboot_lock_file) From afe0b2faa4dce40400d24f31e0b28538a0f439a3 Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Sun, 30 May 2021 16:03:25 +0100 Subject: [PATCH 2/6] Added script to collect logfiles --- gatherLogs.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 gatherLogs.sh diff --git a/gatherLogs.sh b/gatherLogs.sh new file mode 100644 index 0000000..8cdbab4 --- /dev/null +++ b/gatherLogs.sh @@ -0,0 +1,19 @@ +#!/bin/bash +cd ~/RMS_data/logs + +# +# Script to gather the logfiles and upload them for debugging & analysis +# +source /home/pi/source/ukmon-pitools/ukmon.ini +sudo cp /var/log/kern.log . +sudo chown pi:pi kern.log +cp /var/log/messages ./messages.log +ZIPFILE=/tmp/${LOCATION}_logs.tgz +tar cvzf $ZIPFILE *.log* +sftp -i $UKMONKEY -q logupload@$UKMONHELPER << EOF +cd logs +progress +put $ZIPFILE +exit +EOF +rm kern.log messages.log $ZIPFILE From f6a6e20581dda60b6197613b2c9b072f96e457c1 Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Sun, 30 May 2021 16:09:53 +0100 Subject: [PATCH 3/6] Adding config and platepar to log collector --- gatherLogs.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gatherLogs.sh b/gatherLogs.sh index 8cdbab4..496386c 100644 --- a/gatherLogs.sh +++ b/gatherLogs.sh @@ -8,12 +8,14 @@ source /home/pi/source/ukmon-pitools/ukmon.ini sudo cp /var/log/kern.log . sudo chown pi:pi kern.log cp /var/log/messages ./messages.log +cp /home/pi/source/RMS/.config ${location}.config +cp /home/pi/source/RMS/platepar_cmn2010.cal ${location}.cal ZIPFILE=/tmp/${LOCATION}_logs.tgz -tar cvzf $ZIPFILE *.log* +tar cvzf $ZIPFILE *.log* ${location}.config ${location}.cal sftp -i $UKMONKEY -q logupload@$UKMONHELPER << EOF cd logs progress put $ZIPFILE exit EOF -rm kern.log messages.log $ZIPFILE +rm kern.log messages.log $ZIPFILE ${location}.config ${location}.cal From 4c922ae905f79518bc681aa6a21314a79b7cbe41 Mon Sep 17 00:00:00 2001 From: RMS Date: Sun, 30 May 2021 15:11:41 +0000 Subject: [PATCH 4/6] making executable --- gatherLogs.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gatherLogs.sh diff --git a/gatherLogs.sh b/gatherLogs.sh old mode 100644 new mode 100755 From 2b9e69cd14c345b76959acb24a6fd8dbb8058ffd Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Sun, 30 May 2021 16:21:27 +0100 Subject: [PATCH 5/6] fixed bug in case --- gatherLogs.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gatherLogs.sh b/gatherLogs.sh index 496386c..73f3e86 100755 --- a/gatherLogs.sh +++ b/gatherLogs.sh @@ -8,14 +8,14 @@ source /home/pi/source/ukmon-pitools/ukmon.ini sudo cp /var/log/kern.log . sudo chown pi:pi kern.log cp /var/log/messages ./messages.log -cp /home/pi/source/RMS/.config ${location}.config -cp /home/pi/source/RMS/platepar_cmn2010.cal ${location}.cal +cp /home/pi/source/RMS/.config ${LOCATION}.config +cp /home/pi/source/RMS/platepar_cmn2010.cal ${LOCATION}.cal ZIPFILE=/tmp/${LOCATION}_logs.tgz -tar cvzf $ZIPFILE *.log* ${location}.config ${location}.cal +tar cvzf $ZIPFILE *.log* ${LOCATION}.config ${LOCATION}.cal sftp -i $UKMONKEY -q logupload@$UKMONHELPER << EOF cd logs progress put $ZIPFILE exit EOF -rm kern.log messages.log $ZIPFILE ${location}.config ${location}.cal +rm kern.log messages.log $ZIPFILE ${LOCATION}.config ${LOCATION}.cal From 203248a6322c8501e4a67d90055fa6f9ef165628 Mon Sep 17 00:00:00 2001 From: Mark McIntyre Date: Sun, 30 May 2021 22:50:33 +0100 Subject: [PATCH 6/6] fix bug in log handler --- ukmonPostProc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ukmonPostProc.py b/ukmonPostProc.py index 603bc0e..f6e7739 100644 --- a/ukmonPostProc.py +++ b/ukmonPostProc.py @@ -73,7 +73,7 @@ def rmsExternal(cap_dir, arch_dir, config): # clear existing log handlers log = logging.getLogger("logger") - while log.hasHandlers(): + while len(log.handlers) > 0: log.removeHandler(log.handlers[0]) initLogging(config, 'ukmon_')