Commit 04b7f042 by Charlie Root

just made some additional ground. Time for a nap.

Next step is to dive into the when to reset logic
parent 1f0687f9
#!/bin/sh
status=""
monthnow=$(date +%m)
daynow=$(date +%d)
HHMMnow=$(date +%H%M)
exitunknown() {
echo "UNKNOWN - $status"
......@@ -10,16 +14,51 @@ exitunknown() {
monthlogic() {
case "$monthnow" in
02) periodsecs=2419200;;
04 | 06 | 09 | 11) periodsecs=2592000;;
01 | 03 | 05 | 07 | 08 | 10 | 12) periodsecs=2678400;;
esac
dayreset=
}
daylogic() {
# Basic error checking based on length alone
if [ $(expr "${resetdate}" : '.*') -ne 5 ]; then
status="You seem to have an improperly formatted date for reset."
exitunknown
fi
HHMMreset="$(echo "$resetdate" | cut -c2,3,4,5)"
echo $HHMMreset
periodsecs=86400
}
getnextreset() {
}
# GET ARGS
while getopts r:i:w: o
while getopts r:i:w:h o
do case "$o" in
r) resetdate="$OPTARG";;
i) interface="$OPTARG";;
w) warning="$OPTARG";;
[?]) print >&2 " Usage: $0 -r date -i interface [-w warning threshold]" \
h) print >&2 " Usage: $0 -r date -i interface [-w warning threshold]" \
"\n\t$0 -h (shows this message)" \
"\n\n\tdate should be the time you want the counters to reset" \
"\n\tit will use the format <m|d>[DD]HHMM" \
"\n\tit will use the format <m|d>[dd]HHMM" \
"\n\tso if you want to reset at the start of the month use m010000" \
"\n\tor if you want to reset daily at 3:00 AM use d0300" \
"\n\twarning threshold is optional and measured in bytes."
......@@ -31,7 +70,7 @@ shift $OPTIND-1
period="$(echo "$resetdate" | cut -c1)"
case "$period" in
m | M ) monthlogic;;
d | D ) periodsecs=86400;;
d | D ) daylogic;;
* ) status="You didn't specify a valid date"
exitunknown;;
esac
......@@ -43,5 +82,4 @@ if [ $rc -ne 0 ]; then
exitunknown
fi
echo $resetdate
echo $warning
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment