°Ô½Ã¹° 1,369°Ç
   
µµ¸ÞÀκ° MRTG Æ®·¡ÇÈ ±×¸®±â
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2012-02-15 (¼ö) 16:21 Á¶È¸ : 11522
±ÛÁÖ¼Ò :
                                
µµ¸ÞÀκ°·Î ºÐ¸®µÇ¾î ÀÖ´Â ¾ÆÆÄÄ¡ ·Î±×µ¥ÀÌŸ¸¦ °¡Áö°í MRTG ±×¸®±â
·Î±×ºÐ¼®Àº Awstats¿¡¼­ ºÐ¼®ÇØÁØ °á°ú¸¦ °¡Áö°í ÀÌ¿ëÇÑ´Ù.
ÇÊÀÚÀÇ °æ¿ì´Â À¥·Î±×¸¦ apache ¿Í squid ¸¦ ³ª´©¾î¼­ ¿î¿µÇϱ⿡ µÎµµ¸ÞÀÎÀ» °¢°¢...»Ì¾Æ¼­ ÇÕÇÑ´Ù.
¾ÆÆÄÄ¡ ·Î±×¸¸ ¿î¿µÇÏ½Å´Ù¸é °è»ê½ÄÀº »©°í ÀÌ¿ëÇÏ½Ã¸é µÇ°ÚÁö¿ä....


APACHE ·Î±× 
¸ðµç VirtualHost¿¡´Â combined ·Î±×À» ³²±â¸ç µµ¸ÞÀκ°·Î À¥·Î±×°¡ »ý¼º

/usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost 115.68.XX.XXX>
    ServerAdmin webhosting@smileserv.com
    DocumentRoot /home/chonnom
    ServerName test1.chonnom.com
    ErrorLog /backup/apache_logs/chonnom.com-error_log
    CustomLog /backup/apache_logs/chonnom.com-access_log combined
</VirtualHost>


SQUID ·Î±×
Squid ·Î±×´Â vhostº°·Î ·Î±×»ý¼ºÀ» Áö¿øÇÏÁö ¾Ê´Â´Ù.
µû¶ó¼­ »ý¼ºµÈ ·Î±×ÆÄÀÏÀ» µµ¸ÞÀκ°·Î ºÐ·ùÇؼ­ Æ®·¡ÇÈ »ç¿ë·®À» »êÃâÇÑ´Ù.

ex) 
/usr/local/squid/etc/squid.conf
cache_peer test1.chonnom.com parent 80 0
cache_peer test2.chonnom.com parent 80 0
access_log /usr/local/squid/var/logs/access.log combined


Awstats ¼³Ä¡
·Î±× ±â¹Ý Æ®·¡ÇȺм®±â
¼­ºñ½º µµ¸ÞÀθ¶´Ù CACHE ·Î±×¿Í ¾ÆÆÄÄ¡ ·Î±×¸¦ ºÐ¼®ÇÑ´Ù.

Çü½Ä) /etc/awstats
 awstats.cache_${DOMAIN}.conf
 awstats.${DOMAIN}.conf

awstats.cache_${DOMAIN}.conf (µµ¿¡Àκ°·Î SQUID ·Î±×µ¥ÀÌŸ ºÐ¼®)
LogFile="cat /usr/local/squid/var/logs/access.log | egrep '(HEAD|GET|POST) http://${DOMAIN}' |"
SiteDomain="cache_${DOMAIN}"
HostAliases="cache_${DOMAIN} 127.0.0.1 localhost"

 awstats.${DOMAIN}.conf
LogFile="/usr/local/apache/logs/${DOMAIN}-access_log"
SiteDomain="${DOMAIN}"
HostAliases="${DOMAIN} 127.0.0.1 localhost"



/usr/local/awstats/logs
Çü½Ä : awstats{¿ù}{³âµµ}.{DOMAIN}.txt
 ex)  awstats012012.${DOMAIN}.txt  ¡æ ¾ÆÆÄÄ¡·Î±× ºÐ¼®µ¥ÀÌŸ ÆÄÀÏ
       awstats012012.cache_${DOMAIN}.txt  ¡æ ½ºÄûµå·Î±× ºÐ¼®µ¥ÀÌŸ ÆÄÀÏ

±½Àº¼ýÀÚ¸¦ °¡Áö°í µ¥ÀÌŸ·® »êÃâ (±âº»´ÜÀ§ BYTE)
# Date - Pages - Hits - Bandwidth - Visits
BEGIN_DAY 2
20120104 19 145 138557 1
20120105 55 212 328569 5
END_DAY

¡Ø Awstats ±âº»´ÜÀ§ 
  BYTE --> KBYTE --> MBYTE --> GBYTE
         1024           1024          1024
ex)
1088917392821 / 1024 / 1024 / 1024 = 1014.1333498256281018257141113281  /  1014.13 GB


SNMP ¼³Á¤
MRTG ¼­¹ö·Î Àü¼ÛÇÒ µµ¸ÞÀκ° Æ®·¡ÇÈ »ç¿ë·® µ¥ÀÌŸ (5ºÐ´ÜÀ§)
À̹ÌÁöÈ£½ºÆà ¼­¹ö¿¡ ¼³Á¤ÇÏ¸ç µµ¸ÞÀκ°·Î »ý¼ºÇÑ´Ù.

/etc/snmp/snmpd.conf 
exec mrtg /usr/local/src/global.sh domain_mrtg ${DOMAIN_1}
exec mrtg /usr/local/src/global.sh domain_mrtg ${DOMAIN_2}

/usr/local/src/global.sh
year=`date +%Y`
month=`date +%m`
path="/usr/local/awstats/logs"
today=`date +%Y%m%d`
yesterday=`date -d "1 day ago" +%Y%m%d`

function domain_mrtg() {
    sh /usr/local/src/awstats.sh > /dev/null

    apache_logfile=${path}/awstats${month}${year}.$1.txt
    squid_logfile=${path}/awstats${month}${year}.cache_$1.txt

    apache_traffic=`cat ${apache_logfile} |grep -w ${today} | awk '{print $4}'`
    squid_traffic=`cat ${squid_logfile} |grep -w ${today} | awk '{print $4}'`

    # ·Î±× ¹ß»ýÀÌ ¾øÀ»°æ¿ì 0 °ªÀ¸·Î ´ëü
    if [ "${apache_traffic}" = "" ]; then
        apache_traffic=0
    fi
    if [ "${squid_traffic}" = "" ]; then
        squid_traffic=0
    fi

    traffic=`expr ${apache_traffic} + ${squid_traffic}`
    echo $traffic
}

case "$1" in
domain_mrtg)
domain_mrtg $2
;;
*)
esac


5. MRTG CFG ÆÄÀÏ»ý¼º
MRTG ¼­¹ö¿¡ CFG ÆÄÀÏ»ý¼º
Å×½ºÆ®)  ¸¶Áö¸· ¼ýÀÚ 1ÀÌ snmpd.conf ÆÄÀÏ¿¡ ³Ö¾îÁØ Ã¹¹ø° ¶óÀΠ
[root@image_m ]# snmpwalk  -v2c -c managed_snmp 115.68.29.8 .1.3.6.1.4.1.2021.8.1.101.1
UCD-SNMP-MIB::extOutput.1 = STRING: 492505  
 ¡æ SQUID +APACHE LOG Æ®·¡ÇÈ Çջ귮

MRTG.CFG
EnableIPv6: no
Workdir: /HOSTING/testmrtg/bps
language: korean
Options[_]: bits,growright

Target[${DOMAIN}]: .1.3.6.1.4.1.2021.8.1.101.1&.1.3.6.1.4.1.2021.8.1.101.1:managed_snmp@115.68.XX.XX:::::2
MaxBytes[${DOMAIN}]: 125000000
Title[${DOMAIN}]: ${DOMAIN}
PageTop[${DOMAIN]: ${DOMAIN}
 <TABLE>
   <TR><TD>IP:</TD> <TD>${DOMAIN}</TD></TR>
 </TABLE>



¡Ø ÇãÁ¢ÇÏ°Ô³ª¸¶  MRTG´Â µµ¸ÞÀκ°·Î Àß ±×·ÁÁø´Ù~~ ^^

À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.