- Install SNMP
yum install net-snmp-utils net-snmp
- SNMP Configuration
vi /etc/snmp/snmpd.conf
Find the following Line:
com2sec notConfigUser default public
Replace with the following lines:
com2sec local localhost public com2sec mynetwork 192.168.0.0/24 public
Find Lines:
group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser
Replace with:
group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork
Find line:
view systemview included system
Replace with:
view all included .1
Find line:
access notConfigGroup "" any noauth exact systemview none none
Replace with:
access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none
Find lines:
syslocation Unknown (edit /etc/snmp/snmpd.conf) syscontact Root (configure /etc/snmp/snmp.local.conf)
Replace with:
syslocation Linux (CentOs6.5) syscontact YourNameHere <[email protected]>
- Start up SNMP
service snmpd start chkconfig snmpd on
Test your snmp server with following line:snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
- Install MRTG
yum install mrtg mkdir -p /var/www/html/mymrtg/ cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg.cfg public@localhost cp -av /var/www/mrtg/*.png /var/www/html/mymrtg/
- Configure MRTG
vi /etc/mrtg/mymrtg.cfg
Make sure the following content are in the fileEnableIPv6: no WorkDir:/var/www/html/mymrtg # Reload page every 5 minute Refresh:300 # Call mrtg every 5 minute Interval:5 ### Monitoring CPU Load[use+free] Target[cpuload]: .1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.53.0:public@localhost: Directory[cpuload]: cpu Options[cpuload]: nopercent,growright MaxBytes[cpuload]: 100 Unscaled[cpuload]: dwym YLegend[cpuload]: CPU Utilization ShortLegend[cpuload]: % Legend1[cpuload]: CPU Usage(%) Legend2[cpuload]: CPU Free(%) LegendI[cpuload]: Used: LegendO[cpuload]: Free: Title[cpuload]: CPU Load(Use+Free) PageTop[cpuload]:<h1>CPU Load(Use+Free)</h1> ### Monitoring server load(1/5 minute average) Target[load]: .1.3.6.1.4.1.2021.10.1.3.1&.1.3.6.1.4.1.2021.10.1.3.2:public@localhost: Options[load]: growright Directory[load]: dev_load MaxBytes[load]: 10 Unscaled[load]: dwym YLegend[load]: Server Load ShortLegend[load]: Legend1[load]: 1 min Average Legend2[load]: 5 mins Average LegendI[load]: 1 min Average LegendO[load]: 5 mins Average Title[load]: Developer Server Load(1/5 minute average) PageTop[Load]:<h1>Developer Server Load(1/5 minute average)</h1> ### Monitoring Used Memory and Swap [Mem+Swap] free -k Target[memory]: .1.3.6.1.2.1.25.2.3.1.6.3&.1.3.6.1.2.1.25.2.3.1.6.10:public@localhost: Directory[memory]: memory Options[memory]: gauge,growright MaxBytes1[memory]: 8003360 MaxBytes2[memory]: 1048572 Kmg[memory]: K,M,G Kilo[memory]: 1024 Unscaled[memory]: dwym YLegend[memory]: Mem Bytes ShortLegend[memory]: B Legend1[memory]: Used Mem(Bytes) Legend2[memory]: Used Swap(Bytes) LegendI[memory]: Used Mem LegendO[memory]: Used Swap Title[memory]: Memory Usage(Mem+Swap) PageTop[memory]:<h1>Memory Usage(Mem+Swap)</h1> ### Moniting disk size [/+/var] df -k Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.2:public@localhost: # +.1.3.6.1.4.1.2021.9.1.9.3&.1.3.6.1.4.1.2021.9.1.9.4:public@localhost: Options[disk]: gauge,growright,nopercent Directory[disk]: disk MaxBytes[disk]: 100 Unscaled[disk]: dwym YLegend[disk]: Utilization ShortLegend[disk]: % Legend1[disk]: / Usage Legend2[disk]: /var Usage #Legend3[disk]: /boot Usage #Legend4[disk]: /usr Usage LegendI[disk]: / Usage LegendO[disk]: /var Usage Title[disk]: Disk Space(/+/var) PageTop[disk]:<h1>Disk Space(/+/var)</h1> ### Monitoring TCP connections (per minute) Target[connection]: .1.3.6.1.2.1.6.6.0&.1.3.6.1.2.1.6.5.0:public@localhost: Options[connection]: growright,perminute,nopercent Directory[connection]: connection MaxBytes[connection]: 1000000 ShortLegend[connection]: c/s YLegend[connection]: Conns / Min Legend1[connection]: New inbound connections Legend2[connection]: New outbound connections LegendI[connection]: In LegendO[connection]: Out Title[connection]: New TCP Connections PageTop[connection]:<h1>New TCP Connections</h1> ### Established TCP connections Target[Econnection]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@localhost: Options[Econnection]: growright,nopercent,gauge Directory[Econnection]: EstablishedConnections MaxBytes[Econnection]: 1000000 ShortLegend[Econnection]: YLegend[Econnection]: Connections Legend1[Econnection]: Established connections Legend2[Econnection]: LegendI[Econnection]: In LegendO[Econnection]: Title[Econnection]: Currently Established TCP Connections PageTop[Econnection]:<h1>Established TCP Connections</h1>
- Cron
vim /etc/cron.d/mrtg
Edit it like below:0-59/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg
- Remote Server
Install and configure SNMP as step1 and step2 on the remote servers .Add content in the snmpd.conf like below:
...... com2sec server [---IP address of server here---] public ...... group RWGroup v1 server group RWGroup v2c server group RWGroup usm server ......
-
On main server side, make a new directory for remote server configure files, for example:
mkdir /etc/mrtg/servers vi /etc/mrtg/servers/servername1.cfg
add a new line in mrtg configure file:
Include:servers/*.cfg
configure mrtg for server1 like below:
### Monitoring CPU Load[use+free] Target[dev_cpuload]: .1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.53.0:public@(ip address of remote server): Directory[dev_cpuload]: dev_cpu Options[dev_cpuload]: nopercent,growright MaxBytes[dev_cpuload]: 100 Unscaled[dev_cpuload]: dwym YLegend[dev_cpuload]: CPU Utilization ShortLegend[dev_cpuload]: % Legend1[dev_cpuload]: CPU Usage(%) Legend2[dev_cpuload]: CPU Free(%) LegendI[dev_cpuload]: Used: LegendO[dev_cpuload]: Free: Title[dev_cpuload]: Developer Server CPU Load(Use+Free) PageTop[dev_cpuload]: <h1>Developer Server CPU Load(Use+Free)</h1>
- After all, start mrtg service
env Lang=C mrtg /etc/mrtg/mymrtg.cfg indexmaker --output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg
- Apache configure
vim /etc/httpd/conf.d/mrtg.conf
Add below content and restart the httpd service.
Alias /mymrtg /var/www/html/mymrtg <Location /mymrtg> Order allow,deny Allow from all Deny from 192.168.1.1 </Location>
- Visit /mymrtg on browser, and check the result
Mrtg + Snmp远程监控配置
猜你喜欢
转载自blog.csdn.net/luna33/article/details/50034997
今日推荐
周排行