วันจันทร์ที่ 8 กุมภาพันธ์ พ.ศ. 2553

clarkconnect 4.3+ MRTG

สวัสดีครับ พอดีผมมือใหม่ แต่อยากแชร์การติดตั้ง MRTG เผื่อเพื่อนๆจะได้ประโยชน์บ้าง
พอดี เข้าบอร์ดมาพักนึงแล้วล่ะครับ ยอมรับครับว่าบอร์ดนี้ แชร์กันดีมากเลยครับ
ถ้าสนใจเดี๋ยวจะมาแชร์ครับ

รู้จักกับ MRTG
MRTG ย่อมาจาก Multi Router Traffic Grapher เป็นเครื่องมือที่ใช้สำหรับการมอนิเตอร์ดู Traffic Load บน Nerwork Links ซึ่งการทำงานของ MRTG จะมีการสร้าง HTML Pages ที่ประกอบด้วยภาพ (กราฟ) ชนิด PNG โดยภาพดังกล่าวนี้จะแสดงถึงปริมาณของทราฟฟิกบนเครือข่าย ว่ามีทราฟฟิกหนาแน่น หรือไม่ คอยมอนิเตอร์ดู Traffic Load ที่จะมีปัญหาเรื่อง Traffic และสภาพของเครื่อง Server ของเพื่อนๆ โหลด เยอะแค่ไหน จะได้ปรับแต่งได้ตามสมควรครับ หวังว่ามีประโยชน์ไม่มากก็น้อย ยิงฟันยิ้ม


เริ่มกันเลย

ผมทดสอบกับ CC 4.3 En เวอร์ชั่นอื่นๆ น่าจะเหมือนกัน

login เข้า server ด้วย putty

เช็คดูว่ามีการติดตั้ง snmp ไปแล้วหรือยัง

# rpm -qa | grep snmp
ถ้าเจอ package ประมาณนี้ แสดงว่าได้ติดตั้งแล้ว
net-snmp-libs-5.1.2-13.el4
net-snmp-5.1.2-13.el4
net-snmp-utils-5.1.2-13.el4

ถ้า ไม่เจอ package snmp ต้องทำการติดตั้งเข้าไปก่อน โดยใช้คำสั่ง apt-get
# apt-get install net-snmp

พอลงเสร็จแล้วให้แก้ไขค่า config ของ snmp

#vi /etc/snmp/snmpd.conf
หรือ download ไฟล์ snmpd.conf ตัวนี้ไปทับไฟล์ต้นฉบับเลย ยังไงอย่าลืม backup ไฟล์ต้นฉบับไว้ก่อนน่ะครับ ยิงฟันยิ้ม
http://www.uploadd.com/download.aspx?pku=4ECB5DBB0A9J34PVZLI[ROV3FZOOR

สั่ง ให้ snmp start เมื่อบู้ตเครื่องใหม่
#chkconfig snmpd on

สั่ง ให้ snmp start
#service snmpd start


ต่อไปมาดู mrtg กันว่าได้ติดตั้งไปหรือยัง (ส่วนใหญ่ cc จะติดตั้ง MRTG Package มาให้แล้วน่ะครับ)

#rpm -qa | grep mrtg
ถ้าเจอ MRTG Package แสดงว่าได้ติดตั้งลงไปแล้ว ก็ข้ามไปขั้นตอนต่อจากการติดตั้งเสร็จแล้วได้เลย
cc-mrtg-4.3-30
mrtg-2.10.15-2a

สั่ง ติดตั้ง MRTG Package ในกรณีที่ cc ไม่ได้ติดตั้งมาให้
#apt-get install mrtg

พอติดตั้งเสร็จ MRTG Packageให้สร้าง folder mrtg ตามคำสั่งด้านล่าง

# mkdir -p /var/www/html/mrtg/

สั่ง cfgmaker เพื่อสร้างไฟล์ config

#cfgmaker --global 'WorkDir: /var/www/html/mrtg' --output /etc/mrtg/mrtg.cfg public@localhost

สั่ง indexmaker เพื่อสร้าง index page
#indexmaker --column=1 --output=/var/www/html/mrtg/index.html /etc/mrtg/mrtg.cfg

ตั้ง Crontab

#crontab -e

ใส่ค่าเข้าไป
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log

เซฟแล้วออกมา

# vi /etc/httpd/conf.d/mrtg.conf

แก้ไขตามนี้

Alias /mrtg /var/www/html/mrtg


Order deny,allow
#Deny from all
Deny from none
Allow from 127.0.0.1
Allow from all
# Allow from .example.com



เพิ่ม ค่าเหล่านี้เข้าไปในไฟล์ mrtg.cfg
#vi /etc/mrtg/mrtg.cfg

โค๊ด:

### Load Average ###
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@127.0.0.1
MaxBytes[cpu]: 100
Unscaled[cpu]: dwmy
Options[cpu]: gauge, absolute, growright, noinfo, nopercent
YLegend[cpu]: CPU Load(%)
ShortLegend[cpu]: (%)
LegendI[cpu]:   CPU System
LegendO[cpu]:   CPU User
Title[cpu]: CPU Analysis
PageTop[cpu]:

CPU Analysis


### Memory Free ###
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@127.0.0.1
MaxBytes1[mem]: 1030288
MaxBytes2[mem]: 1052216
Unscaled[mem]: dwmy
Options[mem]: gauge, absolute, growright, noinfo
YLegend[mem]: Memory Free
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: (MBytes)
Legend2[mem]: (MBytes)
Title[mem]: Memory Analysis
PageTop[mem]:

Memory Analysis


### New TCP Connection Monitoring (per minute) ###
Target[server.newconns]: tcpPassiveOpens.0&tcpActiveOpens.0:public@127.0.0.1
Title[server.newconns]: Newly Created TCP Connections
PageTop[server.newconns]:

New TCP Connections


MaxBytes[server.newconns]: 10000000000
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
### Established TCP Connections ###
Target[server.estabcons]: tcpCurrEstab.0&tcpCurrEstab.0:public@127.0.0.1
Title[server.estabcons]: Currently Established TCP Connections
PageTop[server.estabcons]:

Established TCP Connections


MaxBytes[server.estabcons]: 10000000000
ShortLegend[server.estabcons]:
YLegend[server.estabcons]: Connections
LegendI[server.estabcons]: In
LegendO[server.estabcons]:
Legend1[server.estabcons]: Established connections
Legend2[server.estabcons]:
Options[server.estabcons]: growright,nopercent,gauge



สั่ง indexmaker เพื่อสร้าง index page ใหม่

#indexmaker --column=1 --output=/var/www/html/mrtg/index.html /etc/mrtg.cfg


#service httpd restart

เรียกดู mrtg

http://myip/mrtg


จบล่ะครับ ติดขัดตรงไหน ถ้ายังไม่ขึ้น กราฟ โพสในบอร์ดได้ครับ เดี๋ยวจะมาตอบ ยิงฟันยิ้ม

หน้าตา ของ MRTG

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

ปัญหา wordpad ใน windows 11 หาย แก้ไขแบบนี้

 https://win7games.com/#wordpad download มาติดตั้งซะ