<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
一、
linux
主机
主要步骤:
1
、安装
snmpd
服务软件包并设置启动之。
2
、上传监控插件至被监控机
nagios/libexec
目录并授权
3
、网卡参数检测
4
、增加监控
command
5
、
nagios
服务器配置添加监控项
|
具体实施:
1
、
安装修改启动
snmpd
服务
安装:
[root@nagios nagios]# yum -y install net-snmp*
修改
vi /etc/snmp/snmp.conf
a
)更改
# sec.name source community
com2sec notConfigUser
default public
为
# sec.name source community
com2sec notConfigUser
127.0.0.1
(源
IP
)
public
(共同体名,即访问密码)
b
)更改
access notConfigGroup "" any noauth exact
systemview
none none
为
access notConfigGroup "" any noauth exact
mib2
none none
c
)
去掉该的
#
#view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
d
)启动
snmp
/etc/init.d/snmpd start
|
2
、上传插件被授权,上传
check_traffic.sh
至
/usr/local/nagios/libexec
cp /root/nagios/nagios-cn-3.2.3/sample-config/check_traffic.sh /usr/local/nagios/libexec/
改属主为:
nagios
chown nagios.nagios ./check_traffic.sh
chmod 776 /var/tmp/*
|
3
、网卡参数检测:
检查启动情况
Netstat
–
na|grep 161
测试
snmpwalk -v 1 -c public localhost system
Traffic
脚本测试,如果不知道网卡
,
命令列出
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -L
[root@localhost snmp]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -L
List Interface for host 127.0.0.1.
Interface index 1 orresponding to lo
Interface index
2
orresponding to eth0
Interface index 3 orresponding to sit0
可以测试是否能够正常采集到数据
[root@localhost snmp]# /usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w 12,30 -c 15,35 -M -b
OK - The Traffic In is 0.0Mbps, Out is 0.0Mbps, Total is 0.0Mbps. The Check Interval is 31s |In=0.0Mbps;12;15;0;0 Out=0.0Mbps;30;35;0;0 Total=0.0Mbps;42;50;0;0 Interval=31s;1200;1800;0;0
注:
-V snmp
协议版本
-C
共同体名
-I
参数对应上面
-L
输出的网卡
index
值。标示监视相应的网卡。该插件其它使用方法及各参数解释详情
”-help”
或者看上面论坛石头描述
4.
增加监控
command
修改
commands.cfg
,增加如下段
define command{
command_name check_traffic
command_line $USER1$/check_traffic.sh -V 2c -C public -H $HOSTADDRESS$ -I $ARG1$ -w $ARG2$ -c $ARG3$ -M -b
}
5
.
nagios
服务器配置添加监控项
修改
localhost.cfg
,增加如下段
############
监控流量
####################
define service{
use local-service,services-pnp ; Name of service template to use
host_name localhost
service_description check_traffic
check_command check_traffic!2!12,30!15,35
notifications_enabled 1
}
重启
nagios
,
snmpd
Service nagios restart
Service snmpd restart
转载于:https://blog.51cto.com/bensonzbs/1083258