nagios监控之CheckEventLog

合集下载

Nagios监控路由器和交换机设备

Nagios监控路由器和交换机设备

Nagios监控路由器和交换机设备1.功能介绍Nagios可以监控有IP可管理的交换机和路由器的设备状态.对小型无管理功能的交换机和HUB是无法监控.监控的方式是通过外部的ping所反馈的信息或者通过SNMP协议来获取相关的状态信息.能够在网络设备上获取的信息包括:包丢失率,包往返时间平均值SNMP状态信息带宽和传输数率2.概述监控的方式有两种一种是利用ping的方式,获取数据包的响应时间和丢包率另一种是利用网络设备的SNMP数据,通过check_snmp获取端口状态和check_mrtgtraf来了解带宽状况.在使用check_snmp之前必须安装snmp包到系统中.如果没有安装则需要先安装好snmp系统包,然后再重新编译nagios plugins3.配置步骤完成第一次执行需要做的操作创建新的监控设备主机和服务对象重新启动Nagios4.确认一下内容在/usr/local/nagios/etc/objects/commands.cfg里面是否包含了check_snmp和check_local_mrt gtraf的命令定义在/usr/local/nagios/etc/objects/templates.cfg里面是否包含了generic-switch5.配置Nagiosa.编辑/usr/local/nagios/etc/nagios.cfg将#cfg_file=/usr/local/nagios/etc/objects/switch.cfg前面的#去掉b.编辑/usr/local/nagios/etc/object/switch.cfg文件设定监控主机的相关内容define host{use generic-switch ; Inherit default values from a templatehost_name Gateway ; The name we're giving to this switchalias Firewall ; A longer name associated with the switchaddress 192.168.200.1 ; IP address of the switchhostgroups allhosts,switches ; Host groups this switch is associated with}监控包的丢失率和RTA响应时间define service{use generic-service ; Inherit values from a templatehost_name Gateway ; The name of the host the service is associated withservice_description PING; The service descriptioncheck_command check_ping!200.0,20%!600.0,60% ;在超过200ms或丢包率在20%上的启动警告,超过600ms或丢包达到60%的启动报警normal_check_interval 5; 在正常情况下,每五分钟监控一次retry_check_interval 1; 在异常情况下,每分钟监控一次}利用SNMP监控交换和网关设备define service{use generic-service ; Inherit values from a templatehost_name Gatewayservice_description Uptimecheck_command check_snmp!-C public -o sysUpTime.0}利用MRTG来监控网络流量信息define service{use generic-service ; Inherit values from a templatehost_name Gatewayservice_description Port 1 Bandwidth Usagecheck_commandcheck_local_mrtgtraf!/var/lib/mrtg/192.168.200.1_1.log!AVG!1000000,2000000!5000000,5000000!10 }利用command里面设定的check_local_mrtgtraf获取本地保存的mrt g流量日志信息来监控,获取文件是/var/lib/mrt g/192.168.200.1_1.log获取数据值是采取AVG的值,数值在1M~2M之间,则状态改为warning,如果超过5M的话则状态改为critical 完成配置后service nagios restart。

Nagios监控mysql的安装配置及报警

Nagios监控mysql的安装配置及报警

一:Nagios的安装1.安装编译所需的软件包;[root@nagios ~]#yum –y install httpd php-* gd-* mysql-devel[root@nagios ~]#setenforce 0 #关闭selinux[root@nagios ~]#sed 's/=enforcing/=permissive/' /etc/sysconfig/selinux2.创建运行nagios服务的用户;[root@nagios ~]#useradd nagios#创建运行nagios服务的用户[root@nagios ~]#usermod –G nagios apache#使apache用户对nagios目录具有写权限,不然web页面操作失败3.Nagios软件安装;[root@nagios ~]#tar zxf nagios-cn-3.2.3.tar.gz#释放nagios源码包[root@nagios ~]#cd nagios-cn-3.2.3Ps: 若在RHEL6X32位系统中安装nagios-cn-3.2.3.tar.bz2要先执行make clean操作,然后再执行./configure和make all等操作,否则执行make all时会报错![root@nagios nagios-cn-3.2.3]#./configure --enable-embedded-perl#编译nagios[root@nagios nagios-cn-3.2.3]#make all[root@nagios nagios-cn-3.2.3]#make install#安装主程序,CGI和HTML文件[root@nagios nagios-cn-3.2.3]#make install-init#在/etc/rc.d/init.d安装启动脚本[root@nagios nagios-cn-3.2.3]#make install-commandmode#配置目录权限[root@nagios nagios-cn-3.2.3]#make install-config#安装示例配置文件[root@nagios nagios-cn-3.2.3]#make install-webconf#安装nagios的web接口,会在/etc/httpd/conf.d目录中创建nagios.conf文件4.安装Nagios-plugins插件;[root@nagios ~]#tar zxf nagios-plugins-1.4.15.tar.gz[root@nagios ~]#cd nagios-plugins-1.4.15[root@nagios nagios-plugins-1.4.15]#./configure –with-nagios-user=nagios \--with-nagios-group=nagios –enable-extra-opts \--enable-libtap --enable-perl-modules [root@nagios nagios-plugins-1.4.15]#make && make install(Ps:会在”/usr/local/nagios/libexec”目录下多出一些文件,这里存放nagios所有插件)5.修改nagios的主配置文件nagios.cfg;[root@nagios ~]#vim /usr/local/nagios/etc/nagios.cfg新建cfg_file=/usr/local/nagios/etc/objects/hosts.cfg#存放主机与主机组定义cfg_file=/usr/local/nagios/etc/objects/services.cfg#存放服务与服务组定义修改#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg #加”#”注释,在36行6.创建hosts.cfg文件;[root@nagios ~]#vim /usr/local/nagios/etc/objects/hosts.cfgdefine host{use linux-server#定义使用的模版host_name nagios#被监控主机名称alias nagios #别名address 127.0.0.1 #被监控主机的IP地址icon_image web.gifstatusmap_image web.gd22d_coords 100,3003d_coords 100,300,100check_command check-host-alive#监控命令,来自commands.cfg文件max_check_attempts 5#检查失败后重试的次数check_period 24x7#查看的时间段,来自timeperiods.cfg定义contact_groups admins#联系人组,在contactgroups.cfg中定义的notification_interval 10#提醒的间隔,每隔10分钟提醒一次notification_period 24x7#提醒的周期,24x7,来自timeperiods.cfg定义notification_options d,u,r #指定什么情况下提醒}define hostgroup{hostgroup_name linux-serversalias linux servermembers *}7.创建services.cfg文件;[root@nagios ~]#vim /usr/local/nagios/etc/objects/services.cfgdefine service {use local-servicehost_name nagiosservice_groups systemcheckservice_description 主机存活check_command check-host-alive}define service {use local-servicehost_name nagiosservice_groups systemcheckservice_description 登录用户数check_command check_local_users!20!50#监测远程主机当前的登录用户数量,如果大于20用户则报warning,如果大于50则报critical}define service {use local-servicehost_name nagiosservice_groups systemcheckservice_description 根分区使用率check_command check_local_disk!20%!10%!/#如果可用空间低于20%会报Warning,如果可用空间低于10%则报Critical}define service {use local-servicehost_name nagiosservice_groups systemcheckservice_description 进程总数check_command check_local_procs!250!400!RSZDT#监测远程主机当前的进程总数,如果大于250进程则报warning,如果大于400进程则报critical,S(休眠)、R(运行)、Z(僵死)、D (不可中断)、T (停止)}define service {use local-servicehost_name nagiosservice_groups systemcheckservice_description CPU负载check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0#当1分钟多于5个进程等待,5分钟多于4个,15分钟多于3个则为warning状态#当1分钟多于10个进程等待,5分钟多于6个,15分钟多于4个则为critical状态}define service {use local-servicehost_name nagiosservice_groups systemcheckservice_description 交换空间利用率check_command check_local_swap!20%!10%#如果交换空间低于20%会报Warning,如果可用空间低于10%则报Critical}define servicegroup {servicegroup_name systemcheckalias systemcheck}[root@nagios ~]#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg#校验nagios配置文件的正确性[root@nagios ~]#htpasswd –c /usr/local/nagios/etc/ers nagiosadmin#添加一个访问nagios页面的授权用户,默认用户是nagiosadmin,创建其他用户修改/usr/local/nagios/etc/cgi.cfg文件:方法一:修改use_authentication=0 值为0 (在78行)方法二:authorized_for_system_information=nagiosadminauthorized_for_configuration_information=nagiosadminauthorized_for_system_commands=nagiosadminauthorized_for_all_services=nagiosadminauthorized_for_all_hosts=nagiosadminauthorized_for_all_service_commands=nagiosadminauthorized_for_all_host_commands=nagiosadmin(用:%s/nagiosadmin/新用户名命令替换所有nagiosadmin字符)8.启动httpd和nagios服务并设置开机自动启动[root@nagios ~]#service iptables stop[root@nagios ~]#service nagios start[root@nagios ~]#service httpd start[root@nagios ~]#chkconfig httpd on[root@nagios ~]#chkconfig nagios on[root@nagios ~]#chkconfig iptables off(Ps:如果开启了selinux需要配置如下两步:chcon -R –t httpd_sys_content_t /usr/local/nagios/sbin/chcon -R –t httpd_sys-content_t /usr/local/nagios/share/ )二:被监控端安装(以mysql为例,监控mysql服务的运行情况)1.安装并启动mysql的服务[root@mysql ~]#yum –y install mysql-server[root@mysql ~]#service mysqld start[root@mysql ~]#service iptables stop[root@mysql ~]#chkconfig mysqld on[root@mysql ~]#chkconfig iptables off2.在mysql服务器上创建监控检测帐户[root@mysql ~]#mysqlmysql> create database nagdb;mysql> grant select on nagdb.* to nagdb@’监控主机IP’;mysql> flush privileges;mysql>exit3.在nagis主机上检测是否可以链接mysql主机上的mysql服务[root@nagios ~]#/usr/local/nagios/libexec/check_mysql –H 被监控端IP–u nagdb –d nagdb 4.在nagios主机上添加对msyql服务监控的定义[root@nagios ~]#vim /usr/local/nagios/etc/objects/hosts.cfgdefine host{use linux-serverhost_name mysqlhostalias mysqlserveraddress 被监控端主机IPicon_image server.gifstatusmap_image server.gd22d_coords 100,3003d_coords 100,300,100check_command check-host-alivemax_check_attempts 5check_period 24x7contact_group adminsnotification_interval 10notification_period 24x7notification_options d,u,r}[root@nagios ~]#vim /usr/local/nagios/etc/objects/services.cfgdefine service {use local-servicehost_name mysqlhostservice_groups mysqlgroupservice_description mysqlservicecheck_command check_mysqlcontact_groups adminsnotification_interval 10notification_period 24x7notification_options w,u,r,c}define servicegroup {servicegroup_name mysqlgroupalias mysqlservices}[root@nagios ~]#vim /usr/local/nagios/etc/objects/commands.cfgdefine command{command_name check_mysqlcommand_line $USER1$/check_mysql -H $HOSTADDRESS$ -u nagdb -d nagdb }[root@nagios ~]#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg#检测无误后重新加载nagios服务[root@nagios ~]#service nagios reload三:Nagios通过NRPE监控远程主机系统状况(以mysql主机为例)1.在被监控端安装nagios-plugins和nrpe[root@mysql ~]#useradd nagios[root@mysql ~]#tar zxf nagios-plugins-1.4.15.tar.gz[root@mysql ~]#cd nagios-plugins-1.4.15[root@mysql nagios-plugins-1.4.15]#./configure --with-nagios-user=nagios \--with-nagios-group=nagios[root@mysql nagios-plugins-1.4.15]#make && make install[root@mysql nagios-plugins-1.4.15]#cd[root@mysql ~]#yum –y install xinetd[root@mysql ~]#tar zxf nrpe-2.12.tar.gz[root@mysql ~]#cd nrpe-2.12[root@mysql nrpe-2.12]#./configure[root@mysql nrpe-2.12]#make all[root@mysql nrpe-2.12]#make install-plugin[root@mysql nrpe-2.12]#make install-daemon#安装守护进程[root@mysql nrpe-2.12]#make install-daemon-config#安装配置文件[root@mysql nrpe-2.12]#make install-xinetd#安装xinetd脚本2.配置nrpe,添加nrpe服务[root@mysql ~]#vim /etc/xinetd.d/nrpe修改only_from = 127.0.0.1 监控主机IP#在后面增加监控主机(即nagios服务器)的地址,以空格间隔[root@mysql ~]#vim /etc/services添加nrpe 5666/tcp #nrpe#nrpe服务监听端口[root@mysql ~]#vim /usr/local/nagios/etc/nrpe.cfg修改command[check_disk]=/usr/local/nagios/libexec/check_disk –w 20% -c 10% -p / #在234行,将#注释去掉并修改,’/’表示根分区检测[root@mysql ~]#service xinetd restart[root@mysql ~]#netstat –at | grep nrpe[root@mysql ~]#netstat –an | grep 5666#重启xinetd服务,并查看NRPE是否已经启动3.监控主机的设置[root@nagios ~]#tar zxf nrpe-2.12.tar.gz[root@nagios ~]#cd nrpe-2.12[root@nagios nrpe-2.12]#./configure \--with-nagios-user=nagios --with-nagios-group=nagios[root@nagios nrpe-2.12]#make all && make install-plugin[root@nagios ~]#/usr/local/nagios/libexec/check_nrpe –H 被监控端IP#如输出NRPE v2.12说明连接正常[root@nagios ~]#vim /usr/local/nagios/etc/objects/command.cfgdefine command{command_name check_nrpe#定义命令名称为check_nrpe,在services.cfg中要使用这个名称command_line $USER1$/check_nrpe –H $HOSTADDRESS$ -c $ARG1$ #用$USER1$代替/usr/local/nagios/libexec,后面带的$ARG1$参数是传给nrpe daemon执行的检测命令}[root@mysql ~]#vim /usr/local/nagios/etc/nrpe.cfg#监控mysql主机的SWAP分区command[check_swap]=/usr/local/nagios/libexec/check_swap –w 20% -c 10% [root@mysql ~]#service xinetd reload[root@nagios ~]#cd /usr/local/nagios/libexec[root@nagios libexec]#./check_nrpe –H 被监控端主机IP -c check_swap[root@nagios ~]#vim /usr/local/nagios/etc/objects/services.cfgdefine service {use local-servicehost_name mysqlhostservice_groups mysqlgroupservice_description SWAP分区check_command check_nrpe!check_swapcontact_groups adminsnotification_interval 10notification_period 24x7notification_options w,u,r,c}define service {use local-servicehost_name mysqlhostservice_groups mysqlgroupservice_description CPU负载check_command check_nrpe!check_loadcontact_groups adminsnotification_interval 10notification_period 24x7notification_options w,u,r,c}define service {use local-servicehost_name mysqlhostservice_groups mysqlgroupservice_description 登录用户数check_command check_nrpe!check_userscontact_groups adminsnotification_interval 10notification_period 24x7notification_options w,u,r,c}define service {use local-servicehost_name mysqlhostservice_groups mysqlgroupservice_description 磁盘剩余空间check_command check_nrpe!check_diskcontact_groups adminsnotification_interval 10notification_period 24x7notification_options w,u,r,c}define service {use local-servicehost_name mysqlhostservice_groups mysqlgroupservice_description 总进程check_command check_nrpe!check_total_procscontact_groups adminsnotification_interval 10notification_period 24x7notification_options w,u,r,c}define service {use local-servicehost_name mysqlhostservice_groups mysqlgroupservice_description 僵尸进程check_command check_nrpe!check_zombie_procscontact_groups adminsnotification_interval 10notification_period 24x7notification_options w,u,r,c}define service{use generic-servicehost_name mysqlhostservice_description SWAPcheck_command check_nrpe!check_swap}[root@nagios ~]#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg [root@nagios ~]#service nagios reload四:通过邮件报警!1.配置nagios邮箱报警功能[root@nagios ~]#vim /usr/local/nagios/etc/object/contacts.cfgdefine contact{contact_name nagiosadminalias Nagios Adminservice_notification_period 24x7host_notification_period 24x7service_notification_options w,u,c,rhost_notification_options d,u,rservice_notification_commands notify-service-by-emailhost_notification_commands notify-host-by-emailemail 1009864@#多个管理员邮箱地址使用空格或者逗号隔开}2.配置邮件服务器(这里以postfix介绍)[root@nagios ~]#yum –y install postfix* httpd* dovecot* [root@nagios ~]#hostname [root@nagios ~]#vim /etc/postfix/main.cf修改myhostname = #在75行mydomain = #在83行myorigin = $myhostname #在98行myorigin = $mydomain #在99行inet_interfaces = all #在113行mydestination = $myhostname, $mydomain #在164行[root@nagios ~]#service sendmail stop[root@nagios ~]#service postfix start[root@nagios ~]#netstat –an | grep 25[root@nagios ~]#service dovecot restart[root@nagios ~]#postmap /etc/postfix/virtual。

nagios流程分析

nagios流程分析

nagios流程分析在大部分环境中,nagios是不需要优化的,一来监控这个东西大家都不觉得很重要,二来n agios本身已经是个很轻量级的软件,架构比较合理,三来现在的机器配置都很恐怖,一台普通的pc机撑起上千台host,上三四千service的监控那是小菜一碟,实际环境中有这么大量监控需求的地方本来就不多,就算有这么大量监控需求的公司,用nagios的并不多数吧!但是某些情况下,还是偶尔碰到需要优化的情况。

我需要监控的机器数量就超过了1000台,而且用的nagios,用了被动检查的架构以后,撑起这么多的监控本来是没有问题,但是上周的时候,做nagios和ndotuils的集成就出现了性能瓶颈,凌晨5点左右,把ndotuils架到两台nagios上之后,应用启动什么的都正常,但是到了上午8点就发现了问题,看到检查结果的last_check时间从7:20到8:20不等,而且是均匀分布,没有办法,只好把ndo mod关掉,到了上午10点左右,就恢复正常了。

既然nagios出现了瓶颈,就不妨拿源码来看一下,配置文件的选项优化,在nagios的文档里说了很多,但是还是感觉不是很直观,分析源码,只是属于个人兴趣,这里把流程跟大家分享一下,至于优化方案,还是需要大家多多指点了。

一、nagios在启动以后,载入成daemon,整个的步骤如下:1、读入配置文件(read_main_config_file)2、初始化event_broker3、载入所有broker_mod(ndomod包括在这里面)4、读入object信息(包括service,host,servicegroup,hostgroup,contact,contactgr oup等等)5、告诉broker,我启动了6、初始化daemon(例行工作,fork进程,修改根目录,设置信号量等等)7、打开cmd文件(nagios.cmd)8、初始化status数据(status.dat)9、读取保存数据(retention.dat)10、读取注释数据11、读取downtime数据12、读取性能数据13、初始化event_timing循环14、初始化check_stats15、生成status.dat(空的,不写数据)16、传输event_loop_start信息到broker(ndo:获取scheduling_info中数据)17、开始event_execution_loop,检查数据,直到捕获重启或者关闭信号如果接到了重启或者关闭的信号,则继续往下执行18、通知broker_mod,我要关闭了,或者我要重启了19、保存retention文件20、清理性能数据21、清理downtime数据22、清理注释数据23、如果是关闭信号,清理status.dat24、如果是关闭信号,删除cmd文件步骤比较简单,其中比较重要的有两个,一个是13,初始化循环,另一个就是17,nagios 在作为daemon运行的过程中,就是在不断的执行这个循环。

nagios监控端安装配置手册

nagios监控端安装配置手册

一、系统环境与软件版本情况本文档使用被监控机的操作系统为rhel6.3 _64位。

监控主机操作系统为rhel6.0 _64位及windows 2003,nagios主服务版本Nagios® Core™ 3.2.3,linu被监控机与主监控通信插件NRPE版本为nrpe-2.8.1。

window被监控机与主监控服务软件为NSClient++-0.2.7所使用的软件如下nrpe-2.8.1.tar.gzNSClient++-0.2.7.zip二、安装配置过程。

因为系统安装大家都非常熟悉了此次略过操作系统安装过程,首先是linux环境下被监控机的安装配置过程。

在安装之前先写个nagios监控非本地信息的原理图主监控机被监控机NRPE总共由两部分组成:–check_nrpe 插件,位于在监控主机上–NRPE daemon,运行在远程的linux主机上(通常就是被监控机)按照上图,整个的监控过程如下:当nagios需要监控某个远程linux主机的服务或者资源情况时1.nagios会运行check_nrpe这个插件,告诉它要检查什么.2.check_nrpe插件会连接到远程的NRPE daemon,所用的方式是SSL3.NRPE daemon会运行相应的nagios插件来执行检查4.NRPE daemon将检查的结果返回给check_nrpe插件,插件将其递交给nagios做处理.注意:NRPE daemon需要nagios插件安装在远程的linux主机上,否则,daemon不能做任何的监控.因为使用rehl线上的yum源安装需要授权,所以先使用iso搭个本地的yum源。

mount /dev/cdrom /mnt/cdrom/ 挂载光驱mkdir /home/rehliso 创建yum源目录。

cp -Rf /mnt/cdrom/* /home/rehliso/ 拷贝安装文件到源目录cd /etc/yum.repos.d/ 切换至yum配置文件目录cp rhel-source.repo rhel-source.repo.bak 备份配置文件vi rhel-source.repo 编辑配置文件,删除之前内容加入[rhel_6_iso]name=local isobaseurl=file:///home/rehlisogpgcheck=1gpgkey=file:///home/rehliso/RPM-GPG-KEY-redhat-release保存退出Yum clean all清除YUM缓存因为是用二进制安装包进行安装所以要先安装gcc编译器yum -y install gcc 安装gcc编译器安装完成后用sftp上传安装文件nrpe-2.8.1.tar.gz, nagios-plugins-1.4.13.tar.gz至/usr/local/src/目录下创建nagios用户Userad nagiosPasswd nagiosCd /usr/local/src 切换至/usr/local/src/目录解压安装包tar zxvf nagios-plugins-1.4.13.tar.gzcd nagios-plugins-1.4.13编译安装./configuremakemake install这一步完成后会在/usr/local/nagios/下生成两个目录libexec和share修改目录权限把权限所属chown nagios.nagios /usr/local/nagios/chown -R nagios.nagios /usr/local/nagios/libexec/至此被监控机nagios插件已经安装完成,接下来就是安装nrpe服务了切换至软件包目录Cd /usr/local/src解压安装文件tar zxvf nrpe-2.8.1.tar.gzcd nrpe-2.8.1编译安装./configurechecking for SSL... configure: error: Cannot find ssl libraries 出现了该错误主要是因为监控主机插件check_nrpe与被监控nrpe服务的通信是通过ssl方式连接的所以必须安装sslyum -y install openssl-devel 所以这个可以在gcc安装时顺便也安装了ssl安装完成后重新./configure*** Configuration summary for nrpe 2.8.1 05-10-2007 ***:General Options:-------------------------NRPE port: 5666NRPE user: nagiosNRPE group: nagiosNagios user: nagiosNagios group: nagiosReview the options above for accuracy. If they look okay,type 'make all' to compile the NRPE daemon and client.成功后会出现以上安装的基本信息接下来编译安装make allmake install-daemonmake install-daemon-configmake install-plugin 安装check_nrpe这个插件之前说过监控机需要安装check_nrpe这个插件,被监控机并不需要,我们在这里安装它是为了测试的目的安装xinetd脚本make install-xinetd这里还要补充一下因为官网的安装文档是将NRPE deamon作为xinetd下的一个服务运行的.在这样的情况下xinetd就必须要先安装好,所以还得确定系统是否已经安装了xinetd的服务[root@localhost nrpe-2.8.1]# service xinetd restartxinetd: unrecognized service服务并未安装yum -y install xinetd 安装xinetd服务安装完成后修改配置文件vi /etc/xinetd.d/nrpeservice nrpe{flags = REUSEsocket_type = streamport = 5666 端口wait = nouser = nagios 用户group = nagios 用户组server = /usr/local/nagios/bin/nrpeserver_args = -c /usr/local/nagios/etc/nrpe.cfg --inetdlog_on_failure += USERIDdisable = noonly_from = 127.0.0.1,192.168.1.243}only_from = 127.0.0.1,192.168.1.243在后面增加监控主机的地址192.168.1.243以空格间隔编辑/etc/services文件,增加NRPE服务端口添加如下信息nrpe 5666/tcp #nrpe查看防火墙是否启动chkconfig iptables –list如果启动需要添加5666端口的开放规则vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT添加该条目service iptables restart 重启iptables服务重启xinetd服务service xinetd restart检查服务端口状态[root@localhost ~]# netstat -natp |grep 5666tcp 0 0 :::5666 :::* LISTEN 1959/xinetd 服务端口已经启动测试NRPE是否则正常工作之前我们在安装了check_nrpe这个插件用于测试,现在就是用的时候.执行[root@localhost ~]# /usr/local/nagios/libexec/check_nrpe -H localhostNRPE v2.8.1返回了版本信息说明nrpe已经正常的工作了。

Nagios监控Linux主机(NRPE安装与应用)

Nagios监控Linux主机(NRPE安装与应用)

Nagios监控Linux主机(NRPE安装与应用)一、NRPE简介及工作原理NRPE是nagios的一个扩展,它被用于被监控的服务器上,向nagios监控平台提供该服务器的一些本地的情况。

例如,cpu负载、内存使用、硬盘使用等等。

NRPE可以称为nagios 的for linux 客户端。

NRPE 由两个部分组成:工作在监控机一侧的check_nrpe 插件、工作在被监控机一侧的NRPE 守护进程。

Nagios 服务器执行check_nrpe 插件并告诉他检查哪个服务,check_nrpe 插件通过SSL 连接方式联系远程服务器上的NRPE 守护进程,NRPE 守护进程执行相应的插件完成指定的检查,并返回结果。

工作原理是:插件nrpe在被监控机上开启一个daemon,通过这个daemon来和监控主机建立一条ssl加密通道,通过这条通道来传送被监控机的本地信息,达到监控的目的。

装在被监控机上的daemon就相当于一个nagios的传递员,命令行从nagios监控主机发出,然后daemon接受到信息,就会执行这条命令行,执行的方式,其实是和nagios主机是一样的,所以被监控机上也需要装一套nagios-plugins插件。

例如:nagios主机需要监控被监控机的硬盘信息,就会对被监控机发出一条命令说:“我要看你的硬盘信息。

”被监控机nrpe的daemon接到这个命令之后,就会运行一个插件,来检查被监控机本地硬盘的信息,然后插件把信息反馈到nrpe,nrpe通过ssl通道再把这些信息反馈到nagios主机。

如下图所示二、NRPE安装1、所需安装包nrpe、nagios-plugins,这两个包都可以从上得到,本例为nrpe-2.12.tar.gz2、安装openssl、openssl-devel;yum install -y opensslyum install -y openssl-devel3、安装nrpe和nagios-plugins插件1)安装nagios-plugins,在安装时首先在被监控机上新建nagios用户及组。

监控系统配置使用(Nagios)

监控系统配置使用(Nagios)
税友
监控系统配置使用—Nagios
讲师:吴云鹏
税友软件集团股份有限公司
课程目标
nagios体系结构认识 • 帮助运维人员对nagios体系结构有更清晰的认识
如何配置监控项 • 帮助运维人员更有效的使用和配置nagios的监控项
理解监控项含义 • 帮助运维人员更好理解现有监控项的含义
2
课程大纲
3
系统介绍 原理、结构 部署、配置 监控项简介
问题交流
Nagios介绍
Nagios介绍: Nagios是一款用于系统和网络监控的应用程序,可在设定的条件下对主机和服务
进行监控,在状态变差和变好的时候给出告警信息。 Nagios 的特征包括: 1) 监控网络服务(SMTP、POP3、HTTP、NNTP、PING 等); 2) 监控主机资源(处理器负荷、磁盘利用率等); 3) 简单地插件设计使得用户可以方便地扩展服务的检测方法; 4) 当服务或主机问题产生与解决时将告警发送给联系人(Email)、页面声音报警 Centreon介绍: centreon作为nagios的分布式监控管理平台,它的底层使用nagios监控软件,通过 centreon页面可以简单方便地管理和配置nagios;
个性类监 控
监控项
Weblogic 类监控
Oracle类 监控
15
监控插件
插件作用
• 什么是插件?插件和命令的关系?
插件存放位置
• 存放在监控机位置?存放在被监控机位置?
现有插件
• 现有哪些插件?获取插件网站
16
回顾
通用监控
主机监控项 Weblogic监控项
Oracle监控项
17
个性监控
Godengate监控项 业务监控项 接口监控项

Nagios 使用说明

Nagios 使用说明

– 重启apache使新设置生效。
• service httpd restart
第二章 Nagios安装和配置
• Nagios典型配置
– Nagios安装完成了,但是还需要配置。 – 修改nagios的主配置文件nagios.cfg。 – 修改CGI脚本控制文件cgi.cfg。 – 定义监控时间段,创建配置文件timeperiods.cfg。 – 定义联系人,创建配置文件contacts.cfg。
第二章 Nagios安装和配置
• nagios.cfg配置文件修改
– 注释行 #cfg_file=/usr/local/nagios/etc/localhost.cfg[2],然后把下面几行的 注释去掉:
• • • • • • cfg_file=/usr/local/nagios/etc/contactgroups.cfg //联系组配置文件路径 cfg_file=/usr/local/nagios/etc/contacts.cfg //联系人配置文件路径 cfg_file=/usr/local/nagios/etc/hostgroups.cfg //主机组配置文件路径 cfg_file=/usr/local/nagios/etc/hosts.cfg //主机配置文件路径 cfg_file=/usr/local/nagios/etc/services.cfg //服务配置文件路径 cfg_file=/usr/local/nagios/etc/timeperiods.cfg //监视时段配置文件路径
– 注意:NRPE daemon需要nagios插件安装在远程的linux主机上,否 则,daemon不能做任何的监控。 – 需要在被监控主机上安装nagios插件,NRPE。在监控主机上安装 check_nrpe插件。

nagios的使用

nagios的使用

Nagios监控的使用一、Nagios简介Nagios是一个监视系统运行状态和网络信息的监视系统。

Nagios能监视所指定的本地或远程主机以及服务,同时提供异常通知功能等Nagios可运行在Linux/Unix平台之上,同时提供一个可选的基于浏览器的WEB界面以方便系统管理人员查看网络状态,各种系统问题,以及日志等等。

Nagios的主要功能特点:监视网络服务(SMTP,POP3,HTTP,NNTP,PING等)监视主机资源(进程,磁盘等)简单的插件设计可以轻松扩展Nagios的监视功能服务等监视的并发处理错误通知功能(通过email,pager,或其他用户自定义方法)可指定自定义的事件处理控制器可选的基于浏览器的WEB界面以方便系统管理人员查看网络状态,各种系统问题,以及日志等等二、工作原理Nagios自身是不带任何功能的,Nagios监测服务只能是本地系统监测以及对远程主机的连通性监测。

为了使Nagios的监测服务器能够远程对被监测主机系统上的信息进行获取,比如远程系统上的进程数、磁盘空间使用状况、所运行的服务等等这些必须要登录远程主机系统上才能了解的信息的话,就必须要依靠NRPE或nsclient这个核心扩展插件程序,NRPE 作为中间的代理程序,扮演着一手接受着Nagios监测服务器发来的请求,另一手在远程主机系统上获取指定的信息的中间人角色。

,要实现监控功能,我们必须安装插件(plugins),以及nrpe。

2.1 监控windows1. windows设置1)安装nsclient,然后在cmd命令台执行以下命令2)修改nsclient的nse.ini配置文件[modules] #去掉注释符号”;”除了CheckWMI.dll和RemoteConfiguration.d llFileLogger.dllCheckSystem.dllCheckDisk.dllNSClientListener.dll[Settings]allowd_host=192.168.2.2 #为nagios服务的IP[NSClient]port=12489 #去掉注释就可以了!3)启动nsclient服务并确认端口是否打开2. linux设置接下来我们开始配置nagios服务器里面的内容,因为nagios是模块化调用,先到配置文件打开windows相关模块。

Linux系统监控之 Nagios配置教程详解(赵舜东)

Linux系统监控之 Nagios配置教程详解(赵舜东)

Linux系统监控之 Nagios配置教程详解(赵舜东)实验目的:通过实验熟练掌握Nagios这个开源的监控解决方案的实施。

实验环境:Red Hat Enterprise Linux +nagios.3.2.0实验步骤:第一部分:Linux系统监控之 Nagios详解(一)一、Nagios 简介(一)什么是Nagios,Nagios有哪些特性。

(二)Nagios工作原理二、部署Nagios监控服务器(一)下载所需软件包(二)安装Nagios(三)安装Nagios的插件nagios-plugin(四)配置检测主机是否存活(五)第一部分功能测试第二部分:Linux系统监控之 Nagios详解(二)三、使用Nagios监控Linux 客户端(一)Nagios监控服务器的配置(二)Nagios监控客户端的配置四、使用Nagios 监控Windows 客户端(一)Nagios 监控服务器的配置(二)Nagios 监控客户端的配置第三部分:Linux系统监控之 Nagios详解(三)五、Nagios 配置文件详解实验简介:公司进行了机房改造,新系统也上线了,需要一个强大的监控方案,对服务器和各服务的运行情况进行有效的监控,我第一个想到的就是Nagios这个强大的开源解决方案,本文以监控八台服务器和Nagios服务器本身为例。

根据先实现、后深入的方式,把本文分为三个部分,开始先实现了功能, 在第三个部分,在对配置的内容进行详细的讲解,功能实现:实现Web浏览器监控,Mail报警邮件收发,手机短信收发。

手机短信怎么收发呢?网上有很多很多的方法,我推荐一种就是使用139信箱,139信箱有一项免费的功能就是发邮件通知到您的手机上,可以在手机上看邮件内容,免费的哦。

什么?还没有139信箱,那么别傻呆了,系统运维必备的信箱,快免费申请吧。

本作品为本站原创作品,如需转载请注明来自UnixHot 技术联盟实验答疑:zhaoshundong@一、Nagios 简介官方网站:/ (更多的详细说明请参考官方网站)Nagios® is a system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better.Nagios was originally designed to run under Linux, although it should work under most other unices as well.Some of the many features of Nagios include:1.Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.) 监控网络资源2.Monitoring of host resources (processor load, disk usage, etc.) 监控主机资源3.Simple plugin design that allows users to easily develop their own service checks4.Parallelized service checks5.Ability to define network host hierarchy using "parent" hosts, allowing detection of and distinction between hosts that are down and those that are unreachable6.Contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method)7.Ability to define event handlers to be run during service or host events for proactive problem resolution8.Automatic log file rotation 自动日志轮滚9.Support for implementing redundant monitoring hosts 支持冗余10.Optional web interface for viewing current network status, notification and problem history, log file, etc.请参考Nagios 中文在线帮助文档:/docs/nagios/cn/build/html/index.html二、部署Nagios监控服务器(一)下载所需软件包1.nagios.3.2.0.tar.gz Nagios的主程序[root@UnixHot src]# wget /sourceforge/nagios/nagios.3.2.0.tar.gz2.nagios-plugins-1.4.13.tar.gz Nagios 的插件[root@UnixHot src]# wget /sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz3.nrpe-2.12.tar.gz代理检测程序[root@UnixHot src]# wget /sourceforge/nagios/nrpe-2.12.tar.gz[root@UnixHot src]# lsnagios-3.2.0.tar.gz nagios-plugins-1.4.13.tar.gz nrpe-2.12.tar.gz(二)安装Nagios官方的安装文档:/docs/3_0/quickstart-fedora.html1.安装前的依赖检查[root@UnixHot ~]# rpm -q httpd php gcc glibc glibc-common gd gd-devel2.创建Nagios账户和组[root@UnixHot src]# useradd -m nagios[root@UnixHot src]#groupadd nagcmd[root@UnixHot src]# usermod -a -G nagcmd nagios[root@UnixHot src]#usermod -a -G nagcmd apache3.编译安装[root@UnixHot src]# tar xvf nagios-3.2.0.tar.gz[root@UnixHot src]# cd nagios-3.2.0(至于每一步的具体意思,我不再详述,因为运行完毕后,提示信息会明确的告诉你,它干了什么,是怎么干的。

Nagios监控系统(二)监控Linux机器

Nagios监控系统(二)监控Linux机器

10.Nagios如何监控Linux机器NRPE总共由两部分组成:(1).check_nrpe插件,运行在监控主机上。

(2).NRPE daemon,运行在远程的linux主机上(通常就是被监控机)按照上图,整个的监控过程如下:当Nagios需要监控某个远程linux主机的服务或者资源情况时:1).nagios会运行check_nrpe插件,我们要在nagios配置文件中告诉它要检查什么.2).check_nrpe插件会通过SSL连接到远程的NRPE daemon.3).NRPE daemon会运行相应的nagios插件来执行检查本地资源或服务.4).NRPE daemon将检查的结果返回给check_nrpe插件,插件将其递交给nagios做处理.注意:NRPE daemon需要nagios插件安装在远程被监控linux主机上,否则,daemon不能做任何的监控.11.Nagios的配置文件#控制cgi访问的配置文件cgi.cfg#Nagios主配置文件nagios.cfg#resource.cfg定义了一些变量,以便被其他文件引用,如$USER1$resource.cfg# objects是一个目录,用于定义Nagios对象objects# servers是自己创建的一个目录,Nagios可以加载一个目录下面的所有配置文件(需要在nagios.cfg中配置)servers./objects:#命令定义配置文件,里面定义的命令可以被其他文件引用commands.cfg#联系人和联系人组配置文件contacts.cfg#监控本地机器的配置文件localhost.cfg#监控打印机的一个事例配置文件(默认未启用)printer.cfg#监控路由器的一个事例配置文件(默认未启用)switch.cfg#模板配置文件,在此可以定义模板,在其他文件中引用templates.cfg#定义监控时间段的配置文件timeperiods.cfg#监控Windows的一个事例配置文件(默认未启用)windows.cfg./servers:#自己创建的主机群组配置文件hostgroup.cfg#自己创建的监控远程Linux主机的配置文件wiki-l-11.cfg配置文件是怎样引用的?用nagios主要是监控一台主机的各种信息,包括本机资源以及对外的服务等等.这些在nagios 里面都是被定义为一个个的项目(nagios称之为服务,为了与主机提供的服务相区别,我这里用项目这个词),而实现每个监控项目,则需要通过commands.cfg文件中定义的命令。

nagios报警触发机制

nagios报警触发机制

Nagios报警触发机制简介之前我曾经学过zabbix,以为他们的机制差不多,但是实际操作测试以来,才发现差别很大,而且网上很多教程都很坑人,比如说nagios里面涉及到抖动、以及模板的调用,跟zabbix 区别很大,接下来我就在下文里进行一个详细的介绍。

Cfg文件的调用Nagios一般监控的话分为服务监控和主机监控,然后对应的配置也文件也需要定义每一个主机和每一个服务的一些相关的功能,我们可以在模板文件里有所看到模板里面就定义了几种,然后呢,网上经常就是直接调用他们,比如说nagios自带的localhost 的模板里面,语法如下它就引用了模板里面的local-service服务然后从local-service里面又引用了generic-service也就是说,这个服务的配置参数引用了所有以上的参数,然后嵌套调用,这样可以省很多东西,不过作为初学者的我来说,刚开始还以为就只有那么几个东西,结果报警触发的时候死活不发邮件,或者隔了好一会儿才发送,所以一定要明白这一点,甚至可以说自己创造一个服务的定义,然后自己引用自己的,我就是这样做的,至于以上参数,有几个重要的在后期的报警上面我会多写一点。

Nagios的报警触发机制Nagios的报警触发默认状态下所定义的服务并不是一监测到问题就报警,而是当发现问题之后,继续监测问题,如果问题仍然持续,才进行报警。

监测单位时间字面意思,上面是服务的时间,下面是主机的时间,这个的话定义一个单位时间为60秒,默认也是60秒,你可以根据自己的需要进行修改,比如说你可以改成30秒,那么两个时间单位就是一分钟,这一点一定要明确。

监测的“软态”和“硬态”首先要清楚几个字段的意思啊retry_check_interval 重试时间max_check_attempts 这个是出现故障的连接次数,达到这个次数之后就报警然后来介绍一下软态硬态是什么意思,以下就直接摘网上的了,反正我已经通过测试了一、软态:被监控项处于retry_check检测周期内的非正常状态;二、硬态:被监控项达到max_check_attempts最大次数后的非正常状态;除此之外的状态,我们估且称之为“常态”。

nagios监控说明

nagios监控说明

Nagios监控利用说明目录Nagios介绍 (2)监控界面说明 (3)General (3)Current Status (3)Tactical Overview (4)右上方_ Monitoring Performance: (4)左上方_Network Outages (4)下方部分 (5)Map (5)Hosts (6)Host State Information (6)Host Commands (7)Host Comments (8)Services (8)Host Groups (9)Service Groups (10)Problem (10)Quick Search (10)Reports (11)Availability (11)第一步 (11)第二步 (12)第三步 (12)第四步 (13)Trends (13)Graphs (14)Alerts (14)History (14)Summary (15)Histogram (15)Notifications (16)Event Log (16)System (16)Comments (16)Downtime (17)Process Info (17)Performance Information (17)Scheduling Queue (17)Configuration (18)Nagios介绍Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,互换机路由器等网络设置,打印机等。

在系统或效劳状态异样时发出邮件或短信报警第一时刻通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。

目前,语联网12台效劳器均由nagios监控,监控界面:监控界面说明上图是nagios的监控界面,左侧栏是nagios能够监控的各个项目,点击左侧栏的按钮,右边即可显示相应的监控数据。

左侧栏显示的功能要紧分四个部份:General、Current Status、Reports、System,下面将别离介绍四部份的详细功能。

nagios基于NSClient监控windows系统

nagios基于NSClient监控windows系统

nagios基于NSClient监控windows系统之前测试nagios监控Linux结果搞得笔者要吐血,太大意了,跟zabbix完全两个东西,但是笔者在测试windows的监控就如鱼得水多了,废话少说,直接上正题。

NSClientLinux的被监控端需要安装check_nrpe以及插件,但是windows直接就一个NSClient就够了,所有的监控,就用它一个就够了!版本的选用上面是笔者下的版本,4.3和4.4的后来下下来才发现……4.4的就不能用啊!也许是笔者打开的方式不对,但是4.4真的不能用所以暂时就用4.3的,各位在测试的时候最好要确定版本!安装一系列默认点下一步就行了……Windows下的安装就是简单……在需要勾选的时候记得全部打钩安装完了之后,点进服务开启桌面交互这个东西计算机右键管理里面找然后设置自动(默认是自动启动)检测端口12489和5666都要有才行笔者用4.4版本的做测试12489端口就没有起来,也许是check_nt没有打开的原因。

Check_nt测试命令之前我产出里面监测linux用的nrpe,这里也是一样,还是先看看nt的插件和命令在不在这里很明显,命令和插件都有,那么笔者来从远端测试一下虚拟机下的C盘多大!这边显示快满了……笔者用笔记本开虚拟机,唉,进去看看是不是这样呢?测试成功!部署cfg配置文件及脚本Nagios最头疼的就是脚本了,nt有几个常用的命令,我就复制粘贴到这里一下(to江涛:这里我只有这一部分是复制粘贴!),仅供参考。

首先是check_nt的语法及几个固定参数语法: check_nt -H host -v variable [-p port] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-u] [-t timeout] 选项: -h, --help 显示帮助-V, --version 显示版本信息-H, --hostname=HOST 被监控主机名称或IP-p, --port=INTEGER 监控端口(默认为1248,不过我的nagios安装后端口为12489)-s, --secret=<password>要求的密码-w, --warning=INTEGER 引发报警状态的阀值-c, --critical=INTEGER引发严重错误状态的阀值-t, --timeout=INTEGER 连接尝试超时秒数(默认-l, --params=<parameters>参数传递给指定的监控项(见下文)-d, --display={SHOWALL}显示选项(目前仅支持SHOWALL)-u, --unknown-timeout多长时间后返回 UNKNOWN)-v, --variable=STRING 监控参数监控参数: CLIENTVERSION = Get the NSClient version 如果用-l<version>指定版本号,则版本不同时会报警CPULOAD = 最后X分钟CPU的平均负载。

使用Nagios监控网页

使用Nagios监控网页

使用Nagios监控网页1. 问题的由来对于一个网站来说,外部用户能够看到就是该网站的页面。

网站页面能否被正常访问,以及显示是否正常势必会成为网站整体水平最直接的外在表现。

那么,如何才能在第一时间检测到网页是否正常,并且给相应的技术人员发出报警来及时解决问题,而不是等接到用户抱怨的电话后才在慌忙中仓促的解决问题呢?解决这个问题的关键就是要在第一时间发现问题,发现那些不能显示的网页或是显示不正常的网页,并及时发出报警。

当然我们可以通过人工的方法去监测,但对于一些大型的、复杂的网站来说就不是很合适了,我们可以使用监控软件来解决这个问题。

我所使用的就是Nagios软件,它提供的插件(Plugins)中有相应的命令可以完成对网页的监控。

2. 如何通过Nagios解决此类问题对于Nagios、NRPE以及Nagios Plugins的安装配置网站的资料很多,在我的Blog中也有相应的文章可以参考,在这里就不再过多的说明了。

想使用Nagios监控网页状况,Nagios插件中的一个命令不得不被提及,那就是check_http,我没可以使用它来检查网页是否正常、可用。

该命令的具体说明和用法如下。

Usage: check_http -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>][-w <warn time>] [-c <critical time>] [-t <timeout>] [-L][-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>][-s string] [-l] [-r <regex> | -R <case-insensitive regex>] [-P string][-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>] [-A string][-k string] [-S] [-C <age>] [-T <content-type>]NOTE: One or both of -H and -I must be specifiedOptions:-h, --helpPrint detailed help screen-V, --versionPrint version information-H, --hostname=ADDRESSHost name argument for servers using host headers (virtual host)Append a port to include it in the header (eg: :5000)-I, --IP-address=ADDRESSIP address or name (use numeric address if possible to bypass DNS lookup).-p, --port=INTEGERPort number (default: 80)-4, --use-ipv4Use IPv4 connection-6, --use-ipv6Use IPv6 connection-S, --sslConnect via SSL. Port defaults to 443-C, --certificate=INTEGERMinimum number of days a certificate has to be valid. Port defaults to 443(when this option is used the url is not checked.)-e, --expect=STRINGString to expect in first (status) line of server response (default:HTTP/1.)If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)-s, --string=STRINGString to expect in the content-u, --url=PATHURL to GET or POST (default: /)-P, --post=STRINGURL encoded http POST data-N, --no-bodyDon't wait for document body: stop reading after headers.(Note that this still does an HTTP GET or POST, not a HEAD.)-M, --max-age=SECONDSWarn if document is more than SECONDS old. the number can also be ofthe form "10m" for minutes, "10h" for hours, or "10d" for days.-T, --content-type=STRINGspecify Content-Type header media type when POSTing-l, --linespanAllow regex to span newlines (must precede -r or -R)-r, --regex, --ereg=STRINGSearch page for regex STRING-R, --eregi=STRINGSearch page for case-insensitive regex STRING--invert-regexReturn CRITICAL if found, OK if not-a, --authorization=AUTH_PAIRUsername:password on sites with basic authentication-A, --useragent=STRINGString to be sent in http header as "User Agent"-k, --header=STRINGAny other tags to be sent in http header. Use multiple times for additional headers-L, --linkWrap output in HTML link (obsoleted by urlize)-f, --onredirect=<ok|warning|critical|follow>How to handle redirected pages-m, --pagesize=INTEGER<:INTEGER>Minimum page size required (bytes) : Maximum page size required (bytes)-w, --warning=DOUBLEResponse time to result in warning status (seconds)-c, --critical=DOUBLEResponse time to result in critical status (seconds)-t, --timeout=INTEGERSeconds before connection times out (default: 10)-v, --verboseShow details for command-line debugging (Nagios may truncate output)通过check_http的帮助我们可以清楚的了解到该命令可以为我们做什么,以及如何去做。

如何使用Nagios进行监控管理

如何使用Nagios进行监控管理

如何使用Nagios进行监控管理随着现代企业的不断发展,IT技术的应用越来越广泛,IT系统的监控管理也成为了企业运维工作中不可或缺的一部分。

Nagios作为一款开源的网络监控系统,在IT系统监控管理中被广泛应用。

本文将介绍如何使用Nagios进行监控管理。

一、Nagios的安装在使用Nagios进行监控管理之前,首先需要进行Nagios的安装。

以Ubuntu为例,可以使用以下命令进行安装:sudo apt-get update && sudo apt-get install nagios3安装完成后,可以通过http://localhost/nagios3访问Nagios的Web界面。

默认管理员账号为nagiosadmin,密码为/etc/nagios3/ers文件中设置的密码。

二、Nagios的配置在Nagios的Web界面中,可以进行监控主机、服务和通知等配置。

1. 监控主机的配置在监控主机的配置中,需要配置主机的名称、IP地址、监控服务、报警策略等信息。

可以通过在Web页面中选择“Hosts”->“Add”进行配置。

2. 监控服务的配置在监控服务的配置中,需要配置监控服务的名称、主机名称、检测命令、报警策略等信息。

可以通过在Web页面中选择“Services”->“Add”进行配置。

3. 报警策略的配置在报警策略的配置中,需要设置报警的方式、邮件、短信等通知方式、报警阀值等信息。

可以通过在Web页面中选择“Contacts”->“Add”进行配置。

三、Nagios的使用在配置完成后,可以通过Nagios进行监控管理。

在Web界面的“Current Status”页面中可以查看当前监控的状态,包括主机的Up和Down状态、服务OK、Warning和Critical状态等。

在Web界面的“Tactical Overview”页面中可以查看当前状态的汇总。

在Nagios监控主机和服务的运行状态时,可以选择手动与自动两种方式。

Nagios监控软件安装和配置文档

Nagios监控软件安装和配置文档

监控软件安装和配置文档监控软件安装和配置文档 (1)1 初始安装 (1)1.1 监控软件介质列表 (1)1.2 服务端安装 (2)1.2.1 软件包安装 (2)1.2.2 创建系统业务用户 (2)1.2.3 上传安装包 (3)1.2.4 编译安装Nagios (3)1.2.5 配置web接口 (3)1.2.6 编译和安装Nagios plugins (4)1.2.7 安装Nagios Chinese plugin (4)1.2.8 开启nagios (4)1.2.9 登陆web界面 (4)1.3 Linux客户端安装 (5)1.3.1 创建系统业务账户 (5)1.3.2 上传安装包 (5)1.3.3 安装Nagios Plugins (5)1.3.4 安装xinetd (5)1.3.5 安装NRPE daemon (6)1.3.6 测试本地NRPE daemon (6)1.3.7 配置NRPE命令 (7)1.3.8 服务端配置(新添节点忽略) (7)1.3.9 定制监控服务(新添节点忽略) (11)1.4 Windows客户端安装 (12)1.4.1 what’s Already Done For you (12)1.4.2 Prerequisites (13)1.4.3 Installing the Windows Agent (13)1.4.4 Monitoring Machine (服务端配置新添加节点则滤过) (18)2 事件处理 (22)2.1 Linux事件处理 (22)2.2 日志 (25)2.3 测试方法 (25)1初始安装1.1监控软件介质列表1.2服务端安装1.2.1软件包安装安装中一部分需要有root权限。

需要以下安装包:●Apache●PHP●GCC compiler●GD可以利用yum安装1.2.2创建系统业务用户以root用户登录建立一个新的nagios 用户账户并设置密码用于操作nagios建立一个新的 nagcmd 组添加nagios和apache用户到此组。

nagios安装-监控-报警配置详解-byHF

nagios安装-监控-报警配置详解-byHF

Nagios安装与配置详解内容简介本文档介绍nagios监控linux服务器, 因为监控都是依靠插件去完成的,而监控linux主要使用NRPE插件,本文首先简单介绍一下NRPE监控基础,及监控过程,然后一步步的配置一个实例实现监控linux服务器1.NRPE监控插件基础NRPE总共由两部分组成:check_nrpe插件,运行在监控主机上。

NRPE daemon,运行在远程的linux主机上(通常就是被监控机)整个的监控过程:(如下图)当Nagios需要监控某个远程linux主机的服务或者资源情况时:1).nagios运行check_nrpe插件,我们要在nagios配置文件中告诉它要检查什么.2).check_nrpe插件会通过SSL连接到远程的NRPE daemon.3).NRPE daemon会运行相应的nagios插件来执行检查本地资源或服务.4).NRPE daemon将检查的结果返回给check_nrpe插件,插件将其递交给nagios做处理.注意:NRPE daemon需要nagios插件安装在远程被监控linux主机上,否则,daemon不能做任何的监控. 别外因为它们间的通信是加密的SSL,所以在编译安装时都要加上选项, ./configure --enable-ssl --with-ssl-lib=/lib/,否则也会出错.安装Nagios一、准备软件包在做安装之前确认要对该机器拥有root权限。

确认你安装好的linux系统上已经安装如下软件包再继续。

ApacheGCC编译器[root@localhost ~]# rpm -qa | grep gdgd-devel-2.0.33-9.3.fc6gdb-6.5-16.el5gd-2.0.33-9.3.fc6gdbm-1.8.0-26.2.1sysklogd-1.4.1-39.2gdm-2.16.0-30.el5[root@localhost ~]# rpm -qa | grep glibglibc-head ers-2.5-12dbus-glib-0.70-5NetworkManager-glib-0.6.4-6.el5avahi-glib-0.6.16-1.el5glibc-2.5-12glibc-common-2.5-12glib-java-0.2.6-3.fc6compat-glibc-head ers-2.3.4-2.26glib2-2.12.3-2.fc6glibc-devel-2.5-12compat-glibc-2.3.4-2.2[root@localhost nagios]# rpm -qa | grep gcccompat-gcc-34-3.4.6-4gcc-4.1.1-52.el5gcc-c++-4.1.1-52.el5compat-gcc-34-g77-3.4.6-4libgcc-4.1.1-52.el5compat-gcc-34-c++-3.4.6-4gcc-gfortran-4.1.1-52.el5下面安装需要用到的软件包下载地址:1.nagios/project/nagios/nagios-3.x/nagios-3.2.1/nagios-3.2.1.tar.gz2.nagios-plugins-1.4.14.tar.gz/project/nagiosplug/nagiosplug/1.4.14/nagios-plugins-1.4.14.tar.g z3.nrpe-2.12.tar.gz/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz二、安装Nagios操作过程2.2 创建一个用户组名为nagioscmd用于从Web接口执行外部命令。

nagios监控系统手册详细操作

nagios监控系统手册详细操作

nagios网络监控Nagios是什么:Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。

在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。

nagios是功能强大的监控软件,主要用来监控网络设备的状态(比如:主机的资源状态);适合于:对大量的服务器进行监控,判断其负载或服务是否正常,发生异常能通过邮件、短信报警。

特别注意:流量监控不是他的强项,流量监控建议使用cacti.可以绘制非常直观的图形nagios能监视什么:nagios可以监控:1、主机是否宕机(通过ping命令,如果ping不通会认为主机属于宕机状态,但不影响所监控的其他服务);2、服务器资源(cpu使用率、硬盘剩余空间等);3、网络服务(smtp\pop3\http\);4、监控网络设备(路由器、交换机等。

)一、RHEL系统上部署Nagios:(禁用selinux功能)系统环境:RHEL,在nagios主机上监控mysql服务器nagios 主机:192.168.10.100mysql 主机: 192.168.10.101操作步骤:1、安装编译所需的软件包:如下图所示:# yum –y install httpd php-* gd-* mysql-devel(若mysql-devel包不安装,会没有check_mysql插件。

)2、创建运行nagios服务的用户注:useradd nagios #创建运行nagios服务的用户usermod -G nagios apache #使apache用户对nagios目录具有写权限,不然web页面操作失败.3、nagios软件安装释放nagios源码包,进行编译前的预备置:编译并安装nagios及相关操作,如下图所示:注:make install //安装主程序,CGI和HTML文件make install-init //在/etc/rc.d/init.d安装启动脚本make install-commandmode //配置目录权限make install-config //安装示例配置文件make install-webconf //安装nagios的web接口,会在/etc/httpd/conf.d目录中创建nagios.conf文件。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

CheckEventLogCheckEventLog is part of the wiki:CheckEventLog module. This page describes the new syntax, for the old syntax refer to the old page: CheckEventLogOld The new syntax is a bit sketchy in the docs as of yet... I shall try to fix some better examples.. but the best idea would be for someone that uses this to help me with that :) Before you start using CheckEventLog use this command (it is long but a good place to start):CheckEventLog file=application file=system filter=new filter=outMaxWarn=1 MaxCrit=1filter-generated=>2d filter-severity==success filter-severity==informationaltruncate=1023 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"This check enumerates all event in the event log and filters out (or in) events and then the resulting list is used to determine state.The CheckEventLog uses filters to define the "interesting" records from the eventlog.SyntaxA filter is made up of three things:•Filter mode Determines what happens when the filter is matched.CheckEventLog1•Filter type What the filter will match (ie. which field).•An Expression What to check for.The syntax of a filter is: filter<mode><type>=<expression>OrderOrder is important, as soon as a positive (+) or negative (-) rule is matched it is either discarded or included and the entry is "finished" and it will continue with the next entry. The best way here is to have an "idea" either remove all entries first or include all required ones first (depending on what you want to do). You can mix and such but this will probably complicate things for you unless you actually need to.Filter modesCapturing eventlog entries (or discarding them) are done with filters. There are three kinds of filters.<filter mode>title description+positive requirements All these filters must match or the row is discarded..potential matches If this matches the line is included (unless another lines overrides).-negative requirements None of these filters can match (if any do the row is discarded). Thus if you want to have: all errors and entries from the last month but not the ones from the cdrom, but if the source is MyModule? get everything. I would break this down as such: (notice there are other options). + type=error - date=older than 2 months . source=MyModule? This would pick up all errors, and drop all old records and then pickup all remaining "MyModule?" records (in this case you could have used + on the source filter since there are no more rules).other example to simplify it: if for example you want to monitor all errors and to ignore warning and success in the eventlog you can write the following: filter+severity==error filter-severity==successfilter-severity==informationaland the command with those parameters with others can be like the following: CheckEventLogfile=application file=system filter=new filter=out MaxWarn=1 MaxCrit=1 filter-generated=>2dfilter+severity==error filter-severity==success filter-severity==informational truncate=1023 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"Filter TypesSyntax2An event type expression is similar to a numeric-expression but instead of a number a "keyword" is taken: error, warning, info, auditSuccess, auditFailure. So filter.eventType==warning orfilter.eventType=<>warning are examples of event type expressions. Yes this is correct the syntax is:filter<mode><type>=<expression> in this case <mode> is ".", <type> is "eventType" and <expression> is "<>warning". This IS confusing but it is "simpler to parse" some day maybe I shall improve this.filter<key><event severity expressionAn event severity expression is similar to a numeric-expression but instead of a number a "keyword" is taken: success, informational, warning or errortime expressionA time expression is a date/time interval as a number prefixed by a filter prefix (<, >, =, <>) and followed by a unit postfix (m, s, h, d, w). A few examples of time expression are: filter+generated=>2d means filter will match any records older than 2 days, filter+generated=<2h means match any records newer then 2 hours. Warning, the bash interprets the "<,>,!". Use the "\" to avoid this. e.g. filter+generated=\>2d . On the Client activate the "Nasty Metachars" Option, to allow the \.string expressionA string expression is a key followed by a string that specifies a string expression. Currently substr and regexp are supported. Thus you enter filter.message=regexp:(foo|bar) to enter a regular expression andfilter-message=substr:foo to enter a substring patter match.Filter in/outThere are two basic ways to filter:•in When you filter in it means all records matching your filter will be returned (the "simplest way")•out When you filter out it means all records matching your filter will be discarded.So:filter=in filter+eventType==warning...filter=out filter-eventType==warningWill both have the same effect as the first one filters "in" and matches all warnings and the second one filters out and discards all warnings. There is one very fundamental difference though the first one will only return the warnings where as the second one will return all entries and all warnings.Filter Types3UniqueWhen unique is present any duplicate entries matching the filter will be discarded so you will only get backone of each "kind" of error. Uniqueness is determined by log-file, event-id, event-type and event-category. ExamplesSample Eventlog CommandCheck by EventID for target errors that may have transpired over the past 2 hours.$ARG1$ = file to check ie. Application, Security, System$ARG2$ = Max Warn amount$ARG3$ = Max Critical amount$ARG4$ = eventID NumberSample Command:CheckEventLog filter=new file="application" MaxWarn=10 MaxCrit=20 filter-generated=OK: ...Nagios Configuration:define command {command_name <<CheckEventLog>>command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckEventLog -a filter=new file="$ARG1$" M From Commandline (with NRPE):check_nrpe -H IP -p 5666 -c CheckEventLog -a filter=new file="application" MaxWarn=10 MaxCrit=20 Another sampleCheck the Application event log for errors over the past 48 hours. Filter out any Cdrom and NSClient Errorsas well as all Warnings. Allow 3 target Errors before firing a Warning, and 7 Errors before firing a CriticalState.This is the corresponding command: Sample Command:CheckEventLog filter=new file=system file=application MaxWarn=1 MaxCrit=1 filter-generated=>2d fi CRITICAL: 27 > critical: ESENTNagios Configuration:define command {command_name <<CheckEventLog>>command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckEventLog -a filter=new file=system fil }<<CheckEventLog>>Unique4From Commandline (with NRPE):check_nrpe -H IP -p 5666 -c CheckEventLog -a filter=new file=system file=application MaxWarn=1 Ma Please note: You need to allow_nasty_meta_chars=1 in the NSC.ini to use time filters like "<2d" (last48 hours).Check if a script is running as it shouldJust to show a 'hidden' parameter ... I check that a script has successfully finished by writing into the eventlog.If after 1 day there is no new log entry, I get the message from Nagios.Sample Command:CheckEventLog filter=new file=application MinWarn=0 MinCrit=0 filter-generated=\>1d filter+eventS OK: ...Nagios Configuration:define command {command_name <<CheckEventLog>>command_line check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckEventLog -a filter=new file=applicatio }<<CheckEventLog>>From Commandline (with NRPE):check_nrpe -H IP -p 5666 -c CheckEventLog -a filter=new file=application MinWarn=0 MinCrit=0 filt Don't understand filtering ?Yes I know, there are a lot of options regarding filtering, and they are a bit hard understand. This section triesto give a more formal definition of what the various options do (form a programming perspective).OptionsThere are three different option pairs all used with the same key filter1.filter=new / filter=old This one decides the code which is used there are two completely differentconcepts and the "Old" one is preferably not to be used as it is slightly less sane.filter=all / filter=any This is NOT used with filter=new so this option is deprecated and should not be2.used unless you are using filter=old.3.filter=in / filter=out This option decides what happens if "nothing matches" if you have filter=in thatmeans if nothing matches you will still get the option where as if you have filter=out you wont. Sothis is the last thing that happens in the code.So what you end up with is:•filter=new this is default in newer versions, so you don't really need this anymore.filter=old Should not be used any more.•Don't understand filtering ?5filter=any is not used any more.••filter=all is not used any more.•filter=in Means you want everything except "something"•filter=out Means you only want "something"RulesThere are three different filter rule types all used in the same way except swapping the - for + for .1.filter+severity==error This means that any entries matching this rule is automatically included in the result. After this we instantly stop matching more rules for this entry.filter-severity==error This means that any entries matching this rule is automatically excluded in the2.result. After this we instantly stop matching more rules for this entry.3.filter.severity==error This means that any entries matching this rule is neither automatically excluded nor automatically included in the result. But after this rule we continue matching more more rules for this entry. Since this is the default behavior with filter=in there is no reason to use filter=. in thismode.How it worksPseudo code (filter=new)This is how the filtering is decided:•bFilterIn=true for filter=in and false for filter=outbool bMatch = !bFilterIn;for(<each rule>) {bTmpMatched=<result of rule evaluation>if ((mode == filter_minus)&&(bTmpMatched)) {// a -<filter> hit so thrash item and bail out!bMatch = false;break;} else if ((mode == filter_plus)&&(!bTmpMatched)) {// a +<filter> missed hit so thrash item and bail out!bMatch = false;break;} else if (bTmpMatched) {bMatch = true;}}if (bMatch) {<deciding factor> = true;}Options6。

相关文档
最新文档