Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1087046
  • 博文数量: 321
  • 博客积分: 7872
  • 博客等级: 少将
  • 技术积分: 2120
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-16 09:06
文章分类

全部博文(321)

文章存档

2017年(1)

2016年(1)

2015年(12)

2014年(17)

2013年(78)

2012年(15)

2011年(17)

2010年(67)

2009年(102)

2008年(11)

分类: LINUX

2013-06-19 18:04:54

环境介绍
安装的监控机A,ip为 192.168.0.16
安装的被监控机B,ip为 192.168.0.17
系统为centos 4/5

被监控B机安装snmp
net-snmp 安装参考

修改B机snmp配置,充许外部访问
自带的snmp配置文件在/etc/snmp/snmpd.conf;
编译安装的snmp配置文件在/usr/local/etc/snmp/snmpd.conf;
vi /etc/snmp/snmpd.conf

  1. com2sec local     localhost       privatepass #安装教程中配置的本机访问要权限
  2. com2sec mynetwork     192.168.0.16       privatepass #新增的外部访问权限,192.168.0.16为监控机ip,privatepass 为安全码可以和local不同
  3.  
  4. group MyROGroup v1 local
  5. group MyROGroup v2c local
  6. group MyROGroupnet v1         mynetwork #新增
  7. group MyROGroupnet v2c        mynetwork #新增
  8.  
  9.  
  10. view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
  11. view all    included  .1                               80 #新增
  12.  
  13.  
  14. access MyROGroup "" any noauth exact mib2 none none
  15. access MyROGroupnet ""      any       noauth    exact  all    none   none #新增
  16.  
  17.  
  18. #以下为访问项目,如果想监控磁盘空间,load等需把注释去掉
  19. #编译安装默认已去掉,自带安装的需手动把注释去掉
  20.  
  21. #  Make sure mountd is running
  22. proc mountd #去掉前面的"#"
  23.  
  24. #  Make sure there are no more than 4 ntalkds running, but 0 is ok too.
  25. proc ntalkd 4
  26.  
  27. #  Make sure at least one sendmail, but less than or equal to 10 are running.
  28. proc sendmail 10 1
  29.  
  30. # Check the / partition and make sure it contains at least 10 megs.
  31.  
  32. disk / 10000
  33.  
  34. # Check for loads:
  35. load 12 14 14

重启snmpd服务
#/etc/init.d/snmpd restart

#killall -9 snmpd
#/usr/local/sbin/snmpd

iptables规则
假如B机开启了iptables并且INPUT默认策略为DROP
在第一条插入充许192.168.0.16(监控机)以udp协议访问snmpd默认161端口的规则

  1. /sbin/iptables -I INPUT -p udp -m udp -s 192.168.0.16 --dport 161 -j ACCEPT

保存一下,防止重启服务后失效

  1. /etc/init.d/iptables save

测试snmp
在A机上先看下系统信息
#snmpwalk -v 2c -c privatepass 192.168.0.17 system

  1. SNMPv2-MIB::sysDescr.0 = STRING: Linux touareg 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64
  2. SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
  3. DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (59664) 0:09:56.64
  4. SNMPv2-MIB::sysContact.0 = STRING: Root (configure /etc/snmp/snmp.local.conf)
  5. SNMPv2-MIB::sysName.0 = STRING: touareg
  6. SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
  7. SNMPv2-MIB::sysORLastChange.0 = Timeticks: (7) 0:00:00.07
  8. SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
  9. SNMPv2-MIB::sysORID.2 = OID: TCP-MIB::tcpMIB
  10. SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
  11. SNMPv2-MIB::sysORID.4 = OID: UDP-MIB::udpMIB
  12. SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
  13. SNMPv2-MIB::sysORID.6 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
  14. SNMPv2-MIB::sysORID.7 = OID: SNMP-MPD-MIB::snmpMPDCompliance
  15. SNMPv2-MIB::sysORID.8 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
  16. SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities
  17. SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for managing TCP implementations
  18. SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing IP and ICMP implementations
  19. SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing UDP implementations
  20. SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
  21. SNMPv2-MIB::sysORDescr.6 = STRING: The SNMP Management Architecture MIB.
  22. SNMPv2-MIB::sysORDescr.7 = STRING: The MIB for Message Processing and Dispatching.
  23. SNMPv2-MIB::sysORDescr.8 = STRING: The management information definitions for the SNMP User-based Security Model.
  24. SNMPv2-MIB::sysORUpTime.1 = Timeticks: (6) 0:00:00.06
  25. SNMPv2-MIB::sysORUpTime.2 = Timeticks: (6) 0:00:00.06
  26. SNMPv2-MIB::sysORUpTime.3 = Timeticks: (6) 0:00:00.06
  27. SNMPv2-MIB::sysORUpTime.4 = Timeticks: (6) 0:00:00.06
  28. SNMPv2-MIB::sysORUpTime.5 = Timeticks: (6) 0:00:00.06
  29. SNMPv2-MIB::sysORUpTime.6 = Timeticks: (7) 0:00:00.07
  30. SNMPv2-MIB::sysORUpTime.7 = Timeticks: (7) 0:00:00.07
  31. SNMPv2-MIB::sysORUpTime.8 = Timeticks: (7) 0:00:00.07

