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´Â µµ¸ÞÀκ°·Î Àß ±×·ÁÁø´Ù~~ ^^