<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>성능 측정 &#8211; 솜삽 블로그</title>
	<atom:link href="https://somsap.somsap.com/tag/%ec%84%b1%eb%8a%a5-%ec%b8%a1%ec%a0%95/feed/" rel="self" type="application/rss+xml" />
	<link>https://somsap.somsap.com</link>
	<description>개발, 업무, 피아노 등등</description>
	<lastBuildDate>Sun, 18 Jan 2026 13:41:52 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.5</generator>

<image>
	<url>https://somsap.somsap.com/wp-content/uploads/sites/6/2025/02/cropped-이미지-1924-2-32x32.png</url>
	<title>성능 측정 &#8211; 솜삽 블로그</title>
	<link>https://somsap.somsap.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">241690237</site>	<item>
		<title>[Shell Script] 다중 원격 서버 로그 분석 자동화 스크립트</title>
		<link>https://somsap.somsap.com/2025/10/21/shell-script-%eb%8b%a4%ec%a4%91-%ec%9b%90%ea%b2%a9-%ec%84%9c%eb%b2%84-%eb%a1%9c%ea%b7%b8-%eb%b6%84%ec%84%9d-%ec%9e%90%eb%8f%99%ed%99%94-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8/</link>
					<comments>https://somsap.somsap.com/2025/10/21/shell-script-%eb%8b%a4%ec%a4%91-%ec%9b%90%ea%b2%a9-%ec%84%9c%eb%b2%84-%eb%a1%9c%ea%b7%b8-%eb%b6%84%ec%84%9d-%ec%9e%90%eb%8f%99%ed%99%94-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8/#respond</comments>
		
		<dc:creator><![CDATA[somsap]]></dc:creator>
		<pubDate>Tue, 21 Oct 2025 06:22:48 +0000</pubDate>
				<category><![CDATA[개발/프로그래밍]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[BPEL]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[로그 분석]]></category>
		<category><![CDATA[리눅스]]></category>
		<category><![CDATA[서버 관리]]></category>
		<category><![CDATA[서버 자동화]]></category>
		<category><![CDATA[성능 측정]]></category>
		<category><![CDATA[셸 스크립트]]></category>
		<guid isPermaLink="false">https://somsap.somsap.com/?p=2035</guid>

					<description><![CDATA[<p>안녕하세요. 오늘은 여러 대의 애플리케이션 서버(AP)에 분산되어 쌓이는 로그를 매번 접속하지 않고, 한 번의 명령으로 취합하여 분석할 수 있는 유용한 셸 스크립트(analLog.sh)를 공유합니다. 이 스크립트는 특히 다수의 서버에서 특정 BPEL 프로세스의 완료 로그를 찾아 실행 시간 통계(최소, 최대, 평균 시간)를 빠르게 확인해야 할 때 매우 유용합니다. 스크립트의 주요 기능 analLog.sh 스크립트는 4대의 지정된 원격 서버(AP1~AP4)에 [&#8230;]</p>
<p>게시물 <a rel="nofollow" href="https://somsap.somsap.com/2025/10/21/shell-script-%eb%8b%a4%ec%a4%91-%ec%9b%90%ea%b2%a9-%ec%84%9c%eb%b2%84-%eb%a1%9c%ea%b7%b8-%eb%b6%84%ec%84%9d-%ec%9e%90%eb%8f%99%ed%99%94-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8/">[Shell Script] 다중 원격 서버 로그 분석 자동화 스크립트</a>이 <a rel="nofollow" href="https://somsap.somsap.com">솜삽 블로그</a>에 처음 등장했습니다.</p>
]]></description>
										<content:encoded><![CDATA[
<p>안녕하세요. 오늘은 여러 대의 애플리케이션 서버(AP)에 분산되어 쌓이는 로그를 매번 접속하지 않고, 한 번의 명령으로 취합하여 분석할 수 있는 유용한 셸 스크립트(<code>analLog.sh</code>)를 공유합니다.</p>



<p>이 스크립트는 특히 다수의 서버에서 특정 BPEL 프로세스의 완료 로그를 찾아 실행 시간 통계(최소, 최대, 평균 시간)를 빠르게 확인해야 할 때 매우 유용합니다.</p>



<h3 class="wp-block-heading">스크립트의 주요 기능</h3>



<p><code>analLog.sh</code> 스크립트는 4대의 지정된 원격 서버(AP1~AP4)에 <code>ssh</code>로 자동 접속하여 다음 작업을 수행합니다.</p>



<ol start="1" class="wp-block-list">
<li><strong>로그 필터링</strong>: 사용자가 지정한 디렉터리(<code>-f</code>)에서 특정 메시지명(<code>-m</code>)을 포함하는 <code>BPEL COMPLETED</code> 로그를 검색합니다.</li>



<li><strong>시간대 지정</strong>: 지정된 날짜(<code>-d</code>)와 시간(<code>-t</code>) 패턴에 일치하는 로그만 추출합니다.</li>



<li><strong>성능 데이터 추출</strong>: 로그에 기록된 <code>Elapsed time = [숫자] miliseconds</code> 패턴을 찾아 실행 시간(숫자) 값만 파싱합니다.</li>



<li><strong>통계 집계</strong>: <code>awk</code>를 사용하여 각 서버별 및 전체 서버의 **총 로그 건수(Count), 최소 시간(Min), 최대 시간(Max), 평균 시간(Avg)**을 밀리초(ms) 단위로 계산합니다.</li>



<li><strong>(선택) 분당/초당 처리량</strong>: <code>-l [분]</code> 옵션을 제공하면, 지정한 시간(분)을 기준으로 분당 및 초당 평균 처리 건수를 함께 계산해 줍니다.</li>
</ol>



<h3 class="wp-block-heading">사용 방법 (Usage)</h3>



<p>스크립트는 <code>getopts</code>를 사용하여 표준 옵션 인자를 받습니다.</p>



<div class="my-codeblock-wrap"><div class="my-codeblock-label">Bash</div><pre><code class="language-bash">Usage: analLog.sh -m &#091;MESSAGE] -d &#091;DATE] -t &#091;TIME] -f &#091;DIRECTORY]
Try 'analLog.sh -help' for more information.
</code></pre></div>



<p><strong>옵션 상세:</strong></p>



<ul class="wp-block-list">
<li><code>-m</code>: 검색할 메시지 이름 (예: <code>AlarmReport.bpel</code>)</li>



<li><code>-d</code>: 검색할 날짜 (예: <code>20/07/02</code>)</li>



<li><code>-t</code>: 검색할 시간 (예: <code>01:17:</code> 또는 <code>01:[0-9][0-9]:</code>)</li>



<li><code>-f</code>: 검색할 원격 서버의 로그 디렉터리 경로 (예: <code>/mesap_log/EEXsvr/20200702</code>)</li>



<li><code>-l</code> (선택 사항): 분석 대상 시간(분). (예: <code>60</code>)</li>
</ul>



<p><strong>실행 예시:</strong></p>



<div class="my-codeblock-wrap"><div class="my-codeblock-label">Bash</div><pre><code class="language-bash">./analLog.sh -m AlarmReport.bpel -d 25/10/21 -t 08:15: -f /mesap_log/EEXsvr/20251021
</code></pre></div>



<h3 class="wp-block-heading">전체 스크립트 코드</h3>



<div class="my-codeblock-wrap"><div class="my-codeblock-label">Bash</div><pre><code class="language-bash">#!/bin/bash

### Created by Ho Seop Lee of Aim System.

### Initialization

usageMsg="Usage: analLog.sh -m &#091;MESSAGE] -d &#091;DATE] -t &#091;TIME] -f &#091;DIRECTORY]
Try 'analLog.sh -help' for more information."

helpMsg='
\t-m\t\tMessage Name\t(ex: -m AlarmReport.bpel)
\t-d\t\tDate\t\t(ex: -d 20/07/02)
\t-t\t\tTime\t\t(ex: -t 01:17: or -t 01:&#091;0-9]&#091;0-9]:)
\t-f\t\tDirectory Path\t(ex: -f /mesap_log/EEXsvr/ or -f /mesap_log/EEXsvr/20200702)
\t-l (Optional)\tMinutes should be analyzed\t(ex: -l 60)
\t-h, -help, -?\tShow Help Info
'

cols=`tput cols`

for((i=0; i&lt;$cols; i++));
do
    line=$line'=';
done

function printLine()
{
    echo $line
}

usage()
{
    echo -e "$usageMsg"
    printLine
    exit 0
}

help()
{
    echo -e "$helpMsg"
    printLine
    exit 0
}

printLine

### Declaration Option Argument

if &#091;&#091; ! $@ =~ ^\-.+ ]]
then
    usage;
fi

while getopts m:d:t:f:l:h? OPT
do
    case $OPT in
        m) msg=$OPTARG;;
        d) date=$OPTARG;;
        t) time=$OPTARG;;
        f) dir=$OPTARG;; # &#091;FIXED] 원본의 'd)'를 'f)'로 수정
        l) howMinute=$OPTARG;;
        h) help;;
        ?) help;;
    esac
