add statstest.fish
This commit is contained in:
parent
2066a0ae18
commit
aafd913847
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env fish
|
||||
|
||||
cp "/home/gemini/access.log" "/home/lettuce/code/gemstates/.temp.log"
|
||||
set access_log "/home/lettuce/code/gemstates/.temp.log"
|
||||
|
||||
set day (date +"%d")
|
||||
echo "current day :" $day
|
||||
|
||||
set month (date +"%m")
|
||||
echo "current month:" $month
|
||||
|
||||
set year (date +"%Y")
|
||||
echo "current year:" $year
|
||||
|
||||
if test $month -eq 1
|
||||
# check whether current month is jan
|
||||
set pmonth 12 #set to dec
|
||||
set pyear (math (date +"%Y") - 1) #set to previous year
|
||||
else
|
||||
set pmonth (math $month - 1) #set to prev month
|
||||
set pyear $year
|
||||
end
|
||||
|
||||
echo "previous month:" $pmonth
|
||||
echo "previous month's year" $pyear
|
||||
|
||||
set total_days_prev_month (cal $pmonth $pyear |egrep -v [a-z] |wc -w)
|
||||
echo "# days last month:" $total_days_prev_month
|
||||
|
||||
# loop through days of prev month starting on same day of month
|
||||
for day_counter in (seq $d $total_days_prev_month)
|
||||
set subtotal (grep lettuce $access_log | grep (date --date=$pyear-$pmonth-$day_counter) | wc -l)
|
||||
end
|
||||
|
||||
echo "subtotal: " $subtotal
|
||||
|
||||
# loop through days of current month
|
||||
set subtotal2 (grep lettuce $access_log | grep (date +"%m") | wc -l)
|
||||
|
||||
echo "grand total past month: " (math $subtotal + $subtotal2)
|
||||
|
||||
rm $access_log
|
Loading…
Reference in New Issue