Last active
February 28, 2024 16:33
-
-
Save phette23/ad81419c5839400fa36ee19000718e04 to your computer and use it in GitHub Desktop.
download all EQUELLA logs from a specified day on both app nodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fish | |
# usage: vlog [date string] e.g. `vlog yesterday` or just `vlog` (for today's logs) | |
# requires SSH aliases for both app nodes (v1 & v2) | |
set today (gdate "+%Y-%m-%d") | |
if test -n "$argv[1]" | |
# need to use gnu date to get the human readable --date parameter | |
set d (gdate --date="$argv[1]" "+%Y-%m-%d") | |
# there can be multiple logs per day, rsync does this in only 1 ssh connection (requires rsync 3+) | |
rsync -ruzvhP v1:/opt/equella/logs/resource-centre/$d/ :/opt/equella/logs/tomcat/$d/ v1-$d | |
rsync -ruzvhP v2:/opt/equella/logs/resource-centre/$d/ :/opt/equella/logs/tomcat/$d/ v2-$d | |
else | |
set d $today | |
rsync -ruzvhP --exclude='*/' v1:/opt/equella/logs/resource-centre/ :/opt/equella/logs/tomcat/ v1-$d | |
rsync -ruzvhP --exclude='*/' v2:/opt/equella/logs/resource-centre/ :/opt/equella/logs/tomcat/ v2-$d | |
end | |
echo "Downloading logs for $d" | |
# rename files & move out of subfolders | |
# some older app logs end in .html even though they are .log files | |
for file in v1-$d/application* | |
mv $file (string replace application $d-v1-app (string replace html log $file)) | |
end | |
for file in v1-$d/tomcat* | |
mv $file (string replace tomcat $d-v1-tomcat $file) | |
end | |
for file in v2-$d/application* | |
mv $file (string replace application $d-v2-app (string replace html log $file)) | |
end | |
for file in v2-$d/tomcat* | |
mv $file (string replace tomcat $d-v2-tomcat $file) | |
end | |
mv v*-$d/* . | |
rmdir v1-$d v2-$d | |
# remove the Hibernate API deprecation warnings that fill up the logs | |
if command -q gsed | |
gsed -i -e '/Hibernate\'s legacy org.hibernate.Criteria API/d' *.log | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment