Created
August 7, 2019 00:29
-
-
Save GarimaDamani/f28fbf8165bbfe8a216e2aaca0898f41 to your computer and use it in GitHub Desktop.
Shell script to parse particular log file and get the logs based on various patterns of past one minute and write the output to another file
This file contains 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
#!/bin/bash/ | |
FILE_PATH=”/var/opt/scripts/past_1min.log” | |
FETCH_LOG=”/var/opt/jfrog/artifactory/logs/request.log” | |
while true | |
do | |
TIME=$(date — date “-1min” ‘+%Y%m%d%H%M’) | |
sed -n “/^$TIME/,$ p” $FETCH_LOG > $FILE_PATH | |
echo -n “$(grep ‘HTTP/1.1|20.|’ $FILE_PATH | wc -l)” > /var/opt/scripts/parse.out.log | |
echo -n “ $(grep ‘HTTP/1.1|40.|’ $FILE_PATH | wc -l)” >> /var/opt/scripts/parse.out.log | |
echo -n “ $(grep ‘HTTP/1.1|50.|’ $FILE_PATH | wc -l)” >> /var/opt/scripts/parse.out.log | |
echo -n “ $(grep ‘|GET|’ $FILE_PATH | wc -l)” >> /var/opt/scripts/parse.out.log | |
echo -n “ $(grep ‘|PUT|’ $FILE_PATH | wc -l)” >> /var/opt/scripts/parse.out.log | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment