Mobile app version of vmapp.org
Login or Join
Frith620

: Apache log analytic's Been trying for a while to get this script fully working I think I'm nearly there. Ok so I basically need the script to show 3 things, email address - Browser type

@Frith620

Posted in: #Apache #ApacheLogFiles #Filenames #LookingForAScript #ServerSideScripting

Been trying for a while to get this script fully working I think I'm nearly there.

Ok so I basically need the script to show 3 things, email address - Browser type - Time logged in.

EMAILS='/home/user/emaillist.txt'
MAIL=$EMAILS
while read MAIL;
do
grep -f $EMAILS /var/log/apache2/ssl_access.log>>/home/user/test.txt
done < $EMAILS


I need some way of first using the todays date in here so it only searches the apache logs for that data. I was thinking about using the linux date +"[%d/%b/%Y" command in the script as this will match the correct date formate.

The other aspect is that I only need the output to show the user's email address | Browser type and date from apache nothing else.

HELP please

UPDATE

Managed to play around with the script and got it to this stage where it works fine I just need to work out how to add browser data into the text file?

x=$(date +"%d/%b/%Y")
y=$(date +"%d%b%Y")
filename=emaillist.txt
while read filename
do
if COUNT=$(grep $filename /var/log/apache2/ssl_access.log |grep -c $x)
then
echo $filename:$COUNT>>/home/user/logs/usage"$y".txt
fi
done < emaillist.txt

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Frith620

1 Comments

Sorted by latest first Latest Oldest Best

 

@Goswami781

If you put

grep $filename /var/log/apache2/ssl_access.log |grep $x | awk -F" '{print }' | sort -u >> /home/user/logs/usage"$y".txt


before the fi that should put the browser information into the text file (and remove duplicate lines where they are the same) after the line with the count on it.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme