Skip to content

Instantly share code, notes, and snippets.

@samueljon
Created October 20, 2014 22:18
Show Gist options
  • Save samueljon/9c42fe85225d090fe4f5 to your computer and use it in GitHub Desktop.
Save samueljon/9c42fe85225d090fe4f5 to your computer and use it in GitHub Desktop.
Analyzing specific data from the blcg_module
#!/bin/bash
#
# Author: Samúel Jón Gunnarsson <[email protected]>
#
# Access log
echo "Analysing access_log for 2014"
log_path="/var/log/httpd"
grep_pattern="-2014"
#
# Deleted Files:
total_count=0
total_count=$(cat $log_path/access_log |awk '{print $7}'|grep blcg_module_delete|grep access_key|wc -l)
# Archived Access logs
for file in `ls ${log_path}/access_log${grep_pattern}*.gz`
do
#echo "Analysing $file"
sub_count=$(zcat $file |awk '{print $7}'|grep blcg_module_delete|grep access_key|wc -l)
if [ $DEBUG ] ; then
echo "SubCount for $file is $sub_count images deleted"
fi
total_count=$(( $total_count + $sub_count))
sub_count=0
done
echo "Total Count of Deleted files are: $total_count"
#
# Downloaded
total_count=0
total_count=$(cat $log_path/access_log |awk '{print $7}'|grep "download=1"|grep access_key|wc -l)
# Archived Access logs
for file in `ls $log_path/access_log-2014*.gz`
do
sub_count=$(zcat $file |awk '{print $7}'|grep -i "download=1" |grep access_key|wc -l)
if [ $DEBUG ] ; then
echo "SubCount for $file is $sub_count images downloaded"
fi
total_count=$(( $total_count + $sub_count))
sub_count=0
done
echo "Total Count of Downloaded files are: $total_count"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment