{"id":4128,"date":"2021-01-22T17:05:38","date_gmt":"2021-01-22T08:05:38","guid":{"rendered":"\/blog\/?p=4128"},"modified":"2023-09-21T09:26:35","modified_gmt":"2023-09-21T00:26:35","slug":"gate1-%eb%aa%85%eb%a0%b9%ec%96%b4-%eb%a1%9c%ea%b7%b8-%ec%8b%9c%ea%b0%84-%ec%88%98%ec%a0%95","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=4128","title":{"rendered":"[GATE1] \uba85\ub839\uc5b4 \ub85c\uadf8 \uc2dc\uac04 \uc218\uc815"},"content":{"rendered":"\n<pre class=\"wp-block-syntaxhighlighter-code\">#!\/usr\/bin\/perl\n######################################################################\n#\n# gate1_log_correction.pl\n# gate1\uc758 \uc798\ubabb\ub41c \uba85\ub839\uc5b4 \ub85c\uadf8\uc758 \ub0a0\uc9dc\ub97c \uc218\uc815\ud55c\ub2e4.\n#\n# \ub85c\uadf8 \uc608) 1602623392:#:20201014060909-T0690081-192.168.7.113-172.16.7.106-3588.10085354:#:17:#:AAAD:#:T0690081:#:\ud64d\uae38\ub3d9:#:192.168.7.113:#::#:UNPP:#::#:YNCC:#:njuu01:#:172.16.7.106:#:\uc6b4\uc601\uc11c\ubc84:#::#:\uc6b4\uc601\uc11c\ubc84:#:ssh:#:501:#:wassvr\n# \ud30c\uc77c\uba85 \uc608) 20200925-172.16.7.235\n#\n######################################################################\nuse warnings;\nuse strict;\nuse POSIX qw(strftime);\n\n######################################################################\n#\n# \ub85c\uadf8 \uc2dc\uac04\uc758 \uc624\ucc28\ub97c \uba85\uc2dc\ud55c\ub2e4. (\ucd08\ub2e8\uc704)\n#\n######################################################################\nmy $fn_date = \"\";\nmy $ARGC = @ARGV;\nif ($ARGC &lt; 2) {\n    printf(\"Usage: $0 &lt;log file> &lt;output dir> &lt;Correction Value(Second)>\\n\\n\");\n    printf(\"    ex) $0 20201030-192.168.21.235 \/work\/output 10458232\\n\");\n    printf(\"    ex) $0 20201008-192.168.21.235 \/test\/logs 172858\\n\");\n    exit;\n}\n\nmy $output_dir = $ARGV[1];\n#my $time_rate = 10458232;  # SEOUL\n#my $time_rate = 172858 ;   # YEOSU\nmy $time_rate = $ARGV[2];\n\n######################################################################\n#\n# \ub85c\uadf8\uc758 \ud55c\uc904\uc744 \uc77d\uc5b4\uc11c \uc2dc\uac04\uc744 \uc218\uc815\ud55c \ub4a4 \uc218\uc815\ub41c \uac12\uc744 \ubc18\ud658\ud55c\ub2e4.\n#\n######################################################################\nsub conv_date {\n    my $log_str1 = $_[0];\n    my $epoch1 = 0;\n    my $epoch2 = 0;\n    my $date_str1 = \"\";\n    my $date_str2 = \"\";\n    my $regex = qr\/^([0-9]*):#:([0-9]*)-(.*)\/mp;\n\n    if ( $log_str1 =~ \/$regex\/g ) {\n      $epoch1 = $1 + 0;\n      $date_str1 = $2;\n    }\n\n    $epoch2 = $epoch1 + $time_rate;\n    $date_str2 = strftime \"%Y%m%d%H%M%S\", localtime($epoch2);\n    if (length($fn_date) == 0) {\n        $fn_date = strftime \"%Y%m%d\", localtime($epoch2);\n        #printf(\"[DEBUG]***fn_date:%s\\n\", $fn_date);\n    }\n\n    $log_str1 =~ s\/$epoch1\/$epoch2\/;\n    $log_str1 =~ s\/$date_str1\/$date_str2\/;\n\n    #printf(\"[DEBUG]epoch1:%u\\n\", $epoch1);\n    #printf(\"[DEBUG]epoch2:%u\\n\", $epoch2);\n    #printf(\"[DEBUG]date_str2:%s\\n\", $date_str2);\n\n    return($log_str1);\n}\n\n######################################################################\n#\n# \ucd9c\ub825 \ud30c\uc77c\uba85\uc744 \ub9cc\ub4e0\ub2e4.\n#\n######################################################################\nsub get_out_filename {\n    my $str_line1 = $_[0];\n    my $str_line2 = $_[1];\n    my $ret_str = \"\";\n    my $regex = qr\/^([0-9]*)-(.*)\/mp;\n\n    if ( $str_line1 =~ \/$regex\/g ) {\n        $ret_str = $str_line2.\"-\".$2;\n    }\n\n    return($ret_str);\n}\n\nprintf(\"[DEBUG]ARGV[0]:%s\\n\", $ARGV[0]);\nmy $linestr = \"\";\n\n######################################################################\n#\n# \ub85c\uadf8\uc5d0\uc11c \ud55c\uc904\ub9cc \uc77d\uc5b4\uc11c \ucd9c\ub825 \ud30c\uc77c\uba85\uc5d0 \uc0ac\uc6a9\ud560 \ub0a0\uc9dc\ub97c \uc5bb\ub294\ub2e4.\n#\n######################################################################\nopen (IN_FILE, '&lt;', $ARGV[0]) or die \"Failed to open. $!\";\nwhile (&lt;IN_FILE>) {\n    $linestr = $_;\n    chomp($linestr);    # $linestr\uac12\uc774 \uc800\uc7a5\ub418\uc5b4 \uc788\ub294\ub370 \uac70\uae30\uc11c \ub05d\uc758 \uacf5\ubc31\uc744 \uc9c0\uc6cc\uc900\ub2e4.\n    $linestr = &amp;conv_date($linestr);\n    #printf(\"[DEBUG]%s\\n\", $linestr);\n    if (length($fn_date) > 0) {\n        last;\n    }\n}\nclose(IN_FILE) or die \"Failed to close. $!\";\n\n######################################################################\n#\n# \ucd9c\ub825 \ub514\ub809\ud1a0\ub9ac\ub97c \ub9cc\ub4e4\uace0 \ucd9c\ub825 \ud30c\uc77c\uba85\uc744 \uc644\uc131\ud55c\ub2e4.\n#\n######################################################################\nmy $out_file = $output_dir.\"\/\".&amp;get_out_filename($ARGV[0], $fn_date);\nprintf(\"[DEBUG]out_file:%s\\n\", $out_file);\n\n######################################################################\n#\n# \ubcc0\ud658 !!\n#\n######################################################################\nopen (IN_FILE, '&lt;', $ARGV[0]) or die \"Failed to open. $! \";\nopen (OUT_FILE, '>', $out_file) or die \"Failed to open. $! \";\nwhile (&lt;IN_FILE>) {\n    $linestr = $_;\n    chomp($linestr);    # $linestr\uac12\uc774 \uc800\uc7a5\ub418\uc5b4 \uc788\ub294\ub370 \uac70\uae30\uc11c \ub05d\uc758 \uacf5\ubc31\uc744 \uc9c0\uc6cc\uc900\ub2e4.\n    $linestr = &amp;conv_date($linestr);\n    print OUT_FILE \"$linestr\\n\";\n}\nclose(IN_FILE) or die \"Failed to close. $!\";\nclose(OUT_FILE) or die \"Failed to close. $!\";\n\nexit;<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">#!\/bin\/sh\n######################################################################\n#\n# \ub514\ub809\ud1a0\ub9ac \ub0b4 \ubaa8\ub4e0 \ub85c\uadf8\uc5d0 gate1_log_correction.pl \uc2e4\ud589\n# - LOG_DIR \uac12\uc744 \uc218\uc815\ud574\uc11c \uc0ac\uc6a9\n#\n######################################################################\n\nCONVERTER=\"\/gate1_log_correction\/gate1_log_correction.pl\"\n\nfunction FN_LOG_CONV() {\n  rm -rf ${OUTPUT_DIR}\n  mkdir -p ${OUTPUT_DIR}\n  cd ${LOG_DIR}\n  LOG_FILES=`ls -1 *-*`\n  for log_file in ${LOG_FILES}\n  do\n    echo ${CONVERTER} ${log_file} ${OUTPUT_DIR} ${CORR_VAL}\n    ${CONVERTER} ${log_file} ${OUTPUT_DIR} ${CORR_VAL}\n  done\n}\n\nLOG_DIR=\"\/gate1_log_correction\/seoul\"\nOUTPUT_DIR=\"${LOG_DIR}\/output\"\nCORR_VAL=5702400\nFN_LOG_CONV\n\nLOG_DIR=\"\/gate1_log_correction\/yeosu\"\nOUTPUT_DIR=\"${LOG_DIR}\/output\"\nCORR_VAL=172858\nFN_LOG_CONV<\/pre>\n\n\n\n<div class=\"wp-block-file\"><a href=\"\/blog\/wp-content\/uploads\/2021\/03\/gate1_log_correction.pl\">gate1_log_correction.pl<\/a><a href=\"\/blog\/wp-content\/uploads\/2021\/03\/gate1_log_correction.pl\" class=\"wp-block-file__button\" download>\ub2e4\uc6b4\ub85c\ub4dc\ud558\uae30<\/a><\/div>\n\n\n\n<div class=\"wp-block-file\"><a href=\"\/blog\/wp-content\/uploads\/2021\/03\/run_log_conv.sh\">run_log_conv.sh<\/a><a href=\"\/blog\/wp-content\/uploads\/2021\/03\/run_log_conv.sh\" class=\"wp-block-file__button\" download>\ub2e4\uc6b4\ub85c\ub4dc\ud558\uae30<\/a><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[22],"tags":[],"class_list":["post-4128","post","type-post","status-publish","format-standard","hentry","category-development_unix"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4128"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4128\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}