nagios监控网络
2013-10-24 10:13
393 查看
1、安装修改启动snmpd服务
方法一:安装:[root@nagios nagios]# yum -y install net-snmp*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Package 1:net-snmp-devel-5.3.2.2-9.el5_5.1.i386 already
installed and latest version
Package 1:net-snmp-libs-5.3.2.2-9.el5_5.1.i386 already installed
and latest version
Package 1:net-snmp-utils-5.3.2.2-9.el5_5.1.i386 already
installed and latest version
Package 1:net-snmp-perl-5.3.2.2-9.el5_5.1.i386 already installed
and latest version
Package 1:net-snmp-5.3.2.2-9.el5_5.1.i386 already installed and
latest version
Nothing to do
#我已经安装过了。。就上面这些包了。。
方法二:
安装snmp
rpm -ivh net-snmp-5.3.2.2-9.el5.x86_64.rpm
net-snmp-devel-5.3.2.2-9.el5.i386.rpm
net-snmp-devel-5.3.2.2-9.el5.x86_64.rpm
net-snmp-libs-5.3.2.2-9.el5.x86_64.rpm
net-snmp-libs-5.3.2.2-9.el5.i386.rpm
net-snmp-perl-5.3.2.2-9.el5.x86_64.rpm
net-snmp-utils-5.3.2.2-9.el5.x86_64.rpm
beecrypt-4.1.2-10.1.1.i386.rpm
elfutils-devel-0.137-3.el5.x86_64.rpm
elfutils-devel-static-0.137-3.el5.x86_64.rpm
beecrypt-devel-4.1.2-10.1.1.i386.rpm
beecrypt-devel-4.1.2-10.1.1.x86_64.rpm
lm_sensors-devel-2.10.7-9.el5.i386.rpm
lm_sensors-devel-2.10.7-9.el5.x86_64.rpm
lm_sensors-2.10.7-9.el5.i386.rpm lm_sensors-2.10.7-9.el5.x86_64.rpm
libsysfs-2.0.0-6.i386.rpm beecrypt-4.1.2-10.1.1.i386.rpm
beecrypt-4.1.2-10.1.1.x86_64.rpm
rpm -ivh lm_sensors-2.10.7-9.el5.x86_64.rpm
rpm -ivh lm_sensors-devel-2.10.7-9.el5.x86_64.rpm
rpm -ivh net-snmp-5.3.2.2-9.el5.x86_64.rpm
rpm -ivh net-snmp-utils-5.3.2.2-9.el5.x86_64.rpm
rpm -ivh net-snmp-perl-5.3.2.2-9.el5.x86_64.rpm
service snmpd restart
修改snmpd.conf
vim /etc/snmp/snmpd.conf
# sec.name source community
com2sec notConfigUser 127.0.0.1(localhost也可不改) public(共同体名)
# group context sec.model sec.level prefix read write notif
access notConfigGroup “” any noauth exact mib2 none none
#改system为mib2
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
#去掉前面的”#”注释符
2、上传插件被授权
上传check_traffic.sh至/usr/local/nagios/libexec
改属主为:nagios
chown nagios.nagios ./check_traffic.sh
chmod +x check_traffic.sh
3、网卡参数检测:
[root@OAServer etc]# /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 bond0
Interface index 3 orresponding to eth0
Interface index 4 orresponding to eth1
Interface index 5 orresponding to sit0
可以测试是否能够正常采集到数据
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H
127.0.0.1 -I 2 -w 1200,1500 -c 1700,1800 -K -b
OK – The Traffic In is 356Kbps, Out is 414Kbps, Total is
770Kbps. The Check Interval is 30s |In=356Kbps;1200;1700;0;0
Out=414Kbps;1500;1800;0;0 Total=770Kbps;2700;3500;0;0
Interval=30s;1200;1800;0;0
注:-V snmp协议版本
-C 共同体名
-I 参数对应上面-L输出的网卡index值。标示监视相应的网卡。
该插件其它使用方法及各参数解释详情”-help”或者看上面论坛石头描述
//更改/var/tmp/check_traffic* 文件权限为nagios用户可读写。简单的给个777吧。。
//chmod 777
/var/tmp/check_traffic_127.0.0.1_2.hist_dat_root__32
4、 更改nrpe.cfg增加如下行:
command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh
-V 2c -C public -H 127.0.0.1 -I 2 -w 300,350 -c 500,600 -K -B
重启nrpe程序
[root@OAServer ~]# ps aux |grep nrpe
nagios 2822 0.0 0.0 4808 1448 ? Ss Jun01 0:04
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
root 1123 0.0 0.0 5936 736 pts/2 S+ 11:02 0:00 grep nrpe
[root@OAServer ~]# kill -9 2822
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg
-d
或service xinetd restart
---------------------------------------------------------------------------------------------------------------------
5、nagios服务器(监控端)编辑service.cfg增加监控网卡流量项目;
define service {
host_name 241-server
service_description check_traffic
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_traffic
}
参数解析:
# -v
#
Verbose mode, to debug some messages out to the /tmp directory with
log file name check_traffic.$$.
#
# -V
1|2c|3
#
Specify the version of snmp
#
# -C
Community
#
Specify the Community
#
# -H
host
#
Specify the host
#
# -6 Use 64
bit counter, ifHC* instead of if*.
#
# -r Use
Range instead of single value in warning and critical
Threshold;
#
# -I
interface
#
Specify the interface
#
# -L List all
Interfaces on specify host
#
# -B/b Switch to B/s or bps, default is -b,
bps
#
# -K/M Switch to K or M (bsp,B/s), default is
-K
#
# -w Warning
value Kbps, in and out
# -c Critical
value Kbps, in and out
#
Set Warning and Critical Traffic value
# -F
s/S
#
Simple or more simple output format
#
# -p
number
#
It is a number that we comare this time value with the average
value of previos N times we had been checked.
#
# -i
suffix
#
It's the individual suffix with the CF/STAT_HIST_DATA if
necessary.
rpm -ivh net-snmp-5.3.2.2-9.el5.x86_64.rpm
net-snmp-devel-5.3.2.2-9.el5.i386.rpm
net-snmp-devel-5.3.2.2-9.el5.x86_64.rpm
net-snmp-libs-5.3.2.2-9.el5.x86_64.rpm
net-snmp-libs-5.3.2.2-9.el5.i386.rpm
net-snmp-perl-5.3.2.2-9.el5.x86_64.rpm
net-snmp-utils-5.3.2.2-9.el5.x86_64.rpm
beecrypt-4.1.2-10.1.1.i386.rpm
elfutils-devel-0.137-3.el5.x86_64.rpm
elfutils-devel-static-0.137-3.el5.x86_64.rpm
beecrypt-devel-4.1.2-10.1.1.i386.rpm
beecrypt-devel-4.1.2-10.1.1.x86_64.rpm
lm_sensors-devel-2.10.7-9.el5.i386.rpm
lm_sensors-devel-2.10.7-9.el5.x86_64.rpm
lm_sensors-2.10.7-9.el5.i386.rpm lm_sensors-2.10.7-9.el5.x86_64.rpm
libsysfs-2.0.0-6.i386.rpm beecrypt-4.1.2-10.1.1.i386.rpm
beecrypt-4.1.2-10.1.1.x86_64.rpm
elfutils-libelf-devel-0.137-3.el5.i386.rpm
rpm-devel-4.4.2.3-18.el5.x86_64.rpm
elfutils-libelf-devel-0.137-3.el5.x86_64.rpm
elfutils-libelf-devel-0.137-3.el5.x86_64.rpm
elfutils-libelf-devel-static-0.137-3.el5.i386.rpm
elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm
nss-devel-3.12.3.99.3-1.el5.centos.2.i386.rpm
sqlite-devel-3.3.6-5.x86_64.rpm nspr-devel-4.7.6-1.el5_4.i386.rpm
elfutils-libelf-0.137-3.el5.i386.rpm
elfutils-libs-0.137-3.el5.x86_64.rpm
993 rpm -ivh
lm_sensors-2.10.7-9.el5.x86_64.rpm
994 rpm -ivh
lm_sensors-devel-2.10.7-9.el5.x86_64.rpm
995 rpm -vih
net-snmp-5.3.2.2-9.el5.x86_64.rpm
996 rpm -vih
net-snmp-utils-5.3.2.2-9.el5.x86_64.rpm
997 rpm -vih
net-snmp-perl-5.3.2.2-9.el5.x86_64.rpm
998 service snmpd restart
18618488246
18603162076
方法一:安装:[root@nagios nagios]# yum -y install net-snmp*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Package 1:net-snmp-devel-5.3.2.2-9.el5_5.1.i386 already
installed and latest version
Package 1:net-snmp-libs-5.3.2.2-9.el5_5.1.i386 already installed
and latest version
Package 1:net-snmp-utils-5.3.2.2-9.el5_5.1.i386 already
installed and latest version
Package 1:net-snmp-perl-5.3.2.2-9.el5_5.1.i386 already installed
and latest version
Package 1:net-snmp-5.3.2.2-9.el5_5.1.i386 already installed and
latest version
Nothing to do
#我已经安装过了。。就上面这些包了。。
方法二:
安装snmp
rpm -ivh net-snmp-5.3.2.2-9.el5.x86_64.rpm
net-snmp-devel-5.3.2.2-9.el5.i386.rpm
net-snmp-devel-5.3.2.2-9.el5.x86_64.rpm
net-snmp-libs-5.3.2.2-9.el5.x86_64.rpm
net-snmp-libs-5.3.2.2-9.el5.i386.rpm
net-snmp-perl-5.3.2.2-9.el5.x86_64.rpm
net-snmp-utils-5.3.2.2-9.el5.x86_64.rpm
beecrypt-4.1.2-10.1.1.i386.rpm
elfutils-devel-0.137-3.el5.x86_64.rpm
elfutils-devel-static-0.137-3.el5.x86_64.rpm
beecrypt-devel-4.1.2-10.1.1.i386.rpm
beecrypt-devel-4.1.2-10.1.1.x86_64.rpm
lm_sensors-devel-2.10.7-9.el5.i386.rpm
lm_sensors-devel-2.10.7-9.el5.x86_64.rpm
lm_sensors-2.10.7-9.el5.i386.rpm lm_sensors-2.10.7-9.el5.x86_64.rpm
libsysfs-2.0.0-6.i386.rpm beecrypt-4.1.2-10.1.1.i386.rpm
beecrypt-4.1.2-10.1.1.x86_64.rpm
rpm -ivh lm_sensors-2.10.7-9.el5.x86_64.rpm
rpm -ivh lm_sensors-devel-2.10.7-9.el5.x86_64.rpm
rpm -ivh net-snmp-5.3.2.2-9.el5.x86_64.rpm
rpm -ivh net-snmp-utils-5.3.2.2-9.el5.x86_64.rpm
rpm -ivh net-snmp-perl-5.3.2.2-9.el5.x86_64.rpm
service snmpd restart
修改snmpd.conf
vim /etc/snmp/snmpd.conf
# sec.name source community
com2sec notConfigUser 127.0.0.1(localhost也可不改) public(共同体名)
# group context sec.model sec.level prefix read write notif
access notConfigGroup “” any noauth exact mib2 none none
#改system为mib2
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
#去掉前面的”#”注释符
2、上传插件被授权
上传check_traffic.sh至/usr/local/nagios/libexec
改属主为:nagios
chown nagios.nagios ./check_traffic.sh
chmod +x check_traffic.sh
3、网卡参数检测:
[root@OAServer etc]# /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 bond0
Interface index 3 orresponding to eth0
Interface index 4 orresponding to eth1
Interface index 5 orresponding to sit0
可以测试是否能够正常采集到数据
/usr/local/nagios/libexec/check_traffic.sh -V 2c -C public -H
127.0.0.1 -I 2 -w 1200,1500 -c 1700,1800 -K -b
OK – The Traffic In is 356Kbps, Out is 414Kbps, Total is
770Kbps. The Check Interval is 30s |In=356Kbps;1200;1700;0;0
Out=414Kbps;1500;1800;0;0 Total=770Kbps;2700;3500;0;0
Interval=30s;1200;1800;0;0
注:-V snmp协议版本
-C 共同体名
-I 参数对应上面-L输出的网卡index值。标示监视相应的网卡。
该插件其它使用方法及各参数解释详情”-help”或者看上面论坛石头描述
//更改/var/tmp/check_traffic* 文件权限为nagios用户可读写。简单的给个777吧。。
//chmod 777
/var/tmp/check_traffic_127.0.0.1_2.hist_dat_root__32
4、 更改nrpe.cfg增加如下行:
command[check_traffic]=/usr/local/nagios/libexec/check_traffic.sh
-V 2c -C public -H 127.0.0.1 -I 2 -w 300,350 -c 500,600 -K -B
重启nrpe程序
[root@OAServer ~]# ps aux |grep nrpe
nagios 2822 0.0 0.0 4808 1448 ? Ss Jun01 0:04
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
root 1123 0.0 0.0 5936 736 pts/2 S+ 11:02 0:00 grep nrpe
[root@OAServer ~]# kill -9 2822
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg
-d
或service xinetd restart
---------------------------------------------------------------------------------------------------------------------
5、nagios服务器(监控端)编辑service.cfg增加监控网卡流量项目;
define service {
host_name 241-server
service_description check_traffic
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_traffic
}
参数解析:
# -v
#
Verbose mode, to debug some messages out to the /tmp directory with
log file name check_traffic.$$.
#
# -V
1|2c|3
#
Specify the version of snmp
#
# -C
Community
#
Specify the Community
#
# -H
host
#
Specify the host
#
# -6 Use 64
bit counter, ifHC* instead of if*.
#
# -r Use
Range instead of single value in warning and critical
Threshold;
#
# -I
interface
#
Specify the interface
#
# -L List all
Interfaces on specify host
#
# -B/b Switch to B/s or bps, default is -b,
bps
#
# -K/M Switch to K or M (bsp,B/s), default is
-K
#
# -w Warning
value Kbps, in and out
# -c Critical
value Kbps, in and out
#
Set Warning and Critical Traffic value
# -F
s/S
#
Simple or more simple output format
#
# -p
number
#
It is a number that we comare this time value with the average
value of previos N times we had been checked.
#
# -i
suffix
#
It's the individual suffix with the CF/STAT_HIST_DATA if
necessary.
rpm -ivh net-snmp-5.3.2.2-9.el5.x86_64.rpm
net-snmp-devel-5.3.2.2-9.el5.i386.rpm
net-snmp-devel-5.3.2.2-9.el5.x86_64.rpm
net-snmp-libs-5.3.2.2-9.el5.x86_64.rpm
net-snmp-libs-5.3.2.2-9.el5.i386.rpm
net-snmp-perl-5.3.2.2-9.el5.x86_64.rpm
net-snmp-utils-5.3.2.2-9.el5.x86_64.rpm
beecrypt-4.1.2-10.1.1.i386.rpm
elfutils-devel-0.137-3.el5.x86_64.rpm
elfutils-devel-static-0.137-3.el5.x86_64.rpm
beecrypt-devel-4.1.2-10.1.1.i386.rpm
beecrypt-devel-4.1.2-10.1.1.x86_64.rpm
lm_sensors-devel-2.10.7-9.el5.i386.rpm
lm_sensors-devel-2.10.7-9.el5.x86_64.rpm
lm_sensors-2.10.7-9.el5.i386.rpm lm_sensors-2.10.7-9.el5.x86_64.rpm
libsysfs-2.0.0-6.i386.rpm beecrypt-4.1.2-10.1.1.i386.rpm
beecrypt-4.1.2-10.1.1.x86_64.rpm
elfutils-libelf-devel-0.137-3.el5.i386.rpm
rpm-devel-4.4.2.3-18.el5.x86_64.rpm
elfutils-libelf-devel-0.137-3.el5.x86_64.rpm
elfutils-libelf-devel-0.137-3.el5.x86_64.rpm
elfutils-libelf-devel-static-0.137-3.el5.i386.rpm
elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm
nss-devel-3.12.3.99.3-1.el5.centos.2.i386.rpm
sqlite-devel-3.3.6-5.x86_64.rpm nspr-devel-4.7.6-1.el5_4.i386.rpm
elfutils-libelf-0.137-3.el5.i386.rpm
elfutils-libs-0.137-3.el5.x86_64.rpm
993 rpm -ivh
lm_sensors-2.10.7-9.el5.x86_64.rpm
994 rpm -ivh
lm_sensors-devel-2.10.7-9.el5.x86_64.rpm
995 rpm -vih
net-snmp-5.3.2.2-9.el5.x86_64.rpm
996 rpm -vih
net-snmp-utils-5.3.2.2-9.el5.x86_64.rpm
997 rpm -vih
net-snmp-perl-5.3.2.2-9.el5.x86_64.rpm
998 service snmpd restart
18618488246
18603162076
相关文章推荐
- 网络主机监控-nagios应用漫谈(三)
- cacti+nagios+ntop网络系统监控
- 网络主机监控-nagios应用漫谈(四)
- Linux服务器上监控网络带宽的18个常用命令nload, iftop,iptraf-ng, nethogs, vnstat. nagios
- 我的Nagios的艰辛.....网络监控之神(一)
- Nginx1.0.11+PHP5.2.17+nagios配置网络监控
- 网络主机监控-nagios应用漫谈(五)
- Linux服务器上监控网络带宽的18个常用命令nload, iftop,iptraf-ng, nethogs, vnstat. nagios
- Wikipedia网络的服务监控 Nagios
- XAMPP+Cacti+Nagios+Ntop实现网络监控
- 网络主机监控-nagios应用漫谈(六)
- nagios和cacti部署在同一台监控机上,是否会造成网络堵塞?
- 网络主机监控-nagios应用漫谈(七)
- 网络监控软件Nagios, Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设备,打印机等。在系统或服务状态异常时发出邮件或短信报
- nagios 网络监控 实现飞信报警
- 使用NAGIOS监控网络、系统及服务
- 网络主机监控-nagios应用漫谈(八)
- Nagios监控网络流量
- Nagios:中大型网络服务器监控软件
- 整合nagios+cacti+微信、飞信实现网络监控系统报警