Nagios安装文档
- 格式:docx
- 大小:21.46 KB
- 文档页数:2
在/etc/rc.d/rc.local里面加入下面一行就实现开机启动nrpe了/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d同理要开机运行nagios就在/etc/rc.d/rc.local里面增加下面这行/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg./check_nrpe -H 10.0.9.154./check_nrpe -H 10.0.9.154 -c check_load./check_nrpe -H 61.153.55.237 -p 5107 -c check_disk -a "-w 15%"/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgnagios的实现方式:nagios采用分布-集中的管理模式。
在nagios服务器上安装nagios主程序,在被监控主机上安装nagios代理程序。
通过nagios主程序和nagios代理程序之间的通讯,监视主机状态。
主程序和代理程序之间有两种工作方式,一种是主程序-->Active-->代理程序;另一种是主程序-->passive-->代理程序;顾名思义,是以一方向另一方主动提出通讯需求来划分的。
nagios的安装:nagios服务器上需要安装以下包,nagios主程序,nagios的plugin程序,check_nrpe程序,imagepak包;安装笔记1.下载并安装相关软件1)下载相关软件apache #/GD库(1.63以上)#/gd/http/gd-2.0.11.tar.gzzlib #/zlib/zlib-1.1.4.tar.gzpnglib #/libpng/libpng-1.2.5.tar.gzjpeglib #/files/jpegsrc.v6b.tar.gzbasic icons #/nagios/imagepak-base.tar.gz gd,zlib,pnglib,jpeglib这些正常安装即可, ./configure && make && make installnagios #/download/nagios-plugins #/download/nrpe #/download/2、nagios安装#useradd nagios#mkdir /usr/local/nagios#chown -R nagios:nagios /usr/local/nagios#chmod 755 /usr/local/nagios#tar -zxf nagios-3.0.5.tar.gz#cd nagios-3.0.5#./configure --prefix=/usr/local/nagios#make all#make install#make install-init ##This installs the init script in /usr/local/etc/rc.d#make install-commandmode#make install-config ##将初始的配置文件安装到/usr/local/nagios/etc注:在makeinstall-init这一步的时候可能会进行不下去,这时只要加个root组即可。
nagios安装过程操作系统:gentoo一、nagios主程序安装# groupadd -g 9000 nagios# groupadd -g 9001 nagcmd# useradd -u 9000 -g nagios -G nagcmd -d /usr/local/nagios -c "Nagios Admin" nagios查找apache的运行用户名# grep "^User" /etc/apache2/conf/httpd.confUser www-data# usermod -G nagcmd www-data# mkdir /usr/local/nagios /etc/nagios /var/nagios# chown nagios.nagios /usr/local/nagios /etc/nagios /var/nagios# cd /usr/local/src/nagios-3.0.6# CFLAGS="-O3 -pipe" CXXFLAGS="-O3 -pipe" ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios --with-command-group=nagcmd# make all# make install# make install-init# make install-commandmode# make install-config# rc-update -a nagios default二、plugin安装# CFLAGS="-O3 -pipe" CXXFLAGS="-O3 -pipe" ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios# make# make install# chown nagios.nagios -R /usr/local/nagios# mkdir /var/nagios# chown nagios.nagios /var/nagios三、修改apache的配置文件httpd.conf,添加ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"<Directory "/usr/local/nagios/sbin">AllowOverride AuthConfigOptions ExecCGIOrder allow,denyAllow from allAuthName "No Unauthorized Access Allowed"AuthType BasicAuthUserFile /etc/nagios/ersRequire valid-user</Directory>Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share">Options NoneAllowOverride AuthConfigOrder allow,denyAllow from allAuthName "No Unauthorized Access Allowed"AuthType BasicAuthUserFile /etc/nagios/ersRequire valid-user</Directory>四、NRPE的安装(可以不用安装,使用自己定制的CGI接口即可)4.1 客户端安装(假设IP为10.60.0.233)4.1.1 首先安装plugins,同二,略4.1.2 按章nrpe# ./configure --sysconfdir=/etc/nagios --enable-ssl #(--enable-command-args,可以向nrpe服务器传递参数,但是由于安全和稳定性,避免编译)# make all# make install-plugin# make install-daemon# make install-daemon-config#make install-xinetd# vi /etc/xinet.d/nrpeonly_from = 110.60.4.138 127.0.0.1# vi /etc/servicenrpe 5666/tcp4.1.3 根据需要修改配置文件# vi /etc/nagios/nrpe.cfg4.1.4 本地测试# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs4.2 服务端安装(在nagios服务器上):# ./configure --sysconfdir=/etc/nagios --enable-ssl# make all# make install-plugin连接客户端测试:/usr/local/nagios/libexec/check_nrpe -H 10.60.0.233五、nagios的升级# cd /usr/local/src/nagios-3.1.0# CFLAGS="-O3 -pipe" CXXFLAGS="-O3 -pipe" ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios --with-command-group=nagcmd# make all# make install六、支持UTF-8的方法如果使用nagios-plugin check_http检测url,页面utf-8中文,一旦报警,在nagios的页面出现的关键字将会是乱码,需要修改nagios的cgi程序路径在源代码/cgi在所有c源代码中查找着两行,如果有就在这两行下面增加:printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");printf("<html>\n");printf("<head>\n");。
Nagios安装与配置安装环境:centos-5.5Nagios是一款用于系统和网络监控的应用程序。
它可以在你设定的条件下对主机和服务进行监控,在状态变差和变好的时候给出告警信息。
一、安装apache,php前提:#yum –y install *gcc*1、安装freetype(FreeType库是一个开源的、高质量的且可移植的字体引擎)# tar -zxvf freetype-2.4.3.tar.gz -C /usr/src/# cd /usr/src/freetype-2.4.3/# ./configure --prefix=/usr/local/freetype-2.4.3# make# make install2、安装libpng(支持对PNG 图形文件的创建、读写等操作)# tar -zxvf libpng-1.4.4.tar.gz -C /usr/src/# cd /usr/src/libpng-1.4.4/# ./configure --prefix=/usr/local/libpng-1.4.4# make# make install3、安装jpeg(显示JPEG图像)# tar -zxvf jpegsrc.v8b.tar.gz -C /usr/src/# cd /usr/src/jpeg-8b/# ./configure --prefix=/usr/local/jpeg-8b# make# make install4、安装GD库重新加载lib # ldconfig# ldconfig -p | grep jpeg# ldconfig -p | grep free# ldconfig -p | grep libpng# tar -zxvf gd-2.0.33.tar.gz -C /usr/src/# cd /usr/src/gd-2.0.33/# ./configure --prefix=/usr/local/gd-2.0.33 --with-jpeg=/usr/local/jpeg-8b/ --with-freetype=/usr/local/freetype-2.4.3/ --with-png=/usr/local/libpng-1.4.4/ --with-zlib --enable-m4_pattern_allow解决方法:# vim gd_png.c找到png.h 改为/usr/local/libpng-1.4.4/include/png.h# make# make install5、安装apache# rpm -e httpd -–nodeps 把rpm安装的httpd包卸载# tar -zxvf httpd-2.2.15.tar.gz -C /usr/src/# cd /usr/src/httpd-2.2.15/# ./configure --prefix=/usr/local/apache-2.2.15 --enable-so --enable-rewrite# make# make install6、安装php# tar -zxvf php-5.2.10.tar.gz -C /usr/src/# cd /usr/src/php-5.2.10/# ./configure --prefix=/usr/local/php-5.2.10 --with-apxs2=/usr/local/apache-2.2.15/bin/apxs --with-zlib --with-libxml-dir --enable-gd-native-ttf --enable-mbstring --with-gd=/usr/local/gd-2.0.33/ --with-freetype-dir=/usr/local/freetype-2.4.3/ --with-jpeg-dir=/usr/local/jpeg-8b/ --with-png-dir=/usr/local/libpng-1.4.4/解决方法:放入系统光盘yum –y install libxml2* libxml2是一个xml C语言的解析器和工具# make# make test# make installApaceh与php整合# vim /usr/local/apache/conf/httpd.conf53 LoadModule php5_module modules/libphp5.so54 AddType application/x-httpd-php .php167 <IfModule dir_module>168 DirectoryIndex index.php index.html 169 </IfModule>解决方法:# make clean# /usr/src/php- php-5.2.10#make install解决方法:重新make之前要make clean# /usr/local/apache/bin/apachectl start验证:http://localhost二、安装nagios1、创建系统用户# useradd nagios# passwd nagios# groupadd nagcmd# usermod -G nagcmd nagios# usermod -G nagcmd apache3、安装nagios# tar -zxvf nagios-3.1.2.tar.gz -C /usr/src/# cd /usr/src/nagios-3.1.2/# ./configure --with-command-group=nagcmd# make all# make install# make install-init# make install-config# make install-commandmode修改配置文件:# vim /usr/local/nagios/etc/objects/contacts.cfg35 email ********************更改email接收报警内容# make install-webconf 安装nagios的web配置文件到apache的conf.d目录下解决方法以:# mkidr –p /etc/httpd/conf.d# vim /usr/local/apache/conf/httpd.conf: -r /etc/httpd/conf.d/nagios.conf 将文件导入到apache配置文件中# /usr/local/apache/bin/apachectl start 启动apache# /usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/ers test 创建登录nagios用户3、安装插件1)、nagios-plugis# tar -zxvf nagios-plugins-1.4.14.tar.gz -C /usr/src/# cd /usr/src/nagios-plugins-1.4.14/# ./configure --with-nagios-user=nagios --with-nagios-group=nagios# make# make install到此,nagios已经安装完成,需要做以下设置,启动Nagios# chkconfig –add nagios 将nagios添加到服务中# chkconfig nagios on 设置服务开机启动# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 检查nagios配置是否正确# service nagios start 启动nagios# setenforce 0 关闭selinux验证:http://localhost/nagios解决方法:# vim /usr/local/nagios/etc/cgi.cfg78 use_authentication=0# service nagios restart(修改nagios侧边栏/usr/local/nagios/share/side.php)三、nagios监控linux服务器服务器:centos 5.5 172.24.0.1 nagios nagios-plugis nrpe客户端:centos 5.5 172.24.0.2 nagios-plugins nrpe因为监控都是依靠插件去完成的,而监控linux主要使用nrpe插件服务器端1、安装nrpe# tar -zxvf nagios-nrpe_2.8.1.orig.tar.gz -C /usr/src/# rpm -qa | grep sslopenssl-0.9.8e-12.el5_4.6# cd /usr/src/nrpe-2.8.1/# ./configure --enable-ssl --with-ssl-lib=/lib/解决方法:# yum -y install openssl-devel# make all# make install-plugin# vim /usr/local/nagios/etc/objects/commands.cfg# 添加#check nrpedefine command{command_name check_nrpecommand_line $US ER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$}# vim /usr/local/nagios/etc/nagios.cfg 配置要监控的linux主机添加:37 cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg# vim /usr/local/nagios/etc/objects/mylinux.cfg 新建监控内容define host{use linux-serverhost_name mylinuxalias mylinuxaddress 192.168.0.21(客户端IP既被监控的IP)}define service{use generic-servicehost_name mylinuxservice_description check-swapcheck_command check_nrpe!check_swap}define service{use generic-servicehost_name mylinuxservice_description check-loadcheck_command check_nrpe!check_load}define service{use generic-servicehost_name mylinuxservice_description check-diskcheck_command check_nrpe!check_had1}define service{use generic-servicehost_name mylinuxservice_description check-userscheck_command check_nrpe!check_users}define service{use generic-servicehost_name mylinuxservice_description otal_procscheck_command check_nrpe!check_total_procs}# service nagios restart客户端配置# useradd nagios# passwd nagios1、安装nagios-plugins# tar -zxvf nagios-plugins-1.4.14.tar.gz -C /usr/src/# cd /usr/src/nagios-plugins-1.4.14/# ./configure --with-nagios-user=nagios --with-nagios-group=nagios # make# make install# chown -R nagios.nagios /usr/local/nagios/# cd /usr/local/nagios/2、安装nagios-nrpe# tar -zxvf nagios-nrpe_2.8.1.orig.tar.gz -C /usr/src/# cd /usr/src/nrpe-2.8.1/# ./configure --enable-ssl --with-ssl-lib=/usr/lib# make all# make install-plugin# make install-daemon# make install-daemon-config# vim /usr/local/nagios/etc/nrpe.cfg72 allowed_hosts=172.24.0.1# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d 启动nrpe # netstat -tulnp | grep 5666 验证nrpe服务器测试# /usr/local/nagios/libexec/check_nrpe -H 172.24.0.2NRPE v2.8.1客户端配置监控对象# vim /usr/local/nagios/etc/nrpe.cfg这一步是关键,如果nagios服务器想要监控客户机swap分区,但客户机nrpe.cfg文件没有swap监控对像,这时监控服务器就是报错(NRPE command ‘check_swap’no defined)至此,查看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监控系统安装及配置文档1.版本历史2.格式规范本文用红色字体表示注释,绿色字体为操作命令,如:# vi•/var/qmail/control/badmailfrom这个控制文件是实现拒收邮件功能的,每一个地址要单独一行。
而且,不用重起qmail就能生效。
例如:peng@•• • ----限制一个特定的用户,@••••••••• ----限制整个域中的邮件3.参考文档[1] [2] /4.前言做为系统管理员,管理着几十台或几百台服务器在运行。
一个非常迫切的需求就是希望了解服务器及服务器上运行的服务的运行状况,在服务器或服务出现当机或停止的时候能够第一时间知道,及时处理。
以便最小的减少由此带来的影响和损失。
Nagios就是用来解决这个问题的,在目前的一些监控软件中,Nagios 以其良好的稳定性,强大的功能等,已成为业界监控软件的首选。
Nagios官方网站的描述:Nagios is an open source host, service and network monitoring program. Who uses it? Lots of people, including many big companies and organizations:Nagios是一个用来监控主机、服务和网络的开放源码软件,很多大的公司或组织都在使用它。
5.Nagios监控原理上图为Nagios监控原理图。
Nagios监控可以使用主动模式(Action)和被动模式(Passive)。
主动模式主要是自身插件或结合Nrpe实现,由Nagios在定义的时间去主动监测被监控端的服务器或服务是否正常。
被动模式结合Naca实现,由Nsca定时监控服务器或服务,再由Nasa把结果传至Nagios。
被动模式适合大规模服务器(一般在最少100台以上)需要监控的情况,可有效减少监控服务器的压力。
在服务器数量比较少的情况下用主动模式比较方便,因为主要的配置在监控主机的设置就好了,无需在被监控端做过多设置。
二. 基本安装和配置本部分主要参考官方文档和田逸的文章<<看我出招之:我用Nagios(技术细节)来修改完成.>>最后达到如下的功能监控机自身的信息,包括主机信息以及对外提供的服务被监控机对外提供的服务如下所有的操作都在监控机192.168.0.111上进行1.安装nagios主程序解压缩tar -zxvf nagios-2.9.tar.gzcd nagios-2.9编译,指定安装目录为/usr/local/nagios./configure --prefix=/usr/local/nagios输出如下信息*** Configuration summary for nagios 2.9 04-10-2007 ***:General Options:-------------------------Nagios executable: nagiosNagios user/group: nagios,nagiosCommand user/group: nagios,nagiosEmbedded Perl: noEvent Broker: yesInstall ${prefix}: /usr/local/nagiosLock file: ${prefix}/var/nagios.lockInit directory: /etc/rc.d/init.dHost OS: linux-gnuWeb Interface Options:------------------------HTML URL: [url]http://localhost/nagios/[/url]CGI URL: [url]http://localhost/nagios/cgi-bin/[/url] Traceroute (used by WAP): /usr/sbin/tracerouteReview the options above for accuracy. If they look okay,type 'make all' to compile the main program and CGIs.make all输出如下信息*** Compile finished ***If the main program and CGIs compiled without any errors, youcan continue with installing Nagios as follows (type 'make'without any arguments for a list of all possible options):make install- This installs the main program, CGIs, and HTML files使用make install来安装主程序,CGI和HTML文件make install-init- This installs the init script in /etc/rc.d/init.d使用make install-init在/etc/rc.d/init.d安装启动脚本make install-commandmode- This installs and configures permissions on thedirectory for holding the external command file使用make install-commandmode来配置目录权限make install-config- This installs *SAMPLE* config files in /usr/local/nagios/etcYou'll have to modify these sample files before you canuse Nagios. Read the HTML documentation for more infoon doing this. Pay particular attention to the docs onobject configuration files, as they determine what/howthings get monitored!使用make install-commandmode来安装示例配置文件,安装的路径是/usr/local/nagios/etc. *** Support Notes *******************************************If you have questions about configuring or running Nagios,please make sure that you:- Look at the sample config files- Read the HTML documentation- Read the FAQs online at [url]/faqs[/url]before you post a question to one of the mailing lists.Also make sure to include pertinent information that couldhelp others help you. This might include:- What version of Nagios you are using- What version of the plugins you are using- Relevant snippets from your config files- Relevant error messages from the Nagios log fileFor more information on obtaining support for Nagios, visit:[url]/support/[/url]*************************************************************Enjoy.很多人都不注意安装过程中的输出信息,直到make install出错了才到处找人求救,而实际上输出的内容包含很多有价值的信息,例如安装路径,版本,每一步做什么,接下来的步骤等.尤其是输出的最后一屏信息,我个人建议好好的读一下.例如上面就列出了很多有价值的信息,我们只需要按照他说的做就行了.安装make install输出如下错误cd ./base && make installmake[1]: Entering directory `/home/yahoon/nagios/nagios-2.9/base'make install-basicmake[2]: Entering directory `/home/yahoon/nagios/nagios-2.9/base'/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin/usr/bin/install: invalid user `nagios' 非法用户nagiosmake[2]: *** [install-basic] Error 1make[2]: Leaving directory `/home/yahoon/nagios/nagios-2.9/base'make[1]: *** [install] Error 2make[1]: Leaving directory `/home/yahoon/nagios/nagios-2.9/base'make: *** [install] Error 2按照文档说明增加用户,修改权限[root@localhost nagios-2.9]# useradd nagios[root@localhost nagios-2.9]# mkdir /usr/local/nagios[root@localhost nagios-2.9]# chown nagios.nagios /usr/local/nagios 查看目录权限[root@localhost nagios-2.9]# ll /usr/localdrwxr-sr-x 2 nagios nagios 4096 Jul 10 11:14 nagios看到nagios目录的权限已经被正确修改了重新执行make install输出信息如下*** Main program, CGIs and HTML files installed ***You can continue with installing Nagios as follows (type 'make'without any arguments for a list of all possible options):make install-init- This installs the init script in /etc/rc.d/init.dmake install-commandmode- This installs and configures permissions on thedirectory for holding the external command filemake install-config- This installs *SAMPLE* config files in /usr/local/nagios/etcYou'll have to modify these sample files before you canuse Nagios. Read the HTML documentation for more infoon doing this. Pay particular attention to the docs onobject configuration files, as they determine what/howthings get monitored!make[1]: Leaving directory `/home/yahoon/nagios/nagios-2.9'执行如下命令来安装脚本make install-init执行make install-commandmode输出信息如下/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw chmod g+s /usr/local/nagios/var/rw*** External command directory configured ***You can continue with installing Nagios as follows (type 'make'without any arguments for a list of all possible options):make install-config- This installs *SAMPLE* config files in /usr/local/nagios/etcYou'll have to modify these sample files before you canuse Nagios. Read the HTML documentation for more infoon doing this. Pay particular attention to the docs onobject configuration files, as they determine what/howthings get monitored!执行make install-config输出信息如下/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/usr/bin/install -c -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg-sample/usr/bin/install -c -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg-sample/usr/bin/install -c -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg-sample/usr/bin/install -c -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/localhost.cfg-sample/usr/bin/install -c -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/commands.cfg-sample*** Sample config file installed ***Remember, these are *SAMPLE* config files. You'll need to readthe documentation for more information on how to actually defineservices, hosts, etc. to fit your particular needs.If you have questions about configuring Nagios properly, please:- Look at the sample config files- Read the HTML documentation- Read the FAQs online at [url]/faqs[/url]*BEFORE* you post a question to one of the mailing lists.验证程序是否被正确安装。
简单介绍nagiosnagios是一款开源的监控软件,能够对网络内的主机和硬件设备进行状态监控。
功能:1. 状态监控2. 预警报告3. 集中,规模化管理4. web可视化显示方式5. 自定义shell脚本或插件实现更多的功能nagios的实现方式:nagios采用分布-集中的管理模式。
在nagios服务器上安装nagios主程序,在被监控主机上安装nagios代理程序。
通过nagios主程序和nagios代理程序之间的通讯,监视主机状态。
主程序和代理程序之间有两种工作方式,一种是主程序-->Active-->代理程序;另一种是主程序-->passive-->代理程序;顾名思义,是以一方向另一方主动提出通讯需求来划分的。
所需软件:系统:Redhat AS 4nagios-3.1.0.tar.gzwget /sourceforge/nagios/nagios-3.1.0.tar.gznagios-plugins-1.4.13.tar.gzwget /sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz nrpe-2.12.tar.gz官方下载:wget/sourceforge/nagios/nagios-3.1.0.tar.gz wget/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz实现要求:在一台机器上面监控多台运行主机状态,所以安装步骤为首先安装监控机器,再配置监控机器,最后安装被监控端软件。
一.安装监控中心(server端)一.nagios 安装[code]tar zxf nagios-3.1.0.tar.gzuseradd nagioscd nagios-3.1.0./configure --prefix=/usr/local/nagios --with-gd-lib=/usr/local/lib --with-gd-inc=/usr/local/includemake all && make installmake install-init && make install-commandmode && make install-configchown -R nagios.nagios /usr/local/nagios2.安装nagios-pluginstar zxf nagios-plugins-1.4.13.tar.gzcd nagios-plugins-1.4.13./configure --prefix=/usr/local/nagios --enable-redhat-pthread-workaroundmake all && make install(在redhat系统上面安装可能出现configure时,到这里checking for redhat spopenproblem...就不动了,所以需要在configure时再加上这个--enable-redhat-pthread-workaround 3安装imagepak-base.tar.gzwget /distfiles/imagepak-base.tar.gztar zxf imagepak-base.tar.gz解压以后是base目录cp -r base /usr/local/nagios/share/images/logos/4监控的机器上需要安装nrpewget /project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz tar xzf nrpe-2.12.tar.gzcd nrpe-2.12./configure --enable-ssl --enable-command-argsmake allmake install-pluginmake install-daemonmake install-daemon-config二 .配置apache在httpd.conf中追加ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/<Directory "/usr/local/nagios/sbin/">AllowOverride AuthConfigOptions ExecCGIOrder allow,denyAllow from all</Directory>Alias /nagios/ /usr/local/nagios/share/<Directory "/usr/local/nagios/share">Options NoneAllowOverride AuthConfigOrder allow,denyAllow from all</Directory>2.配置nagios检查配置文件是否出错/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg出现Total Warnings: 0Total Errors: 0vi /usr/local/nagios/etc/cgi.cfguse_authentication=1改为use_authentication=0,即不用验证.启动后台进程把nagios作为守护进程:/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg/etc/init.d/nagios start此时我们就可以访问nagios监控界面了,访问的方法是http://ip/nagios/安装远程端一.安装nrpeuseradd nagiostar xzf nrpe-2.12.tar.gzcd nrpe-2.12./configure --enable-ssl --enable-command-argsmake all && make install-plugin && make install-daemon && make install-daemon-config2 安装nagios-pluginstar zxf nagios-plugins.tar.gzcd nagios-plugins./configure --prefix=/usr/local/nagios --enable-redhat-pthread-workaroundmake all && make installok,安装好了,可以到/usr/local/nagios/下面检查一下,应该生成了4个目录:bin、etc、libexec、share。
本系列文章旨在记录作者搭建nagios监控的安装及配置步骤,都经过测试,欢迎指正。
nagios简介:Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。
在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
本篇文章将详细说明如何在ubuntu12.04 server 上安装nagios,并监控本机基本信息。
一、准备1.更新ubuntu系统配置好合适的源后/etc/apt/sources.listsudo apt-get updatesudo apt-get upgrade2.依赖软件包:sudo apt-get install build-essentialsudo apt-get install libssl0.9.8 libssl-devopensslsudo apt-get install libgd2-noxpm libgd2-noxpm-devsudo apt-get install apache2(安装完nagios plugin后可以检查一下http,检查:/usr/local/nagios/libexec/check_http -H 127.0.0.1错误结果:Connection refusedHTTP CRITICAL - Unable to open TCP socket启动apache: service apache2 start后再检查,正确结果:HTTP OK: HTTP/1.1 200 OK - 452 bytes in 0.001 second response time|time=0.001221s;;;0.000000 size=452B;;;0 )安装到目录:/usr/bin/htpasswd/usr/sbin/apache2 link/etc/apache2 配置文件httpd.conf在此/usr/lib/apache2 modules 在此/usr/share/apache2/usr/share/man/man8/apache2.8.gzapt-get install php5安装到目录/usr/bin/php5 /etc/php5 /usr/lib/php5 /usr/share/php5/usr/share/man/man1/php5.1.gz二、下面进行nagios的安装以下操作要在root权限用户下进行修改root密码:sudopasswd root设置root密码su切到root用户1.下载nagios软件包下载所需安装包,在/usr/local/src目录下载wget /sourceforge/nagios/nagios-3.2.3.tar.gzwget /sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz wget /sourceforge/nagios/nrpe-2.12.tar.gz2.创建所需用户和组信息groupaddnagcmdgroupaddnagiosuseradd -gnagiosnagios3.安装nagiostar zxvf nagios-3.2.3.tar.gzcd nagios-3.2.3./configure --prefix=/usr/local/nagios --with-command-group=nagcmd终端打印出configure信息:注意关于apache2和mail的配置,以后可能会修改,记住位置:Apache conf.d directory: /etc/apache2/conf.dMail program: /usr/bin/mail编译:make all根据上述提示安装:make installmake install-initmake install-configmake install-commandmodemake install-webconf其中要注意每一步的安装信息,主要是安装目录,方便以后修改。
CentOs 5/6已经测试可用!
Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。
在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
安装完成后的一些情况
Nagios以及插件将安装在/usr/local/nagios目录
Nagios会配置监控本地机器几个方面(CPU负载,磁盘使用率等)
Nagios可以通过http://localhost/nagios/访问
准备工作:需要以root身份安装Nagios。
确保在CentOS安装了下面几个软件包:
Apache
PHP
GCC compiler
GD development libraries
你可以通过yum完成这些安装工作:
1.yum install httpd httpd-devel php openssl-devel
2.yum install gcc glibc glibc-common
3.yum install gd gd-devel
开始安装Nagios
创建帐号
创建 nagios用户:
1./usr/sbin/useradd -m nagios
创建nagcmd用户组以执行来自web接口的命令,并添加nagios和apache用户到此用户组。
1./usr/sbin/groupadd nagcmd
2./usr/sbin/usermod -a -G nagcmd nagios
3./usr/sbin/usermod -a -G nagcmd apache
下载Nagios和插件
创建下载存储目录:
1.mkdir ~/downloads
2.cd ~/downloads
从网站/download/下载Nagios以及插件。
1.wget /project/nagios/nagios-3.x/nagios-3.4.1/nagios-3.4.1.tar.gz
2.wget/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz 编译安装Nagios
1.cd ~/downloads
2.tar xzf nagios-
3.
4.1.tar.gz
3.cd nagios
运行Nagios配置脚本,并把nagcmd更改为之前所创建的组。
1../configure --with-command-group=nagcmd
编译源码:
1.make all
安装二进制,init脚本,sample配置文件和设置外部命令目录权限。
1.make install
2.make install-init
3.make install-config
4.make install-commandmode
不要现在执行nagios,下面还有一些需要配置。
定制配置
样式配置文件已经安装在/usr/local/nagios/etc目录,你仅仅需要更改email地址。
1.vi /usr/local/nagios/etc/objects/contacts.cfg
配置web接口
安装Nagios Web配置文件在Apache的conf.d目录:
1.make install-webconf//此处强烈建议:安装时在nagios目录下执行最好!执行完命令后,执行cp
sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
为登录Nagios Web接口创建nagiosadmin帐号。
记住下面你设置的密码,之后登录用到。
1.htpasswd -c /usr/local/nagios/etc/ers nagiosadmin
重启Apache使新配置生效。
1.service httpd restart
编译安装Nagios插件
1.cd ~/downloads
2.tar xzf nagios-plugins-1.4.16.tar.gz
3.cd nagios-plugins-1.
4.16
4../configure --with-nagios-user=nagios --with-nagios-group=nagios
5.make
6.make install
启动Nagios
设置开机启动:
1.chkconfig --add nagios
2.chkconfig nagios on
测试配置文件是否有错误:
1./usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果没有,立即启动Nagios
1.service nagios start
登录Nagios
安装已经完成,你可以使用nagiosadmin用户以及之前设置的密码通过http://localhost/nagios/地址登录Nagios后台。
下次学习Nagios的使用。
备注:如果出现不能访问情况,请修改iptables!
参考:/docs/nagioscore/3/en/quickstart-fedora.html
转载请标明文章来源:《http://www.centos.bz/2012/02/centos-install-nagios/》。