Right now manually extracting the log files from the baby-fleming-nodes dir structure is a proper PITA.
I’m failing to put a script together to scan the contents of $HOME/.safe/node/baby-fleming-nodes/ and copy all the log files to a set of timestamped directories and then tar that up so the devs can look harder.
I traverse baby-fleming-nodes/ looking for sn_node.log* and copy those logs into the correct sub-dir in $HOME/saved-logs but I am screwing up with cut at line 30. There must be a better way to do this and treat the output of $d as a string rather than a path so I can append the correct node number and store the log correctly
#! /bin/bash
# collect log files from each run of baby-fleming
# we have many files named sn_node.log, so we need to store them in seperate dirs
# finally tar up all the logs from each run
TIMESTAMP=$(/usr/bin/date +%Y%m%d_%H%M)
#Do this outside the loop so the timestamp is consistent even if the time changes while the loop is running
if [[ ! -d $HOME/.safe/node/baby-fleming-nodes ]];
then
echo "Cannot find your baby-fleming nodes"
echo "Are you sure your baby-fleming network is/was running?"
exit 1
fi
cd $HOME/.safe/node/baby-fleming-nodes/
for i in {1..11};
do
mkdir -p $HOME/baby-fleming-logs/$TIMESTAMP/sn_node-$i/
done
mv $HOME/baby-fleming-logs/$TIMESTAMP/sn_node-1 $HOME/baby-fleming-logs/$TIMESTAMP/sn_node-genesis
for d in $HOME/.safe/node/baby-fleming-nodes/*;
do
cd $d
NODE_STRING=$(echo $d)
echo $NODE_STRING
NODE_NO=$(cut -c -40 $NODE_STRING)
echo $NODE_NO
cp -v sn_node.log* $HOME/baby-fleming-logs/$TIMESTAMP/$NODE_NO/
cd ..
done
tree $HOME/baby-fleming-logs
#TODO compress the saved logs
tar -cvf $HOME/baby-fleming-logs
I think this is worth putting some effort into as if successful we get a consistent way of delivering logs until ELK gets sorted out. With a script it becomes a LOT easier for others to join in with testing the latest from github and the more eyes on a problem, the sooner bugs will be uncovered etc etc etc
So someone, please do my homework so I can extract all the log files from (say) $HOME/.safe/node/baby-fleming-nodes/sn_node8/ and copy them to $HOME/baby-fleming-logs/$TIMESTAMP/sn_node8/ etc.
Of course maybe I a going about this the wrong way and a different approach is needed. Tell me if Im making it too difficult.
I have been running around like a clown touching ground only briefly here and there. I can confirm that metrics were working on beats but I did not look to see where or if the logs were stored.