一般我们监控Linux都是通过SSH或Telnet方式,有时候我们不方便通过这两种方式,比如遇到监控端口因为安全原因被封禁、以及SSH需要密钥登录,这都会让监控工具很难直接远程连接。而通过SNMP的方式监控就灵活多了,可以指定IP来接发数据包,监控项和端口也可以灵活配置。
1.安装 snmp服务先检查是否安装了snmp[root@localhost] rpm -qa|grep snmp如果未安装则yum安装
[root@localhost] yum install -y net-snmp net-snmp-utils2.配置snmp服务第一步:
(yum安装snmpd的配置文件为/etc/snmp/snmpd.conf ,一份非常详细的文档,先备份一份snmpd.conf)
[root@localhost] mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak3.运行snmp服务
[root@localhost] service snmpd startStarting snmpd:                           
                [  OK  ]4.设置成开机自动运行snmpd服务[root@localhost] chkconfig snmpd on
[root@localhost] chkconfig –list|grep snmpdsnmpd           0:off   1:off 
 2:on    3:on    4:on    5:on    6:off
5.如果无法联网安装,就需要下载相关rpm,但是安装过程中要注意顺序
rpm -ivh 安装顺序如下:
lm_sensors-libs-3.1.1-17.el6.x86_64.rpm  
net-snmp-libs-5.5-60.el6.x86_64.rpm
net-snmp-5.5-60.el6.x86_64.rpm
net-snmp-utils-5.5-60.el6.x86_64.rpm


6.snmpd.conf文件配置
vi /etc/snmp/snmpd.conf
   按照如下方式修改snmpd.conf文件
   (1)修改默认的community string
   com2sec notConfigUser default public
   将public修改为你才知道的字符串(也可不改)
   (2)把下面的#号去掉
   #view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
   (3)把下面的语句
   access notConfigGroup "" any noauth exact systemview none none
   改成:
   access notConfigGroup "" any noauth exact mib2 none none
7.重启snmpd服务
   #/etc/rc.d/init.d/snmpd restart
   完成snmpd的配置


8.确保linux的iptables防火墙对我们的流量监控服务器开放了udp 161端口的访问权限(为了安全起见,也可以修改161端口)
   可使用iptables –L –n 查看当前iptables规则
   可编辑/etc/sysconfig/iptables文件来修改iptables规则


9.最后可以用监控工具(如zabbix、Cacti等)获取snmp的监控数据,实现可视化展现,我们用的是Applications
Manager来监控,监控效果如下:



友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信