#!/bin/csh -f
###################################
# Look through the recent WWW access logs from the cismm.org machine to find who accessed the
# Microscope Simulator download page.  These logs need to have been copied to
# ~taylorr/tmp/cismm.org_logs
###################################

cd /afs/cs.unc.edu/project/cismm/web_logs
rm ~/tmp/cismm_scopesim_total_list

foreach p (`ls *access_log-*`)
	rm ~/tmp/cismm_scopesim_list
    #cat $p | grep -E 'GET .*MicroscopeSimulator|GET .*microscope_simulator' | grep -v 152.2. | tee ~/tmp/cismm_scopesim_list
    cat $p | grep -E 'MicroscopeSimulator|microscope_simulator' | tee ~/tmp/cismm_scopesim_list
	#gunzip < $p | grep 'cismm/download/afmsimulator/microscope_simulator' | grep -v 152.2. | tee ~/tmp/cismm_scopesim_list
	#gunzip < $p | grep '/wp-content/downloads/microscope_simulator' | grep -v 152.2. | tee -a ~/tmp/cismm_scopesim_list
	#gunzip < $p | grep -E '/wp-content/downloads/MicroscopeSimulator.*.exe|/wp-content/downloads/MicroscopeSimulator.*.dmg' | grep -v 152.2. | tee -a ~/tmp/cismm_scopesim_list
	# gunzip < $p | grep 'download/28' | grep -v 152.2. | tee -a ~/tmp/cismm_scopesim_list
	# gunzip < $p | grep 'download/29' | grep -v 152.2. | tee -a ~/tmp/cismm_scopesim_list
	# gunzip < $p | grep 'download/12' | grep -v 152.2. | tee -a ~/tmp/cismm_scopesim_list
	# gunzip < $p | grep 'download/25' | grep -v 152.2. | tee -a ~/tmp/cismm_scopesim_list
	# gunzip < $p | grep 'download/26' | grep -v 152.2. | tee -a ~/tmp/cismm_scopesim_list
	cat ~/tmp/cismm_scopesim_list >>! ~/tmp/cismm_scopesim_total_list
end

echo "Total number of unique off-site hits:"
cut -f1 -d" " ~/tmp/cismm_scopesim_total_list | sort | uniq | wc

echo "Total number of weeks:"
ls access_log* | wc

echo "Months covered:"
cut -f2 -d"/" ~/tmp/cismm_scopesim_total_list | sort | uniq

