nagios通过SNMP服务的网络监控

简介:

nagios通过SNMP服务的网络监控,当达到某个设定的值,那么就报警

http://bbotte.blog.51cto.com/6205307/1403997 nagios服务端和客户端的安装配置

http://bbotte.blog.51cto.com/6205307/1583484 Nagios结合pnp4nagios图形监控


借助于网上提供的资源,做下面的操作

https://github.com/cloved/check_traffic/releases  下载最新版本的shell脚本
下载check_traffic.sh  V1.4.0,在附件已经上传

#被监控端/客户端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
cd /usr/local/nagios/libexec/  #下载此脚本
chmod 755 check_traffic.sh
# yum install net-snmp-utils net-snmp net-snmp-libs bc -y  #因脚本里面需要用到bc
# mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
# vim /etc/snmp/snmpd.conf                                 #配置snmp服务
# cat /etc/snmp/snmpd.conf|grep -v ^\# |sed  '/^$/d'
com2sec notConfigUser  default       public
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.2.1.25.1.1
access  notConfigGroup  ""       any        noauth    exact   all  none none
view  all     included  .1                               80
view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
access notConfigGroup  ""       any        noauth    exact   all  none none
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes
  
# service snmpd start
# snmpd -L                                                  #测试snmp配置文件
Error opening specified endpoint  ""
Server Exiting with code 1
# ./check_traffic.sh -V 2c -C public -H localhost -L -vvvv  #测试本机的网口,主要的数值是index后面的数字
List Interface for host localhost.
Interface index 1 orresponding to  lo
Interface index 2 orresponding to  eth0
Interface index 3 orresponding to  eth1
  
# ./check_traffic.sh -V 2c -C public -H 127.0.0.1 -I 2 -w 2000,3000 -c 3001,5000 -K –B
OK - It is the first time of this plugins to run,  or  some  data file lost. We will get the data from the next time.
  
# ll /var/tmp/check_traffic_127.0.0.1_2__itnms.hist_dat_64   #检查权限,所属用户和组都为nagios
#此脚本有帮助说明,用-h查看,上面 -I 2 即是对eth0做监控,-w 2000,3000是流入2000K/s,或发送3000K/s会提示warning
# -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
#
# -N    interface name
#    Specify the interface name
#
# -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

#被监控端/客户端

1
2
3
vim  /usr/local/nagios/etc/nrpe .cfg
command [check_traffic]= /usr/local/nagios/libexec/check_traffic .sh -V 2c -C public -H 127.0.0.1 -I 2 -w 2000,4000 -c 4000,6000 -K -B
# service nrped restart

#监控端/服务端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
vim  /usr/local/nagios/etc/objects/linuxhost .cfg
define host{
         use                     mylinux-server,service-pnp
         host_name               192_168_23_2
         alias                    server tongji
         address                 192.168.23.2
         }
    
vim  /usr/local/nagios/etc/objects/linux13 .cfg
define service{
         use                             linux-service,service-pnp
         host_name                       192_168_1_2
         service_description             check network
         check_command                   check_nrpe!check_traffic
         }

完事把nagios重启一下,刚开始会搜集数据,如下面的提示 大概2分钟就能看到图形界面了,

PNP4Nagios Version 0.6.24
Please check the documentation for information about the following error.
XML file "/usr/local/pnp4nagios/var/perfdata/192_168_1_2/check_network.xml" not found. <a href="http://docs.pnp4nagios.org/faq/6">Read FAQ online</a>

file [line]:
application/models/data.php [312]:
back

在nagios页面会看到

wKioL1TVtKrxU-KtAAF2YWxDtcg182.jpg

wKioL1TVtSCzM_1xAAN9h1HCNAk383.jpg

此图会有in,out的网卡流量,可以在服务器ifstat验证


此外,http://nagios.manubulon.com/ 这个网站也值得一看,里面有 http://nagios.manubulon.com/check_snmp_int.pl 脚本,同样可以实现对网络的监控 










本文转自 bbotte 51CTO博客,原文链接:http://blog.51cto.com/bbotte/1612660,如需转载请自行联系原作者
目录
相关文章
|
25天前
|
存储 安全 网络安全
云端防御策略:融合云服务与网络安全的未来之路
在数字化浪潮的推动下,企业纷纷转向云计算以获取灵活性、可扩展性和成本效益。然而,随之而来的是日益复杂的网络威胁,它们挑战着传统的安全边界。本文将探讨如何通过创新的云服务模型和先进的网络安全措施来构建一个既可靠又灵活的安全框架。我们将分析云计算环境中的关键安全挑战,并提出一系列针对性的策略来加强数据保护,确保业务连续性,并满足合规要求。
28 2
|
1月前
|
弹性计算 负载均衡 网络协议
这种情况可能是由于阿里云的API服务出现了短暂的故障或者网络波动导致的
【2月更文挑战第20天】这种情况可能是由于阿里云的API服务出现了短暂的故障或者网络波动导致的
58 1
|
4月前
|
Kubernetes Ubuntu 安全
Linux|科普扫盲帖|配置网络软件源---阿里云镜像仓库服务使用(centos,Ubuntu)
Linux|科普扫盲帖|配置网络软件源---阿里云镜像仓库服务使用(centos,Ubuntu)
493 0
|
1天前
|
运维 安全 Cloud Native
安全访问服务边缘(SASE):网络新时代的安全与连接解决方案
SASE(安全访问服务边缘)是一种云基安全模型,结合了网络功能和安全策略,由Gartner在2019年提出。它强调身份驱动的私有网络、云原生架构和全面边缘支持,旨在解决传统WAN和安全方案的局限性,如高延迟和分散管理。SASE通过降低IT成本、提升安全响应和网络性能,应对数据分散、风险控制和访问速度等问题,适用于移动办公、多分支办公等场景。随着网络安全挑战的增加,SASE将在企业的数字化转型中扮演关键角色。
|
20天前
|
缓存 网络协议 数据库连接
【底层服务/编程功底系列】「网络通信体系」深入探索和分析TCP协议的运输连接管理的核心原理和技术要点
【底层服务/编程功底系列】「网络通信体系」深入探索和分析TCP协议的运输连接管理的核心原理和技术要点
20 0
|
28天前
|
存储 运维 安全
SDN 网络编排与服务
【2月更文挑战第30天】网络编排是基于业务需求,对逻辑网络服务进行有序组织和安排,通过控制器构建满足需求的网络服务。
|
29天前
|
域名解析 缓存 网络协议
探索Qt 网络编程:网络地址与服务类全解析
探索Qt 网络编程:网络地址与服务类全解析
54 0
|
1月前
|
存储 运维 安全
SDN网络编排与服务
【2月更文挑战第23天】
|
1月前
|
安全 数据库
5. 基础网络服务与应用配置
5. 基础网络服务与应用配置
23 2