监控和被监控端都要安装和配置snmp

[root@HE1bin]# yum install net-snmp*

[root@HE1bin]# vi /etc/snmp/snmpd.conf

41default均改为监控服务器ip;团体名被监控机监控机一致,示例如下:

com2secnotConfigUser  192.168.1.250       ikongjian

 

62systemview改为all,供所有snmp访问权限 

access  notConfigGroup ""      any      noauth    exact  all none none

 

85#注释符号去掉

 viewall    included  .1                               80

 

修改snmp级别以减少日志输出

[root@HE1 home]# vi /etc/init.d/snmpd

#OPTIONS="-LS0-6d-Lf /dev/null -p /var/run/snmpd.pid"

OPTIONS="-LS 4 d -p /var/run/snmpd.pid -a"

 

 

 

[root@HE1bin]# /etc/init.d/snmpd restart

Stoppingsnmpd:                                           [  OK  ]

Startingsnmpd:                                           [  OK  ]

 

 

验证snmp服务

[root@HE1 bin]# ps-ef | grep 'snmpd'

root     26100    1  0 11:20 ?        00:00:00 /usr/sbin/snmpd -LS 4 d -p/var/run/snmpd.pid -a

root     26114 25540  0 11:30 pts/0    00:00:00 grep snmpd

 

监控机修改lepus配置文件添加44,45,46行内容

[root@HE3lepus]# vi /usr/local/lepus/check_os.sh 

43行后添加44,45,46行内容

     40    mem_buffered=`/usr/bin/snmpwalk -v1 -c ${community}  ${ip} UCD-SNMP-MIB::memBuffer.0 |cut -d= -f2 |awk -F ' ' '{print $2}'`

     41    mem_cached=`/usr/bin/snmpwalk -v1 -c ${community}  ${ip} UCD-SNMP-MIB::memCached.0 |cut -d= -f2 |awk -F ' ' '{print $2}'`

     42    mem_usage_rate=`/usr/bin/snmpdf -v1 -c ${community}  ${ip} |grep "Physical"|awk '{print $6}'`

     43    mem_available=$[$mem_free+$mem_buffered+$mem_cached]

     44  if [ -z $mem_shared ]; then

     45          mem_shared=0

     46           fi

[root@HE3 lepus]#python check_os.py

 

 

开始图形化界面添加主机

wKiom1csHx7SlPkzAASc50lDwvE786.jpg


 

wKiom1csH56ThepQAARbTV8Cn1o578.jpg

wKiom1csH6KiAO6_AASqlSByv0w431.jpg

 



本文出自 “岁伏” 博客,请务必保留此出处http://suifu.blog.51cto.com/9167728/1770703

posted on 2016-08-19 17:14  岁伏  阅读(715)  评论(0编辑  收藏  举报