Skip to content
Snippets Groups Projects
Commit 6858595e authored by Matthew K Defenderfer's avatar Matthew K Defenderfer
Browse files

add an output directory option. set the default output directory to be in the...

add an output directory option. set the default output directory to be in the same location as the log
parent 48b51c10
No related branches found
No related tags found
2 merge requests!15Update main to v0.1.1,!14Set default location for split-file-info output
...@@ -11,6 +11,7 @@ mem="16G" ...@@ -11,6 +11,7 @@ mem="16G"
time="12:00:00" time="12:00:00"
partition="amd-hdr100" partition="amd-hdr100"
lines=5000000 lines=5000000
outdir=""
############################################################ ############################################################
# Help # # Help #
...@@ -18,8 +19,9 @@ lines=5000000 ...@@ -18,8 +19,9 @@ lines=5000000
usage() usage()
{ {
>&2 cat << EOF >&2 cat << EOF
Usage: $0 [ -h ] [ -n | --ntasks ] [ -p | --partition] [ -t | --time ] [ -m | --mem ] Usage: $0 [ -h ] [ -l | --lines ] [ -o | --outdir ]
[ -l | --lines ] log [ -n | --ntasks ] [ -p | --partition] [ -t | --time ] [ -m | --mem ]
log
EOF EOF
} }
...@@ -28,8 +30,9 @@ help() ...@@ -28,8 +30,9 @@ help()
# Display Help # Display Help
>&2 cat << EOF >&2 cat << EOF
Splits a GPFS policy log into multiple parts for batch array processing Splits a GPFS policy log into multiple parts for batch array processing
Usage: $0 [ -h ] [ -n | --ntasks ] [ -p | --partition ] [ -t | --time ] [ -m | --mem ] Usage: $0 [ -h ] [ -l | --lines ] [ -o | --outdir ]
[ -l | --lines ] log [ -n | --ntasks ] [ -p | --partition] [ -t | --time ] [ -m | --mem ]
log
General: General:
-h|--help Print this Help. -h|--help Print this Help.
...@@ -37,9 +40,12 @@ General: ...@@ -37,9 +40,12 @@ General:
Required: Required:
log Path to the log file to split log Path to the log file to split
File Partitioning: Split Parameters:
-l|--lines Max number of records to save in each split (default: 5000000) -l|--lines Max number of records to save in each split (default: 5000000)
File Parameters:
-o|--outdir Directory path to store split files in. Defaults to ${log}.d in ${log}'s parent directory.
Job Parameters: Job Parameters:
-n|--ntasks Number of job tasks (default: 4) -n|--ntasks Number of job tasks (default: 4)
-p|--partition Partition to submit tasks to (default: amd-hdr100) -p|--partition Partition to submit tasks to (default: amd-hdr100)
...@@ -49,7 +55,7 @@ EOF ...@@ -49,7 +55,7 @@ EOF
exit 0 exit 0
} }
args=$(getopt -a -o hn:p:t:m:l: --long help,ntasks:,partition:,time:,mem:,lines: -- "$@") args=$(getopt -a -o hl:o:n:p:t:m: --long help,lines:,outdir:,ntasks:,partition:,time:,mem: -- "$@")
if [[ $? -gt 0 ]]; then if [[ $? -gt 0 ]]; then
usage usage
fi fi
...@@ -60,11 +66,12 @@ while : ...@@ -60,11 +66,12 @@ while :
do do
case $1 in case $1 in
-h | --help) help ;; -h | --help) help ;;
-l | --lines) lines=$2 ; shift 2 ;;
-o | --outdir) outdir=$2 ; shift 2 ;;
-n | --ntasks) ntasks=$2 ; shift 2 ;; -n | --ntasks) ntasks=$2 ; shift 2 ;;
-p | --partition) partition=$2 ; shift 2 ;; -p | --partition) partition=$2 ; shift 2 ;;
-t | --time) time=$2 ; shift 2 ;; -t | --time) time=$2 ; shift 2 ;;
-m | --mem) mem=$2 ; shift 2 ;; -m | --mem) mem=$2 ; shift 2 ;;
-l | --lines) lines=$2 ; shift 2 ;;
--) shift; break ;; --) shift; break ;;
*) >&2 echo Unsupported option: $1 *) >&2 echo Unsupported option: $1
usage ;; usage ;;
...@@ -76,8 +83,17 @@ if [[ $# -eq 0 ]]; then ...@@ -76,8 +83,17 @@ if [[ $# -eq 0 ]]; then
fi fi
log=$1 log=$1
dirname="$(basename ${log} .gz).d"
prefix=${dirname}/list- if [[ -z "${log}" ]]; then
echo "Log path is required"
usage
fi
if [[ -z "${outdir}" ]]; then
outdir="$(readlink -f ${log}).d"
fi
prefix=${outdir}/list-
split_cmd="cat ${log} | split -a 3 -d -l ${lines} - ${prefix}" split_cmd="cat ${log} | split -a 3 -d -l ${lines} - ${prefix}"
zip_cmd="ls ${prefix}* | xargs -i -P 0 bash -c 'gzip {} && echo {} done'" zip_cmd="ls ${prefix}* | xargs -i -P 0 bash -c 'gzip {} && echo {} done'"
...@@ -89,6 +105,7 @@ fi ...@@ -89,6 +105,7 @@ fi
>&2 cat << EOF >&2 cat << EOF
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
GPFS log: ${log} GPFS log: ${log}
Output Directory $(outdir)
Lines per File: ${lines} Lines per File: ${lines}
ntasks: ${ntasks} ntasks: ${ntasks}
...@@ -101,7 +118,7 @@ zip cmd: ${zip_cmd} ...@@ -101,7 +118,7 @@ zip cmd: ${zip_cmd}
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
EOF EOF
mkdir -p ${dirname} mkdir -p ${outdir}
mkdir -p out mkdir -p out
mkdir -p err mkdir -p err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment