Skip to content
Snippets Groups Projects
Verified Commit eec24620 authored by David Hoese's avatar David Hoese
Browse files

Update loggernet_rotate to be faster

parent 14b1e040
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
alias errcho='>&2 echo' alias errcho='>&2 echo'
LOGGERNET_PATH=/opt/CampbellSci/LoggerNet LOGGERNET_PATH=/opt/CampbellSci/LoggerNet
LOGGERNET_DATA=/data/loggernet LOGGERNET_DATA=/data1/incoming/aoss/tower/
#LOGGERNET_DATA=/tmp #LOGGERNET_DATA=/tmp
HEADER_SIZE=0 HEADER_SIZE=0
INPUT_PREFIX="rig_tower" INPUT_PREFIX="rig_tower"
...@@ -53,10 +53,19 @@ EOF ...@@ -53,10 +53,19 @@ EOF
# TODO: if file doesn't exist add the header # TODO: if file doesn't exist add the header
# TODO: Handle output file suffix # TODO: Handle output file suffix
yyyy_jjj_tower_split() { yyyy_jjj_tower_split() {
awk -F"," -v "header_size=$HEADER_SIZE" 'NR>header_size { time_spec=sprintf("%04d 01 %03d 00 00 00", $2, $3); print mktime(time_spec) }' $1 | \ awk_command='
sort | \ NR>header_size {
uniq | \ time_spec = sprintf("%04d 01 %03d 00 00 00", $2, $3);
awk -v "file_prefix=$OUTPUT_PREFIX" -v "file_ext=$OUTPUT_EXT" -v "input_file=$1" '{ file_date=strftime("%Y-%m-%d", $0); jday=strftime("%j", $0); y=strftime("%Y", $0); output_file=sprintf("%s.%s.%s", file_prefix, file_date, file_ext); command=sprintf("grep \"%d,%d\" %s >> %s", y, jday, input_file, output_file); command | getline val; print output_file }'; epoch_seconds = mktime(time_spec);
file_date = strftime("%Y-%m-%d", epoch_seconds);
jday = strftime("%j", epoch_seconds);
y = strftime("%Y", epoch_seconds);
output_file = sprintf("%s.%s.%s", file_prefix, file_date, file_ext);
print $0 >> output_file;
print output_file
}
'
awk -F"," -v "header_size=$HEADER_SIZE" -v "file_prefix=$OUTPUT_PREFIX" -v "file_ext=$OUTPUT_EXT" "$awk_command" $1 | uniq;
} }
oops() { oops() {
......
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