On Mon, Aug 20, 2001 at 11:05:13AM +0800, Chang wrote:
> that gives you a total only.
> How did yuo group by date?
> you don't grep each date, do you?  :)
> 
> > you can do with grep, sort, uniq, sed, for loops, cut, and bc. For example:
> > 
> > cat access* | grep XXX | cut -d" " -f1 | sort -u  | grep -c .  
> 
Yes. I do grep each date.
Here is the entire bash script, which used gnuplot
to make a nice graph of the whole thing for each day.
You have to have the right
gnuplot_1 configuration file to make the graph look nice.
The script is invoked like so:
script 2 (or 3 or 4 etc)
This makes the script grep two days prior to today's date. The search
variable in the script makes this possible. This was the tricky part of this
script.
So, you can do like so:
for i in 0 1 2 3 4 5 6 7 8 9 10; do script $i;done
Then, using the pschain script I posted a while back, you can:
pschain `dir -1 Red_X_Aug*.ps | sort  -t"_" +3n`  | psnup -4 > summary.ps
and see graphically the whole month's activity. I have attached one page of
this file, suitable for framing.
Even without the gnuplot stuff, $outfile will show the hourly activity in columar
form. 
Setting this up takes a lot of work, but, once it runs, it goes well.
However, you should be able to run this script against your apache access files after
commenting out the gnuplot stuff (which I have done below) and get the
columnar output without much work.
Joel


#!/bin/bash
cd /var/log/httpd
if [ -z $1 ];then back=0;else back=$1;fi
search=$(date --date " $back days ago " | tr -s " " | cut -d" " -f3)"/"$(date | cut 
-d" " -f2)
outfile=$(date --date " $back days ago " | tr -s " " | cut -d" " -f2,3)
outfile=Red_X_$(echo $outfile | tr -s " " | tr " " "_")
cat access_log* | grep $search | grep XXXX | sed "s/.*2001://p" | cut -d":" -f1 | uniq 
-c > $outfile
# cat redplot | sed "s/junktemp/$outfile/"  > redplot_1
# gnuplot redplot_1
# mutt -s "Ping Data $f3" -a "$outfile.ps" jlh < ping_canned.txt
# gv $outfile.ps             

junk.ps

Reply via email to