1、Nagios29详细安装攻略Nagios安装攻略一.准备阶段:1.实验环境包含3台主机,详细信息如下主机名操作系统IP作用nagios-serverredhat 9192.168.0.111监控机dbpiredhat 9192.168.0.100被监控机yahoonxp192.168.0.28被监控机注:监控机:安装了nagios软件的机器,对监控的数据做处理,并且提供web界面查看和管理.当然也可以对本机自身的信息进行监控.被监控机:安装了NRPE等客户端,根据监控机的请求执行监控,然后将结果回传给监控机.2.nagios原理这里引用某位仁兄的话nagios的功能是监控服务和主机,但是他自身
2、并不包括这部分功能的代码,所有的监控、检测功能都是有插件来完成的。再说报警功能,如果监控系统发现问题不能报警那就没有意义了,所以报警也是nagios很重要的功能之一。但是,同样的,nagios自身也没有报警部分的代码,甚至没有插件,而是交给用户或者其他相关开源项目组去完成。nagios安装,是指基本平台,也就是nagios软件包的安装。它是监控体系的框架,也是所有监控的基础。打开nagios官方的文档,会发现nagios基本上没有什么依赖包,只要求系统是linux或者其他nagios支持的系统。不过如果你没有安装apache(http服务),那么你就没有那么直观的界面来查看监控信息了,所以ap
3、ache姑且算是一个前提条件。关于apache的安装,网上有很多,照着安装就是了。安装之后要检查一下是否可以正常工作。原文链接url3.Nagios定义的监控状态nagios定义了4中监控状态,代表不同的严重级别,除了OK代表正常不用关心外,其余3种都要引起重视.如下表状态代码颜色正常OK绿色,警告WARNING黄色,严重CRITICAL红色,未知错误UNKOWN深黄色4.所用软件nagios-2.9.tar.gznagios-plugins-1.4.9.tar.gznrpe-2.8.1.tar.gzNSClient+-0.2.7.zip注:前三个的下载地址:urlhttp:/www.nagi
4、os.org/url,后一个的url5.总体目标学习嘛,总要有个目标,很简单,就是看到下面这张图具体信息如下表主机名要监控的服务nagios-server是否活动是否开启ftp磁盘使用情况dbpi是否活动是否开启ssh磁盘使用情况cpu负载swap分区使用情况主进程数当前登陆用户僵尸进程数yahoon是否活动是否开启80端口是否启动W3SVC服务cpu负载内存使用情况运行时间NSClient客户端版本(NSClient是一个windows下的nagios客户端)C盘使用情况D盘使用情况explorer进程运行情况其中蓝色字体的服务是外部服务,也就是说不需要登陆被监控机,直接在外部就可以进行检查
5、.例如我们需要检查被监控机是否打开80端口,就可以在别的一台机器上telnet被监控机的80端口即可.绿色字体表示是内部服务,意思是必须登陆到被监控机上才能查看.因为它们属于”本地信息”(nagios将之称为LOCAL).很容易理解,你不登陆到被监控机上,如何知道当前磁盘的使用情况呢?nagios是不是很强大,基本上对监控对象的任何信息都可以一手掌握了.而且不用登陆到目的机就可以看到那台机器私密的”本地信息”,比木马还厉害啊.但是别误会,这可不是什么木马.nagios有着十分安全的措施.这确实是一个庞大的工程,你想想这还只是三台机器而已都已经监控这么多服务了,那要是多个几十台怎么办,不用紧张,
6、从现在开始,跟我动手吧.家庭作业,将所用的软件下载好,配置好监控机192.168.0.111上的apache.二.基本安装和配置本部分主要参考官方文档和田逸的文章来修改完成.最后达到如下的功能监控机自身的信息,包括主机信息以及对外提供的服务被监控机对外提供的服务如下所有的操作都在监控机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
7、 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
8、 Options:-HTML URL:urlhttp:/localhost/nagios/urlCGI URL:urlhttp:/localhost/nagios/cgi-bin/urlTraceroute (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 a
9、nd CGIs compiled without any errors, youcan continue with installing Nagios as follows (type makewithout 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 i
10、n /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/etcYoull
11、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.* Suppor
12、t 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 urlhttp:/www.nagios.org/faqs/urlbefore you post a question to one of the mailing lists.Also make sure to include pertin
13、ent 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:u
14、rlhttp:/www.nagios.org/support/url*Enjoy.很多人都不注意安装过程中的输出信息,直到make install出错了才到处找人求救,而实际上输出的内容包含很多有价值的信息,例如安装路径,版本,每一步做什么,接下来的步骤等.尤其是输出的最后一屏信息,我个人建议好好的读一下.例如上面就列出了很多有价值的信息,我们只需要按照他说的做就行了.安装make install输出如下错误cd ./base & make installmake1: Entering directory /home/yahoon/nagios/nagios-2.9/basemake inst
15、all-basicmake2: 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非法用户nagiosmake2: * install-basic Error 1make2: Leaving directory /home/yahoon/nagios/nagios-2.9/basemake1: * install Error
16、2make1: Leaving directory /home/yahoon/nagios/nagios-2.9/basemake: * install Error 2按照文档说明增加用户,修改权限rootlocalhost nagios-2.9#useradd nagiosrootlocalhost nagios-2.9#mkdir /usr/local/nagiosrootlocalhost nagios-2.9#chown nagios.nagios /usr/local/nagios查看目录权限rootlocalhost nagios-2.9# ll /usr/localdrwxr-s
17、r-x2 nagiosnagios4096 Jul 10 11:14 nagios看到nagios目录的权限已经被正确修改了重新执行make install输出信息如下* Main program, CGIs and HTML files installed *You can continue with installing Nagios as follows (type makewithout any arguments for a list of all possible options):make install-init- This installs the init script i
18、n /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/etcYoull have to modify these sample files before you canuse Nagios.Read the HTML do
19、cumentation for more infoon doing this.Pay particular attention to the docs onobject configuration files, as they determine what/howthings get monitored!make1: Leaving directory /home/yahoon/nagios/nagios-2.9执行如下命令来安装脚本make install-init执行make install-commandmode输出信息如下/usr/bin/install -c -m 775 -o na
20、gios -g nagios -d /usr/local/nagios/var/rwchmod g+s /usr/local/nagios/var/rw* External command directory configured *You can continue with installing Nagios as follows (type makewithout any arguments for a list of all possible options):make install-config- This installs *SAMPLE* config files in /usr
21、/local/nagios/etcYoull 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
22、 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 nagio
23、s -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.c
24、fg /usr/local/nagios/etc/commands.cfg-sample* Sample config file installed *Remember, these are *SAMPLE* config files.Youll 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 pr
25、operly, please:- Look at the sample config files- Read the HTML documentation- Read the FAQs online at urlhttp:/www.nagios.org/faqs/url*BEFORE* you post a question to one of the mailing lists.验证程序是否被正确安装。切换目录到安装路径(这里是/usr/local/nagios),看是否存在etc、bin、sbin、share、var这五个目录,如果存在则可以表明程序被正确的安装到系统了。后表是五个目录功能
26、的简要说明:binNagios执行程序所在目录,nagios文件即为主程序etcNagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件sbinNagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录ShareNagios网页文件所在的目录VarNagios日志文件、spid等文件所在的目录var/archivesEmpty directory for thearchived logsvar/rwEmpty directory for theexternal command file2.安装插件解压缩tar -zxvf nagios-plugins-1.4.9
27、.tar.gzcd nagios-plugins-1.4.9编译,指定路径为之前nagios的安装路径./configure -prefix=/usr/local/nagios/make安装make installls /usr/local/nagios/libexec/会显示安装的插件文件,即所有的插件都安装在libexec这个目录下将apache的运行用户加到nagios组里面从httpd.conf中过滤出当前的apache运行用户grep User /usr/local/apache2/conf/httpd.conf我的是vpopmail,下面将这个用户加入nagios组usermod
28、-G nagios vpopmail3.修改apache配置修改apache的配置文件,增加nagios的目录,并且访问此目录需要进行身份验证vi /usr/local/apache2/conf/httpd.conf,在最后增加如下内容#setting for nagios 20070707ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbinOptions ExecCGIAllowOverride NoneOrder allow,denyAllow from allAuthName Nagios AccessAuthType BasicAuthUserFile /usr/local/n
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1