done

echo "Arg msg: $msg"
echo "Arg date: $date"
echo "Arg time: $time"
echo "Arg directory: $dir"
echo "Arg howMinute: $howMinute"

### Analyze log from each AP by remote ssh

# &#091;FIXED] AP1의 grep에 '-s' 옵션을 추가하여 다른 AP와 일관성 유지
# echo 'AP1 p7mesfab@172.25.4.17';
ap_summary=`ssh p7mesfab@172.25.4.17 grep "-sE '***** BPEL COMPLETED :: "${msg}"' "${dir}/*"" | grep -P "${date} ${time}" | grep -Po '(?&lt;=Elapsed time = )\w+(?= miliseconds)' | awk 'BEGIN {min=999999;max=1} {if($1&gt;max) {max=$1}; if($1&lt;min) {min=$1}; total+=$1; count+=1} END {if(count&gt;0) {print "AP1 count: "count" min: "min" max: "max" avg: "total/count}}'`

# echo 'AP1 p7mesfab@172.25.4.18';
ap_summary=$ap_summary"\n"`ssh p7mesfab@172.25.4.18 grep "-sE '***** BPEL COMPLETED :: "${msg}"' "${dir}/*"" | grep -P "${date} ${time}" | grep -Po '(?&lt;=Elapsed time = )\w+(?= miliseconds)' | awk 'BEGIN {min=999999;max=1} {if($1&gt;max) {max=$1}; if($1&lt;min) {min=$1}; total+=$1; count+=1} END {if(count&gt;0) {print "AP2 count: "count" min: "min" max: "max" avg: "total/count}}'`

# echo 'AP1 p7mesfab@172.25.4.19';
ap_summary=$ap_summary"\n"`ssh p7mesfab@172.25.4.19 grep "-sE '***** BPEL COMPLETED :: "${msg}"' "${dir}/*"" | grep -P "${date} ${time}" | grep -Po '(?&lt;=Elapsed time = )\w+(?= miliseconds)' | awk 'BEGIN {min=999999;max=1} {if($1&gt;max) {max=$1}; if($1&lt;min) {min=$1}; total+=$1; count+=1} END {if(count&gt;0) {print "AP3 count: "count" min: "min" max: "max" avg: "total/count}}'`

# echo 'AP1 p7mesfab@172.25.4.34';
ap_summary=$ap_summary"\n"`ssh p7mesfab@172.25.4.34 grep "-sE '***** BPEL COMPLETED :: "${msg}"' "${dir}/*"" | grep -P "${date} ${time}" | grep -Po '(?&lt;=Elapsed time = )\w+(?= miliseconds)' | awk 'BEGIN {min=999999;max=1} {if($1&gt;max) {max=$1}; if($1&lt;min) {min=$1}; total+=$1; count+=1} END {if(count&gt;0) {print "AP4 count: "count" min: "min" max: "max" avg: "total/count}}'`

ap_summar=`echo -e $ap_summary | grep "AP"`

### Show Analysis

echo
echo -e "$ap_summar" # &#091;FIXED] 줄바꿈이 적용된 '$ap_summar' 변수로 수정
echo
if &#091; -z $howMinute ]; then
    # &#091;FIXED] "Total Count: " 중복 오타 수정
    echo -e "$ap_summar" | awk 'BEGIN {min=99999;max=0} length($0) &gt; 0 {total+=$3; if($5&lt;min) {min=$5}; if($7&gt;max) {max=$7}; count+=1; avg_sum+=$9} END {print "Total Count: "total", Min(ms): "min", Max(ms): "max", Avg(ms): "avg_sum/count}'
elif &#091; $howMinute -gt 0 ]; then
    echo -e "$ap_summar" | awk -v howMinute=$howMinute 'BEGIN {min=99999;max=0} length($0) &gt; 0 {total+=$3; if($5&lt;min) {min=$5}; if($7&gt;max) {max=$7}; count+=1; avg_sum+=$9} END {print "Total Count: "total", Count/m: "total/howMinute", Count/s: "total/howMinute/60", Min(ms): "min", Max(ms): "max", Avg(ms): "avg_sum/count", Avg(s): "avg_sum/count/1000}'
fi
printLine
exit 0
</code></pre></div>



<h3 class="wp-block-heading">사용 방법 예시</h3>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="615" src="https://somsap.somsap.com/wp-content/uploads/sites/6/2025/10/image-2-1024x615.png" alt="image 2" class="wp-image-2041" title="[Shell Script] 다중 원격 서버 로그 분석 자동화 스크립트 1" srcset="https://somsap.somsap.com/wp-content/uploads/sites/6/2025/10/image-2-1024x615.png 1024w, https://somsap.somsap.com/wp-content/uploads/sites/6/2025/10/image-2-300x180.png 300w, https://somsap.somsap.com/wp-content/uploads/sites/6/2025/10/image-2-768x461.png 768w, https://somsap.somsap.com/wp-content/uploads/sites/6/2025/10/image-2-1536x923.png 1536w, https://somsap.somsap.com/wp-content/uploads/sites/6/2025/10/image-2.png 1641w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>시간 Option에 정규식 입력 시, Back Slash를 사용하려면 Back Slash를 두 번 써야 하는 불편함이 있습니다.</p>



<h3 class="wp-block-heading">마무리</h3>



<p>이 스크립트를 활용하면 여러 서버의 로그를 확인하기 위해 반복적으로 접속하고 <code>grep</code> 명령을 실행하는 수고를 덜 수 있습니다. IP 주소나 <code>grep</code> 패턴을 환경에 맞게 수정하여 다양하게 활용해 보시기 바랍니다.</p>
<p>게시물 <a rel="nofollow" href="https://somsap.somsap.com/2025/10/21/shell-script-%eb%8b%a4%ec%a4%91-%ec%9b%90%ea%b2%a9-%ec%84%9c%eb%b2%84-%eb%a1%9c%ea%b7%b8-%eb%b6%84%ec%84%9d-%ec%9e%90%eb%8f%99%ed%99%94-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8/">[Shell Script] 다중 원격 서버 로그 분석 자동화 스크립트</a>이 <a rel="nofollow" href="https://somsap.somsap.com">솜삽 블로그</a>에 처음 등장했습니다.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://somsap.somsap.com/2025/10/21/shell-script-%eb%8b%a4%ec%a4%91-%ec%9b%90%ea%b2%a9-%ec%84%9c%eb%b2%84-%eb%a1%9c%ea%b7%b8-%eb%b6%84%ec%84%9d-%ec%9e%90%eb%8f%99%ed%99%94-%ec%8a%a4%ed%81%ac%eb%a6%bd%ed%8a%b8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2035</post-id>	</item>
	</channel>
</rss>
