Tuesday, December 21, 2010

วิธีติดตั้ง MTRG บน Kloxo

ป็นหนึ่งในเทคนิคที่ผมนำมาเพิ่มความสามารถให้แก่ VPS(Linux) ที่ใช้ Control Panel Kloxo Lxadmin
ซึ่งถ้า VPS ที่เราเช่ามาเป็นแบบไม่มี Control Panel สำหรับดู Status ต่างๆของ VPS  มันก็เป็นเรื่องลำบากพอสมควร ที่เราจะเช็คว่า VPS หรือ Server ของเรา ใช้งาน CPU, RAM, Traffic , Connections ไปมากน้อยแค่ไหน

จริงแล้วๆ มีโปรแกรมอื่นๆที่นิยมใช้กันอีกนอกจาก MRTG อย่าง Munin ก็แสดงผลได้ละเอียดดีเหมือนกัน

ก่อนอื่นก็เข้า Shell ก่อนนะครับ แล้วก๊อบคำสั่งไปใช้งานได้เลยครับ

- ติดตั้ง mrtg ก่อน
yum -y install net-snmp net-snmp-utils mrtg
cd /etc/snmp/
mv snmpd.conf snmpd.conf.bak
nano snmpd.conf

- แก้ไข Config โดยการก๊อบข้างล่างไปวางใน text editor เลยครับ

โค๊ด:
syslocation  Thailand
syscontact  admin
sysservices 79
rocommunity  snmp 127.0.0.1
agentaddress  127.0.0.1

chkconfig snmpd on
/etc/init.d/snmpd start

- สร้าง Directory ที่ใช้ในการทำงานของ mrtg
mkdir -p /home/kloxo/httpd/default/mrtg
cd /etc/mrtg/

- แก้ไข Config ของ mrtg
mv mrtg.cfg mrtg.cfg.bak
nano mrtg.cfg

- คำโค้ดไฟล์การตั้งค่าไปใส่ใน text editor
โค๊ด:
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt,/usr/share/snmp/mibs/UDP-MIB.txt

WorkDir: /home/kloxo/httpd/default/mrtg

Options[_]: growright

EnableIPv6: no

Target[server.traffic]: 2:snmp@127.0.0.1:::::2
SetEnv[server.traffic]: MRTG_INT_IP="eth0" MRTG_INT_DESCR="eth0"
MaxBytes[server.traffic]: 125000000
Title[server.traffic]: Traffic Load
PageTop[server.traffic]: <h1>Traffic Load</h1>
Options[server.traffic]: growright, bits

#
# Memory Monitoring (Free with Buffer,/Cache/Total)
#

Target[server.memory]: memTotalSwap.0&memAvailReal.0:snmp@127.0.0.1 + PseudoZero&memBuffer.0:snmp@127.0.0.1 - memAvailSwap.0&PseudoZero:snmp@127.0.0.1
Title[server.memory]: Free Memory
PageTop[server.memory]: <H1>Free Memory</H1>
MaxBytes[server.memory]: 1044480000
ShortLegend[server.memory]: KBytes
YLegend[server.memory]: KBytes
LegendI[server.memory]: Swap inused
LegendO[server.memory]: Free Memory
Legend1[server.memory]: Swap inused
Legend2[server.memory]: Free memory inc Buffer
Options[server.memory]: growright,gauge,nopercent
#kMG[server.memory]: k,M,G

#
# CPU Monitoring
# (Scaled so that the sum of all three values doesn't exceed 100)
#
 
Target[server.cpu]: ssCpuRawUser.0&ssCpuUser.0:snmp@127.0.0.1 + ssCpuRawSystem.0&ssCpuSystem.0:snmp@127.0.0.1
Title[server.cpu]: Server CPU Load
PageTop[server.cpu]: <H1>CPU Utilization</H1>
MaxBytes[server.cpu]: 100
ShortLegend[server.cpu]: %
YLegend[server.cpu]: % CPU
#Legend1[server.cpu]: Current CPU Idle
Legend1[server.cpu]: Accurate CPU Load
Legend2[server.cpu]: Current CPU Load
#LegendI[server.cpu]: Percentage CPU Idle
LegendI[server.cpu]: Accurate CPU Load
LegendO[server.cpu]: Current CPU Load
Options[server.cpu]: growright,nopercent,gauge
Unscaled[server.cpu]: ymwd
 
#
# Load Average 1 & 15 min
# (Scaled so that the sum of all three values doesn't exceed 100)
#

Target[server.load]: laLoadInt.3&laLoadInt.1:snmp@127.0.0.1
Title[server.load]: Load Average at 15 and 1 Min
PageTop[server.load]: <H1>Load Average</H1>
MaxBytes[server.load]: 10000
ShortLegend[server.load]: #
YLegend[server.load]: #Load
Legend1[server.load]: Current CPU load (15 Mins)
Legend2[server.load]: Current CPU load (1 Mins)
LegendI[server.load]: Load 15 Mins
LegendO[server.load]: Load 1 Mins
Options[server.load]: growright,nopercent,gauge

#
# New TCP Connection Monitoring (per minute)
#
 
Target[server.newconns]: tcpPassiveOpens.0&tcpActiveOpens.0:snmp@127.0.0.1
Title[server.newconns]: Newly Created TCP Connections
PageTop[server.newconns]: <H1>New TCP Connections</H1>
MaxBytes[server.newconns]: 65536
ShortLegend[server.newconns]: c/s
YLegend[server.newconns]: Conns / Min
LegendI[server.newconns]: In
LegendO[server.newconns]: Out
Legend1[server.newconns]: New inbound connections
Legend2[server.newconns]: New outbound connections
Options[server.newconns]: growright,nopercent,perminute
#Unscaled[server.newconns]: ymwd
#kMG[server.newconns]: k,M,G,T,P,X  
 
#
# Established TCP Connections
#
 
Target[server.estabcons]: tcpCurrEstab.0&tcpCurrEstab.0:snmp@127.0.0.1
Title[server.estabcons]: Currently Established TCP Connections
PageTop[server.estabcons]: <H1>Established TCP Connections</H1>
MaxBytes[server.estabcons]: 65536
ShortLegend[server.estabcons]: #
YLegend[server.estabcons]: Connections
LegendI[server.estabcons]: In/Out
LegendO[server.estabcons]: 
Legend1[server.estabcons]: Established connections
Legend2[server.estabcons]: 
Options[server.estabcons]: growright,nopercent,gauge

- สุดท้าย
indexmaker --columns=2 --output=/home/kloxo/httpd/default/mrtg/index.html /etc/mrtg/mrtg.cfg


การเรียกใช้งาน เรียกผ่าน ip server/vps ของคุณ http://xxx.xxx.xxx.xxx/mrtg (http://xxx.xxx.xxx.xxx/mrtg)

(http://i.uppicturbo.com/pic/6870_7681.jpg)

จาก

http://www.thaiseoboard.com/index.php?action=printpage;topic=113754.0

0 comments:

Post a Comment

 
Design by GURU