All pastes #275318 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-12-11 12:50 UTC
rendered paste body
#!/bin/bash

## Script for reading some stats
##
## (c) by rastii
##

#### Config Section

glroot="/glftpd"
gllog="$glroot/ftp-data/logs/glftpd.log"
date=`date "+%a %b %d"`
date1=`date "+%a %b %e"`
#date="Sun Nov 12"

newdir_tmp_file="$glroot/tmp/day.newdir"
users_tmp_file="$glroot/tmp/day.newdir.users"

pre_tmp_file="$glroot/tmp/day.pre"

prefix=".:fb \002stats\002:."
b="^B"


#### Code Section

# Newdirs

tac $gllog | grep "$date1" | grep NEWDIR: > $newdir_tmp_file

cat $newdir_tmp_file | cut -d ' ' -f8 | sort | uniq -c | sort -n -r > $users_tmp_file

new_dirs=`cat $users_tmp_file | head -n 1 | tr -d ' ' | cut -d '"' -f1`
new_dirs_user=`cat $users_tmp_file | head -n 1 | tr -d ' ' | cut -d '"' -f2`

###########

# PREs

tac $gllog | grep "$date" | grep PRE: > $pre_tmp_file

pres=`cat $pre_tmp_file | wc -l`

grp_most_pre_nr=`cat $pre_tmp_file | cut -d ' ' -f8 | sort | uniq -c | sort -nr | tr -d ' ' | head -n 1 | cut -d '"' -f1`
grp_most_pre=`cat $pre_tmp_file | cut -d ' ' -f8 | sort | uniq -c | sort -nr | tr -d ' ' | head -n 1 | cut -d '"' -f2`

###########

# Output

echo -e "$prefix at the end of this day .: $b$date$b :. we have some stats for ya"
echo -e "$prefix most newdirs $b$new_dirs$b were made by $b$new_dirs_user$b"
if [ "$pres" -eq "0" ]
then
echo -e "$prefix there were no pres today"
else
echo -e "$prefix we had $b$pres$b pre(s) on the site - most pre(s) done by $b$grp_most_pre$b with $b$grp_most_pre_nr$b pre(s)"
fi