Skip to content

Commit

Permalink
New Feature: History Length
Browse files Browse the repository at this point in the history
This will allow activityLog to run forever without piling up
unsustainable amounts of snapshot logs. History length
will be enabled by a parameter at invocation time and
its value will indicate how many days back the snapshot
history shall extend.

TODO: Write the remainder of implementation for History Length
  • Loading branch information
Node0 committed Nov 1, 2015
1 parent 957c14a commit aff5faa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions BASH/activityLog/activityLog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,14 @@ function processParams {
# Note: Regexes structured with regard for parameter-case
# in order to ensure smooth interchangability between grep and sed
# without regard to version (of sed) or system. Per-tool case
# sensitivity flags 'may' have otherwise resulted in more brittle code.

epochParam="\-\-[eE][pP][oO][cC][hH]";
mysqlParam="\-\-[sS][aA][mM][pP][lL][eE]\-[mM][yY][sS][qQ][lL]";
fsRwRoParam="\-\-[sS][hH][oO][wW][rR][oO][oO][tT][fF][sS][sS][tT][aA][tT][eE]"
# sensitivity flags may have otherwise resulted in more brittle code.

helpShort="\-[hH]";
helpLong="\-\-[Hh][Ee][Ll][Pp]";
epochParam="\-\-[Ee][Pp][Oo][Cc][Hh]";
mysqlParam="\-\-[Ss][Aa][Mm][Pp][Ll][Ee]\-[Mm][Yy][Ss][Qq][Ll]";
fsRwRoParam="\-\-[Ss][Hh][Oo][Ww][Rr][Oo][Oo][Tt][Ff][Ss][Ss][Tt][Aa][Tt][Ee]";
historyLength="\-\-[Hh][Ii][Ss][Tt][Oo][Rr][Yy]\-[Ll][Ee][Gg][Nn][Tt][Hh]\=";
ipAddrRgx="\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b";

# Out of order parameter processing loop (script may be invoked with params given in any order)
Expand All @@ -100,6 +103,13 @@ function processParams {
# In general: Detect presence of parameter i.e. ( $(echo ${param} | grep -Po) != "" )
# then handle the particulars using sed for access if the param is a key:value pair.

# Handle activityLog history length
if [[ "$(echo "${param}" |command grep -Po '('${historyLength}')' )" != "" ]]; then
histLength=$(echo "${param}" |command sed -r "s~(${historyLength})~~g");
finiteHistory=1;
fi


# Handle Filename epoch prefix parameter check
if [[ "$(echo "${param}" |command grep -Po '('${epochParam}')')" != "" ]]; then
filenameEpochPrefix=1;
Expand Down

0 comments on commit aff5faa

Please sign in to comment.