|
From: Aleksey T. <ats...@gm...> - 2017-11-10 01:59:04
|
As a Web application owner, I wanted to graph the number of daily unique
visitors (out of my Apache httpd log) for the last six weeks.
My httpd log goes 5 months back (from July to November 2017) -- here it is
sorted by month:
# cat /var/cfengine/httpd/logs/access_log* | awk '/GET \/api\/user\//
{print $4, $7}'| cut -b2-12,22- | grep -v admin | sort -u | sort
-k2 -t/ -M | awk '{print $1}' | uniq -c | awk 'NR == 1 { print }
END { print }'
1 12/Jul/2017
2 09/Nov/2017
#
I tried the following:
set xdata time
set xtics rotate
set timefmt "%d/%b/%Y"
set format x "%d/%b/%Y"
set autoscale xfixmin
set autoscale xfix
# only show visitors for last 6 weeks (sliding window)
min=system("date -d '6 weeks ago' +%d/%h/%Y")
max=system("date -d 'now' +%d/%h/%Y")
set xrange [ "min" : "max"]
show xrange
plot '-' using 2:1 with lines
which generated:
line 0: illegal day of month
set xdata time
set xrange [ * : * ] noreverse nowriteback # (currently
["01/Jan/2000":"01/Jan/2000"] )
set autoscale xfixmin
set autoscale xfixmax
So then I took out the xrange stuff and instead just added "| tail -42" to
my one-liner:
cat /var/cfengine/httpd/logs/access_log* | awk '/GET \/api\/user\//
{print $4, $7}'| cut -b2-12,22- | grep -v admin | sort -u | sort
-k2 -t/ -M | awk '{print $1}' | uniq -c | tail -42
I can feed THAT into gnuplot and it does what I want, graphs the last six
months only. Yay! So I've solved my graphing needs, but I'd like to
understand the error message. What does 'line 0' mean? There is nothing
wrong with my input... What am I doing wrong with the gnuplot commands?
Love the tool, by the way. So powerful and useful!
Thanks!
Aleksey
|