1、安装。在一台ubuntu机器上安装snmpd(太方便了,这就是ubuntu) #apt-get install snmpd snmp 2、简单测试。 # snmpwalk -v 1 -c public localhost 如果有反应,表示你的snmpd已经可以正常工作。 3、配置/etc/snmp/snmpd.conf 首先修改,注意private11,回头用它。 # sec.name source community com2sec paranoid default public com2sec readonly default public com2sec readwrite default private11 再修改(检测磁盘/ 目录的磁盘空间) # disk checks # # The agent can check the amount of available disk space, and make # sure it is above a set limit. # disk PATH [MIN=DEFDISKMINIMUMSPACE] # # PATH: mount path to the disk in question. # MIN: Disks with space below this value will have the Mib's errorFlag set. # Default value = DEFDISKMINIMUMSPACE. # Check the / partition and make sure it contains at least 100 megs. disk / 100000 再修改(查服务器cpu平均负载) # load average checks # # load [1MAX=DEFMAXLOADAVE] [5MAX=DEFMAXLOADAVE] [15MAX=DEFMAXLOADAVE] # # 1MAX: If the 1 minute load average is above this limit at query # time, the errorFlag will be set. # 5MAX: Similar, but for 5 min average. # 15MAX: Similar, but for 15 min average. # Check for loads: load 1 1 1 4、测试 测试服务器CPU负荷(这里的private11就是com2sec readwrite default private11里面的private11) $ snmpwalk -v 1 -c private11 localhost .1.3.6.1.4.1.2021.10 UCD-SNMP-MIB::laIndex.1 = INTEGER: 1 UCD-SNMP-MIB::laIndex.2 = INTEGER: 2 UCD-SNMP-MIB::laIndex.3 = INTEGER: 3 UCD-SNMP-MIB::laNames.1 = STRING: Load-1 UCD-SNMP-MIB::laNames.2 = STRING: Load-5 UCD-SNMP-MIB::laNames.3 = STRING: Load-15 UCD-SNMP-MIB::laLoad.1 = STRING: 1.74 UCD-SNMP-MIB::laLoad.2 = STRING: 1.40 UCD-SNMP-MIB::laLoad.3 = STRING: 1.36 UCD-SNMP-MIB::laConfig.1 = STRING: 1.00 UCD-SNMP-MIB::laConfig.2 = STRING: 1.00 UCD-SNMP-MIB::laConfig.3 = STRING: 1.00 UCD-SNMP-MIB::laLoadInt.1 = INTEGER: 173 UCD-SNMP-MIB::laLoadInt.2 = INTEGER: 139 UCD-SNMP-MIB::laLoadInt.3 = INTEGER: 136 UCD-SNMP-MIB::laLoadFloat.1 = Opaque: Float: 1.740000 UCD-SNMP-MIB::laLoadFloat.2 = Opaque: Float: 1.400000 UCD-SNMP-MIB::laLoadFloat.3 = Opaque: Float: 1.360000 UCD-SNMP-MIB::laErrorFlag.1 = INTEGER: error(1) UCD-SNMP-MIB::laErrorFlag.2 = INTEGER: error(1) UCD-SNMP-MIB::laErrorFlag.3 = INTEGER: error(1) UCD-SNMP-MIB::laErrMessage.1 = STRING: 1 min Load Average too high (= 1.74) UCD-SNMP-MIB::laErrMessage.2 = STRING: 5 min Load Average too high (= 1.40) UCD-SNMP-MIB::laErrMessage.3 = STRING: 15 min Load Average too high (= 1.36) 测试磁盘 /目录的磁盘空间(这里的private11就是com2sec readwrite default private11里面的private11) $ snmpwalk -v 1 -c private11 localhost .1.3.6.1.4.1.2021.9 UCD-SNMP-MIB::dskIndex.1 = INTEGER: 1 UCD-SNMP-MIB::dskPath.1 = STRING: / UCD-SNMP-MIB::dskDevice.1 = STRING: /dev/sda2 UCD-SNMP-MIB::dskMinimum.1 = INTEGER: 10000000 UCD-SNMP-MIB::dskMinPercent.1 = INTEGER: -1 UCD-SNMP-MIB::dskTotal.1 = INTEGER: 15132932 UCD-SNMP-MIB::dskAvail.1 = INTEGER: 4094796 UCD-SNMP-MIB::dskUsed.1 = INTEGER: 10269428 UCD-SNMP-MIB::dskPercent.1 = INTEGER: 71 UCD-SNMP-MIB::dskPercentNode.1 = INTEGER: 18 UCD-SNMP-MIB::dskErrorFlag.1 = INTEGER: error(1) UCD-SNMP-MIB::dskErrorMsg.1 = STRING: /: less than 10000000 free (= 4094796) 再写些脚本,或者安装图形化的管理中心,就可以批量监控你的服务器了。 |
联系客服