• yum -y remove net-snmp net-snmp-utils mrtg
  • rm -rf /var/www/mrtg
  • rm -rf /etc/snmp
  • rm -rf /etc/mrtg
     

ถ้ามี error

at /usr/bin/../lib64/mrtg2/SNMP_util.pm line 492
SNMPGET Problem for ifHCInOctets.2 ifHCOutOctets.2 sysUptime sysName on snmp@127.0.0.1:::::2:v4only


yum update

cpan สั่ง install IO-Socket-INET6

yum -y install perl-Net-SNMP

  • yum -y install net-snmp net-snmp-utils mrtg mrtg-libs
  • echo -e "syslocation Thailand\nsyscontact admin\nsysservices 79\nrocommunity snmp 127.0.0.1\nagentaddress 127.0.0.1" > /etc/snmp/snmpd.conf
  • vi /etc/mrtg/mrtg.cfg

copy ลงไฟล์ไฟล์ credit p'man kke

#LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt,/usr/share/snmp/mibs/UDP-MIB.txt

WorkDir: /var/www/html/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 Loadh1>
Options[server.traffic]: growrightbits

#
# 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

Target[server.memory]: .1.3.6.1.4.1.2021.4.3.0&.1.3.6.1.4.1.2021.4.6.0:snmp@127.0.0.1 PseudoZero&.1.3.6.1.4.1.2021.4.14.0:snmp@127.0.0.1 .1.3.6.1.4.1.2021.4.4.0&PseudoZero:snmp@127.0.0.1
Title
[server.memory]: Free Memory
PageTop
[server.memory]: <H1>Free MemoryH1>
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

Target[server.cpu]: .1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.9.0:snmp@127.0.0.1 .1.3.6.1.4.1.2021.11.52.0&.1.3.6.1.4.1.2021.11.10.0:snmp@127.0.0.1
Title
[server.cpu]: Server CPU Load
PageTop
[server.cpu]: <H1>CPU UtilizationH1>
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

Target[server.load]: .1.3.6.1.4.1.2021.10.1.5.3&.1.3.6.1.4.1.2021.10.1.5.1:snmp@127.0.0.1
Title
[server.load]: Load Average at 15 and 1 Min
PageTop
[server.load]: <H1>Load AverageH1>
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

Target[server.newconns]: .1.3.6.1.2.1.6.6.0&.1.3.6.1.2.1.6.5.0:snmp@127.0.0.1
Title
[server.newconns]: Newly Created TCP Connections
PageTop
[server.newconns]: <H1>New TCP ConnectionsH1>
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

Target[server.estabcons]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:snmp@127.0.0.1
Title
[server.estabcons]: Currently Established TCP Connections
PageTop
[server.estabcons]: <H1>Established TCP ConnectionsH1>
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 

  • mkdir -p /var/www/html/mrtg
  • indexmaker --columns=2 --output=/var/www/html/mrtg/index.html /etc/mrtg/mrtg.cfg
  • chkconfig snmpd on
  • /etc/init.d/snmpd restart
  • snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

IP-MIB::ipAdEntIfIndex.103.xxx.xx.xx= INTEGER: 2
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

  • vi /etc/cron.d/mrtg

*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok > /dev/null 2>&1

  • ทดสอบ

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok

  • Refference
http://www.icez.net/blog/28/%E0%B8%A...B8%A2%E0%B9%86
- บทความเก่าของคุณแมน kke
http://www.ireallyhost.com/kb/7/

ไอเรียลลี่โฮส
สำหรับการสนับสนุน และช่วยเหลือ
http://www.ireallyhost.com/support
ข้อกำหนดในการเผยแพร่บทความ ข่าวสาร
** บทความนี้มีลิขสิทธิ์ ไม่อนุญาติให้คัดลอก ทำซ้ำ ดัดแปลงก่อนได้รับอนุญาต **
โปรดระบุแหล่งที่มา บริษัท เอ็กซ์ตร้า คอร์ปอเรชั่น จำกัด / https://www.ireallyhost.com