#!/bin/bash # ======================================================================== # Copyright (c) 2007-2009 The University of Washington # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ======================================================================== # make shib activity plots case `hostname` in ovid*) ok=1 ;; *) echo "run on ovid" exit 1 ;; esac case `id -n -u` in fox) ok=1 ;; *) echo "run as fox" exit 1 ;; esac cd ~fox/public_html/stats_idp sumdir=/sx00/fox/idp # ----------------------------------- # # compute date some days ago # case `uname` in AIX) function ago { (( hrs=$1*24+2 )) TZ=PST${hrs}PDT date $2 } ;; Linux) function ago { date -d "$1 days ago" $2 } ;; esac function ago_m { ago $1 +'%Y-%m' } function ago_d { ago $1 +'%Y%m%d' } function set_days { START="`ago_d $1`" END="`ago_d 1`" SLOG="`ago_m $1`" ELOG="`ago_m 1`" } # --------------------------------------- color_bg=linen color_fg=black width=600 height=300 # # yesterday plot # set_days 1 LOGS="$sumdir/audit-${SLOG}.log" [[ $SLOG != $ELOG ]] && LOGS="$LOGS $sumdir/audit-${ELOG}.log" ./idp-plot -f $START -t $END \ -bg $color_bg -fg $color_fg \ -ph lastd.jpg \ -phw 600 -phh 300 -pht "Yesterday" \ -sum lastd.sum \ $LOGS # # last7 days plot # set_days 7 LOGS="$sumdir/audit-${SLOG}.log" [[ $SLOG != $ELOG ]] && LOGS="$LOGS $sumdir/audit-${ELOG}.log" ./idp-plot -f $START -t $END \ -bg $color_bg -fg $color_fg \ -pd last7.jpg \ -pdw 600 -pdh 300 -pdt "Last 7 days" \ -sum last7.sum \ $LOGS # # last 30 days # set_days 30 LOGS="$sumdir/audit-${SLOG}.log" [[ $SLOG != $ELOG ]] && LOGS="$LOGS $sumdir/audit-${ELOG}.log" ./idp-plot -f $START -t $END \ -bg $color_bg -fg $color_fg \ -pd last30.jpg \ -pdw 600 -pdh 300 -pdt "Last 30 days" \ -sum last30.sum \ $LOGS # # last 6 months # SY="`ago 1 +'%Y'`" (( SM="`ago 1 +'%m'`" )) (( mc=0 )) LOGS="" while (( mc<6 )) do (( SM < 10 )) && ZM="0$SM" || ZM="$SM" LOGS="$LOGS $sumdir/audit-${SY}-${ZM}.log" (( SM = SM - 1 )) (( SM == 0 )) && { (( SY = SY - 1 )) (( SM = 12 )) } (( mc = mc + 1 )) done ./idp-plot \ -bg $color_bg -fg $color_fg \ -pd last6m.jpg \ -pdw 600 -pdh 300 -pdt "Last 6 months" \ -sum last6m.sum \ $LOGS