Frank的学习之路

3.1_zabbix通过snmp监控linux

1: linux snmpd安装:
yum install -y net-snmp net-snmp-utils

2: snmp的配置(vim /etc/snmp/snmpd.conf):
com2sec notConfigUser default snmp_passwd
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
#view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1
access notConfigGroup "" any noauth exact systemview none none
syslocation hangzhou
syscontact module@hangzhou.com
dontLogTCPWrappersConnects yes

snmp oid:
1
3 5

mib的讲解:
disk2 -> 1.2.2

3: snmp开启和默认开启
/etc/init.d/snmpd restart
chkconfig snmpd on
chkconfig --list|grep snmp

4: snmp理论与测试:
4.1 snmp oid(搜索SNMPv2-MIB进行讲解)
4.2 snmp mib库
4.3 测试
snmpwalk -v 2c -c snmp_passwd 172.16.0.3 sysDescr
snmpwalk -v 2c -c snmp_passwd 172.16.0.3 ifDescr
snmpwalk -v 2c -c snmp_passwd 172.16.0.3 ifOutOctets.1
snmpwalk -v 2c -c snmp_passwd 172.16.0.3 ifHCOutOctets.1

5: zabbix添加主机:
使用snmp监控172.16.0.3,端口是161
ss -tulnp|grep snmp

zabbix自定义宏变量:
管理-> 一般->宏定义
{$SNMP_COMMUNITY} = snmp_passwd

6: zabbix手动添加通过snmp v2添加监控:
SNMPv2-MIB::sysDescr.0 #字符
克隆添加IF-MIB::ifDescr.2

7: zabbix通过snmp模板去监控linux流量
7.1 使用Template SNMP Interfaces模板(注意,流量需要用64位的)
Incoming traffic on interface 加个HC
Outgoing traffic on interface 加个HC
7.2 刷新一下,看下流量是否准确
7.3 时间调短说明

8: zabbix通过snmp模板监控linux磁盘
8.1 使用Template SNMP Disks模板
8.2 多等一会儿看下磁盘的容量,跟系统进行对比
8.3 时间调短说明

设置举例:
名称:sysDescr
类型:SNMPv2客户端
健值:sysDescr
主机接口:172.21.3.153:161
SNMP OID:SNMPv2-MIB::sysDescr.0
SNMP community:{$SNMP_COMMUNITY}
信息类型:字符

模板设置:
系统参数(1.3.6.1.2.1.1)
获取系统基本信息 SysDesc
系统运行的进程列表 hrSWRunName

网络接口(1.3.6.1.2.1.2)
网络接口的数目 IfNumber
接口的物理地址 IfPhysAddress
接口当前操作状态[up|down] IfOperStatus
接口收到的字节数 IfInOctet

接口发送的字节数 IfOutOctet ifHCOutOctets.1

CPU及负载
用户CPU百分比 ssCpuUser
系统CPU百分比 ssCpuSystem
CPU的当前负载,N个核就有N个负载 hrProcessorLoad

内存及磁盘(1.3.6.1.2.1.25)
获取内存大小 hrMemorySize
使用多少,跟总容量相除就是占用率 hrStorageUsed
Total Swap Size(虚拟内存) memTotalSwap

disk
Path where the disk is mounted dskPath
Path of the device for the partition dskDevice

Total size of the disk/partion (kBytes) dskTotal

Available space on the disk dskAvail

Used space on the disk dskUsed

Percentage of space used
on disk dskPercent
Percentage of inodes used on disk dskPercentNode
返回顶部