没有问题,再看下磁盘信息
#snmpwalk -v 2c -c privatepass 192.168.0.17 .1.3.6.1.4.1.2021.9

  1. UCD-SNMP-MIB::dskIndex.1 = INTEGER: 1
  2. UCD-SNMP-MIB::dskPath.1 = STRING: /
  3. UCD-SNMP-MIB::dskDevice.1 = STRING: /dev/mapper/VolGroup00-LogVol01
  4. UCD-SNMP-MIB::dskMinimum.1 = INTEGER: 10000
  5. UCD-SNMP-MIB::dskMinPercent.1 = INTEGER: -1
  6. UCD-SNMP-MIB::dskTotal.1 = INTEGER: 44628400
  7. UCD-SNMP-MIB::dskAvail.1 = INTEGER: 22383404
  8. UCD-SNMP-MIB::dskUsed.1 = INTEGER: 19941408
  9. UCD-SNMP-MIB::dskPercent.1 = INTEGER: 47
  10. UCD-SNMP-MIB::dskPercentNode.1 = INTEGER: 1
  11. UCD-SNMP-MIB::dskErrorFlag.1 = INTEGER: noError(0)
  12. UCD-SNMP-MIB::dskErrorMsg.1 = STRING:

出现下面这个信息,你需要检查下A机snmpd.conf中“disk / 10000”前的注释有无去掉。

  1. UCD-SNMP-MIB::dskTable = No Such Object available on this agent at this OID

“.1.3.6.1.4.1.2021.9″代表磁盘
“.1.3.6.1.4.1.2021.10″代表load,可以参考snmpd.conf中的注释

监控机cacti增加监控设备
Console -> Devices->add
cacti add device
在设置页面配置

Description:touareg
Hostname:192.168.0.17
Host Template:ucd/net SNMP Host

Downed Device Detection:Ping and SNMP

SNMP Version:预定义的设置

保存后在页面左上角可以看到调试信息

touareg (192.168.0.17)
SNMP Information
System:Linux touareg 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009
x86_64
Uptime: 38790 (0 days, 0 hours, 6 minutes)
Hostname: touareg
Location: Unknown (edit /etc/snmp/snmpd.conf)
Contact: Root root@localhost (configure /etc/snmp/snmp.local.conf)

cacti graphs

1) ucd/net – CPU Usage Not Being Graphed (cpu负载,system,user,nice)
2) ucd/net – Load Average Not Being Graphed (系统平均负载,1分钟,5分钟,15分钟)
3) ucd/net – Memory Usage Not Being Graphed (内存使用,free,buffers,cache)

1) SNMP – Interface Statistics (网卡流量,in,out)
2) ucd/net – Get Monitored Partitions (根分区,free,used)

Not Being Graphed 表示还末生成图像,创建图像后会变成Is Being Graphed
我们可以再添加一些更详细的监控
Host MIB – Processes 监控进程数量
Host MIB – Logged in Users 监控登录用户

SNMP – Get Mounted Partitions 更多分区大小,Memory Buffer,Real Memory,Swap Space
SNMP – Get Processor Information 每个cpu的负载

临控对像增加图表
左则New Graphs
在host中选择touareg
cacti graphs2
勾选右则后选择create,就完成了图表创建,真是很方便。

添加到Graph Trees
图表创建后在Graph Management里可以看到图表,但点击导航上方的”graphs”是看不到的,需要添加到graph trees中。
Console -> Graph Trees -> (Edit) -> Graph Tree Items

Tree Item Type:host
Host:touareg

创建后就可以在graph中看到了
cacti graph tree

参考:转自:http://blog.c1gstudio.com/archives/1046

阅读(1572) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~