已阅读5页,还剩9页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Cacti+Nagios完全攻略(二)整合cacti与nagios安装部署 2012-04-05 20:45:52标签:安装 二 完全攻略 休闲 职场Cacti+Nagios完全攻略(二)整合cacti与nagios安装部署Nagios简介Nagios是一个用来监视系统和网络的开源应用软件,它通常运行于一个主服务器上,这个服务器运行 Liunx 或 Unix 操作系统。Nagios 利用其众多的插件实现对本机和远端服务的监控,当被监控对象出现异常,Nagios 就会及时给管理人员告警。它是一个基于TCP/IP协议的软件包,包含有nagios主程序和它的各个插件,配置非常灵活,可以监视的项目很多,也可以通 过自定义 shell 脚本进行监控服务,非常适合各类企业的网络应用。 Nagios功能非常强大,它可以监控服务和主机,但是他自身并不包括这部分功能的代码,所有的监控、检测功能都是有插件来完成的。再说报警功能,如果监 控系统发现问题不能报警那就没有意义了,所以报警也是nagios很重要的功能之一。但是,同样的,nagios自身也没有报警部分的代码,甚至没有插 件,而是交给用户或者其他相关开源项目组去完成。nagios安装,是指基本平台,也就是nagios软件包的安装。它是监控体系的框架,也是所有监控的 基础。 打开nagios官方的文档,会发现nagios基本上没有什么依赖包,只要求系统是linux或者其他nagios支持的系统。不过如果你没有安装 apache(http服务),那么你就没有那么直观的界面来查看监控信息了,所以apache姑且算是一个前提条件。 Nagios 系统的特点主要有下面几点: 监控主机资源和网络服务 允许用户通过设计实现简单的插件来监控自己特定的服务 当被监控对象出现问题时,会及时通知管理人员 事先定义事件处理程序,当对象出现问题时自动调用对应的处理程序 通过 web 页面来监视对象状态,警告提示和日志文件。需要安装软件列表:php-devel-5.1.6-23.2.el5_3.i386.rpmphp-json-ext-1.2.1.tar.bz2cacti-plugin-0.8.7e-PA-v2.6.zipnagios-3.2.1.tar.gznagios-plugins-1.4.14ndoutils-1.4b9.tar.gznpc-2.0.4.tar.gzNagios安装/projects/nagios/files/rootcacti-qmail soft# wget /project/nagios/nagios-3.x/nagios-3.2.1/nagios-3.2.1.tar.gz rootcacti-qmail soft# tar -zxvf nagios-3.2.1.tar.gz rootcacti-qmail soft#cd nagios-3.2.1rootcacti-qmail nagios-3.2.1# ./configure -prefix=/usr/local/nagiosrootcacti-qmail nagios-3.2.1#make all输入make all 得到下面具体信息=* Compile finished *If the main program and 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 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/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-commandmode来安装示例配置文件,安装的路径是/usr/local/nagios/etcmake install-webconf- This installs the Apache config file for the Nagiosweb interface使用make install-webconf来安装apache的配置文件=make install在安装这个动作之前要增加一个nagios用户,并修改它的权限,不然会出现以下错误:=cd ./base & make installmake1: Entering directory /home/yahoon/nagios/nagios-2.9/basemake install-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 2make1: Leaving directory /home/yahoon/nagios/nagios-2.9/basemake: * install Error 2=rootcacti-qmail nagios-3.2.1# useradd nagiosrootcacti-qmail nagios-3.2.1#mkdir /usr/local/nagiosrootcacti-qmail nagios-3.2.1#chown nagios.nagios /usr/local/nagiosrootcacti-qmail nagios-3.2.1#make allrootcacti-qmail nagios-3.2.1#make install; make install-init;make install-commandmode;make install-config;make install-webconf验证程序是否被正确安装切换目录到安装路径(这里是/usr/local/nagios),看是否存在 etc、bin、 sbin、 share、 var这五个目录,如果存在则可以表明程序被正确的安装到系统了。后表是五个目录功能的简要说明:bin Nagios执行程序所在目录,nagios文件即为主程序etc Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件sbin Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录Share Nagios网页文件所在的目录Var Nagios日志文件、spid 等文件所在的目录修改nagios页面文件rootcacti-qmail nagios-3.2.1# more /etc/httpd/conf/nagios.conf# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER# Last Modified: 11-26-2005# This file contains examples of entries that need# to be incorporated into your Apache web server# configuration file. Customize the paths, etc. as# needed to fit your system.ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin# SSLRequireSSLOptions ExecCGIAllowOverride NoneOrder allow,denyAllow from all# Order deny,allow# Deny from all# Allow from AuthName Nagios AccessAuthType BasicAuthUserFile /usr/local/nagios/etc/htpasswd.usersRequire valid-userAlias /nagios /usr/local/nagios/share# SSLRequireSSLOptions NoneAllowOverride NoneOrder allow,denyAllow from all# Order deny,allow# Deny from all# Allow from AuthName Nagios AccessAuthType BasicAuthUserFile /usr/local/nagios/etc/htpasswd.usersRequire valid-user基本上这个文件可以直接使用,所以直接复制过去rootcacti-qmail nagios-3.2.1# cp /etc/httpd/conf/nagios.conf /var/www/html/生成nagios页面访问账号根据这个配置文件中指定的AuthUserFile项,它指定的是通过Apache访问Nagios的合法用户的帐户名单库文件,需要使用 htpasswd命令对这个名单库进行用户的添加。而默认安装环境下在/usr/local/nagios/etc/目录下是没有 htpasswd.uses这个文件的,所以需要手动添加。请特别注意,用root身份建立的htpasswd.user文件的权限问题,应该在建立该文 件完毕后立即更改为nagios用户nagios组的所有权rootcacti-qmail nagios-3.2.1# touch /usr/local/nagios/etc/htpasswd.users建立Nagios的网页访问用户帐户文件(这里必须要与Nagios网页配置文件当中AuthUserFile指定的路径文件名一致)rootcacti-qmail nagios-3.2.1# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.usersviongNew password:Re-type new password:Adding password for user viongrootcacti-qmail nagios-3.2.1# cat /usr/local/nagios/etc/htpasswd.user viong:HbfEis6w0gKqI修改nagios主配置文件 rootcacti-qmail nagios-3.2.1# vi /usr/local/nagios/etc/nagios.cfglog_file=/usr/local/nagios/var/nagios.log( 默认无nagios.log文件,需要手动创建)command_check_interval=15s#command_check_interval=-1设定命令检查的时间间隔,将原来值-1的项注释掉,启用原来备用值为15s(15秒)。这项的时间间隔值请按实际需求情况设定。rootcacti-qmail nagios-3.2.1# touch /usr/local/nagios/var/nagios.log rootcacti-qmail nagios-3.2.1# chown nagios.nagios /usr/local/nagios/var/nagios.log Nagios的CGI配置文件 rootcacti-qmail nagios-3.2.1# vi /usr/local/nagios/etc/cgi.cfguse_authentication=1 (默认是启动身份验证)设定启用身份验证authorized_for_system_information=viong设定系统信息的授权用户authorized_for_configuration_information=viong设定配置信息的授权用户authorized_for_system_commands=viong设定系统命令的授权用户authorized_for_all_services=viong设定全部监测服务的授权用户。authorized_for_all_hosts=viong设定全部被监测主机的授权用户authorized_for_all_service_commands=viong设定全部监测服务命令的授权用authorized_for_all_host_commands=viong设定全部主机命令的授权用户测试nagios是否成功设置nagios为开机启动rootcacti-qmailnagios-plugins-1.4.14#chkconfig nagios onrootcacti-qmailnagios-plugins-1.4.14# service nagios start测试nagios是否成功启动在IE输入 3/nagios/ 跳出以下窗口nagios-plugins插件安装rootcacti-qmail soft#wget/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gzrootcacti-qmail soft# tar -zxvf nagios-plugins-1.4.14.tar.gzrootcacti-qmail nagios-plugins-1.4.14#./configure -prefix=/usr/local/nagios/(注意:安装目录是nagios而不是nagios-plugins的原因是直接把libexec目录的插件覆盖到nagios里面去的)rootcacti-qmail nagios-plugins-1.4.14#make;make installrootcacti-qmail nagios-plugins-1.4.14# grep User /etc/httpd/conf/httpd.conf将apache的运行用户加到nagios组里面,从httpd.conf中过滤出当前的apache运行用户我这里过滤出的用户无,如有用户需要运行以下命令usermod -G nagios 用户名PHP支持JSON扩展PHP必须安装PDO 和 JSON扩展。由于NPC使用了Ext JS,如果没有JSON扩展,NPC的界面不会出来,只能看到一个空白页面。初始化PHP环境 需要用phpize命令,所以也要安装 php-devel。rootcacti-qmail soft#wget /projects/php-json/php-json-ext-1.2.1.tar.bz2rootcacti-qmail soft# tar jxvf php-json-ext-1.2.1.tar.bz2rootcacti-qmail soft# cd php-json-ext-1.2.1rootcacti-qmail php-json-ext-1.2.1# phpize-bash: phpize: command not foundrootcacti-qmail php-json-ext-1.2.1# cd /misc/Server/rootcacti-qmail Server# rpm -ivh php-devel-5.1.6-23.2.el5_3.i386.rpmwarning: php-devel-5.1.6-23.2.el5_3.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186Preparing. # 100%1:php-devel # 100%rootcacti-qmail Server# cd /root/soft/php-json-ext-1.2.1rootcacti-qmail php-json-ext-1.2.1# phpize Configuring for:PHP Api Version: 20041225Zend Module Api No: 20050922Zend Extension Api No: 220051025rootcacti-qmail php-json-ext-1.2.1# ./configure=如果遇到报以下错误,请直接yum install gcc-c+a.configure: error: no acceptable C compiler found in $PATHSee config.log for more details. 请直接yum install gccb.configure: error: C+ preprocessor /lib/cpp fails sanity check =rootcacti-qmail php-json-ext-1.2.1# make;make installrootcacti-qmail php-json-ext-1.2.1# find / -name *json.so/usr/lib/php/modules/json.so/root/soft/php-json-ext-1.2.1/modules/json.so/root/soft/php-json-ext-1.2.1/.libs/json.sorootcacti-qmail php-json-ext-1.2.1# vi /etc/php.d/json.ini添加以下内容extension=json.so保存退出rootcacti-qmail php-json-ext-1.2.1# service httpd restart测试PHP是否支持json扩展rootcacti-qmail php-json-ext-1.2.1#vi /var/www/html/test.php添加以下内容保存退出在IE输入3/test.php 看到以下信息ndoutils安装ndoutils是将Nagios的配置及监控信息存储到数据库里,NPC通过调用ndo所存储的数据来展现 Nagios的信息。ndoutils需要用到mysql的mysql-lib及mysql-inc,因此需要安装mysql-devel。由于刚装系统 的时候已经装过了.这个软件本节就不用安装.rootcacti-qmail soft# tar -zxvf ndoutils-1.4b9.tar.gzrootcacti-qmail soft# cd ndoutils-1.4b9rootcacti-qmail ndoutils-1.4b9#./configure-with-mysql-inc=/usr/include/mysql -with-mysql-lib=/usr/lib/mysql -enable-mysql -with-ndo2db-user=nagios -with-ndo2db-group=nagiosrootcacti-qmail ndoutils-1.4b9#make编译完成后(不需要make install)rootcacti-qmail ndoutils-1.4b9# cd src/rootcacti-qmail src# ll总计 1624-rw-r-r- 1 1001 1001 22480 09-15 20:04 db.c-rw-r-r- 1 root root 145468 03-02 01:54 dbhandlers-2x.o-rw-r-r- 1 root root 145444 03-02 01:54 dbhandlers-3x.o-rw-r-r- 1 1001 1001 169907 10-27 15:51 dbhandlers.c-rw-r-r- 1 root root 37872 03-02 01:54 db.o-rwxr-xr-x 1 root root 31342 03-02 01:54 file2sock-rw-r-r- 1 1001 1001 5421 10-27 16:08 file2sock.c-rw-r-r- 1 1001 1001 11485 10-21 15:53 io.c-rw-r-r- 1 root root 16432 03-02 01:54 io.o-rwxr-xr-x 1 root root 32602 03-02 01:54 log2ndo-rw-r-r- 1 1001 1001 6780 10-27 16:08 log2ndo.c-rw-r-r- 1 root root 4427 03-02 01:53 Makefile-rw-r-r- 1 1001 1001 4336 09-15 20:04 Makefile.in-rwxr-xr-x 1 root root 224645 03-02 01:54 ndo2db-2x-rwxr-xr-x 1 root root 224629 03-02 01:54 ndo2db-3x-rw-r-r- 1 1001 1001 57565 10-27 16:08 ndo2db.c-rwxr-xr-x 1 root root 120333 03-02 01:54 ndomod-2x.o-rwxr-xr-x 1 root root 128498 03-02 01:54 ndomod-3x.o-rw-r-r- 1 1001 1001 136855 10-27 16:08 ndomod.c-rw-r-r- 1 1001 1001 514 2007-01-08 protonum.c-rwxr-xr-x 1 root root 28503 03-02 01:54 sockdebug-rw-r-r- 1 1001 1001 3418 10-27 16:08 sockdebug.c-rw-r-r- 1 1001 1001 4623 2009-07-17 utils.c-rw-r-r- 1 root root 8824 03-02 01:54 utils.o rootcacti-qmail src# cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/bin/rootcacti-qmail src# cd ./configrootcacti-qmail config# ll总计 64-rw- 1 root root 439 03-02 01:53 misccommands.cfg-rw-r-r- 1 1001 1001 427 09-07 04:51 misccommands.cfg.in-rw- 1 root root 566 03-02 01:53 nagios.cfg-rw-r-r- 1 1001 1001 522 09-07 04:51 nagios.cfg.in-rw- 1 root root 4486 03-02 02:06 ndo2db.cfg-rw- 1 root root 4493 03-02 01:53 ndo2db.cfg-sample-rw-r-r- 1 1001 1001 4489 09-15 20:08 ndo2db.cfg-sample.in-rw- 1 root root 5130 03-02 01:59 ndomod.cfg-rw- 1 root root 5130 03-02 01:53 ndomod.cfg-sample-rw-r-r- 1
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年【全】我国服装行业发展现状分析报告
- 鼻假体植入后感染的护理
- 眼伴面三度烧伤的护理课件
- 2026年地方文化活动推广合同
- 活动方案策划文字要求(3篇)
- 重阳节少先队活动策划与实施方案
- 报警器处置管理制度(3篇)
- 雨衣收集活动方案策划(3篇)
- 慈善圣诞活动策划方案(3篇)
- 幼教机构课程设置与教学评估
- 医疗器械不良事件上报培训考试试题含答案
- 2024年开封文化艺术职业学院单招《语文》真题重点附答案详解
- 部编版四年级语文上册第五六单元综合测评(含答案)
- 激光镭雕岗位安全培训课件
- 掘进队长考试题库及答案
- 代收个人居间费合同范本
- 知道智慧树西方经济学实验(山东联盟).满分测试答案
- 小区监控改造升级方案(3篇)
- 医院传染病管理培训课件
- 呼吸科护士轮转工作汇报
- 学堂在线 遥测原理 章节测试答案
评论
0/150
提交评论