【移动应用开发技术】我们来看下 监控软件 Nagios 和 cacti 结合_第1页
【移动应用开发技术】我们来看下 监控软件 Nagios 和 cacti 结合_第2页
【移动应用开发技术】我们来看下 监控软件 Nagios 和 cacti 结合_第3页
【移动应用开发技术】我们来看下 监控软件 Nagios 和 cacti 结合_第4页
【移动应用开发技术】我们来看下 监控软件 Nagios 和 cacti 结合_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

【移动应用开发技术】我们来看下监控软件Nagios和cacti结合

来看下两者区别Cacti:在监控方面绘图比较不错,在流量与图型展现比较存在优势

Nagios:在故障分析比较不错,报警机制相对来说比较好,报警机制:邮箱、短信等,而且也比Cacti灵活;同时适用监控大量服务器以及服务器上面大批服务状态是否正常,重点不在图形化,而在状态故障的监控1.安装相关的软件包[root@WangqiDesktop]#yum-yinstallhttpdphpgccglibcglibc-commongdgd-devellibpnglibjpegzlib2.创建相关的用户和组[root@WangqiLoadBalancer]#useradd-s/sbin/nologinnagios[root@WangqiLoadBalancer]#groupaddnagcmd[root@WangqiLoadBalancer]#usermod-Gnagcmdnagios[root@WangqiLoadBalancer]#usermod-Gnagcmdapache3.安装、编译nagios[root@WangqiDesktop]#tarzxvfnagios-3.2.1.tar.gz-C/usr/src/[root@WangqiDesktop]#cd/usr/src/nagios-3.2.1/[root@Wangqinagios-3.2.1]#./configure--with-command-group=nagcmd[root@Wangqinagios-3.2.1]#makeall[root@Wangqinagios-3.2.1]#makeinstall[root@Wangqinagios-3.2.1]#makeinstall-init[root@Wangqinagios-3.2.1]#makeinstall-config[root@Wangqinagios-3.2.1]#makeinstall-commandmode[root@Wangqinagios-3.2.1]#makeinstall-webconf注释:makeinstall-init是向/etc/rc.d/init.d中安装启动脚本makeinstall-commandmode是将额外的命令文件修改好恰当的权限make

install-config是向/usr/local/nagios/etc目录下写入示例配置文件[root@Wangqinagios-3.2.1]#cd/usr/local/nagios/[root@Wangqinagios]#lsbin测试命令目录etc配置文件目录libexec插件目录

sbin

cgj脚本目录share

nagios网页文件目录varnagios运行总会产生的数据[root@Wangqinagios]#lsetc/cgi.cfg

cgi程序配置文件nagios.cfg

nagios服务主配置文件resource.cfg定义nagios变量文件[root@Wangqinagios]#lsetc/objects/commands.cfg

定义监控命令配置文件localhost.cfg

定义监控本机对象配置文件timeperiods.cfg监控时间模板文件contacts.cfg

指定报警邮件发送邮箱templates.cfg

监控方式模板文件4.安装插件[root@WangqiDesktop]#tar-zxvfnagios-plugins-1.4.14.tar.gz[root@WangqiDesktop]#cdnagios-plugins-1.4.14[root@Wangqinagios-plugins-1.4.14]#./configure--with-nagios-user=nagios--with-nagios-group=nagcmd[root@Wangqinagios-plugins-1.4.14]#make&&makeinstall插件使用:[root@Wangqilibexec]#./check_http--help[root@Wangqilibexec]#./check_http-Hlocalhost-p80[root@Wangqilibexec]#./check_ftp-Hlocalhost-p21[root@Wangqilibexec]#./check_ping-H-w5,10%-c10,20%-p10-t20[root@Wangqilibexec]#htpasswd-cm/usr/local/nagios/etc/htpasswd.usersnagiosadmin5.通过Firefox访问nagios[root@Wangqilibexec]#firefox&/nagiosuser:nagiosadminpassword:1234566.nagios监控本身配置步骤定义监控命令->commands.cfg定义监控对象->localhost.cfg加载监控对象配置文件->nagios.cfg配置登陆页面认证用户->nagios.conf启动nagios服务启动HTTP服务登陆监控页面(1)定义监控命令[root@Wangqinagios]#vimetc/objects/commands.cfg#'check_nfs'commanddefinitiondefinecommand{

command_name

check_nfs

command_line

$UWangqi$/check_tcp-H$HOSTADDRESS$$ARG1$

}[root@Wangqinagios]#vimetc/objects/localhost.cfgdefineservice{

use

local-service

;Nameofservicetemplatetouse

host_name

localhost

service_description

NFS

check_command

check_nfs!2049

notifications_enabled

0

}[root@Wangqinagios]#./bin/nagios-v/usr/local/nagios/etc/nagios.cfg

//检查文件[root@Wangqinagios]#servicenagiosrestart7.配置监控远程主机被监控端(1)安装监控插件[root@WangqiDesktop]#useraddnagios[root@WangqiDesktop]#groupaddnagcmd[root@WangqiDesktop]#usermod-aGnagcmdnagios安装插件[root@Wangqinagios-plugins-1.4.14]#tarzxvfnagios-plugins-1.4.14.tar.gz-C/usr/src/[root@Wangqinagios-plugins-1.4.14]#cd/usr/src/nagios-plugins-1.4.14/[root@Wangqinagios-plugins-1.4.14]#yum-yinstallgccgcc-c++[root@Wangqinagios-plugins-1.4.14]#./configure--with-nagios-user=nagios--with-nagios-group=nagcmd[root@Wangqinagios-plugins-1.4.14]#make&&makeinstall[root@Wangqinagios-plugins-1.4.14]#cd/usr/local/nagios/安装NRPE[root@WangqiDesktop]#tarzxvfnrpe-2.12.tar.gz[root@WangqiDesktop]#cdnrpe-2.12[root@Wangqinrpe-2.12]#yum-yinstallopenssl-devel[root@Wangqinrpe-2.12]#./configure&&

make&&makeinstall[root@Wangqinrpe-2.12]#makeinstall-plugin[root@Wangqinrpe-2.12]#makeinstall-daemon[root@Wangqinrpe-2.12]#makeinstall-daemon-config[root@Wangqinrpe-2.12]#makeinstall-xinetd[root@Wangqietc]#vimnrpe.cfgcommand[check_root]=/usr/local/nagios/libexec/check_disk-w20%-c10%-p/rootcommand[check_boot]=/usr/local/nagios/libexec/check_disk-w20%-c10%-p/boot[root@Wangqietc]#vim/etc/xinetd.d/nrpeonly_from

=[root@Wangqietc]#vim/etc/servicesnrpe

5666/tcp

#nrpe[root@Wangqinrpe-2.12]#yum-yinstallxinetd

//6.5需要安装[root@Wangqinrpe-2.12]#netstat-anptul|grep:5666tcp

0

0:::5666

:::*

LISTEN

51819/xinetd

[root@Wangqinrpe-2.12]#cd/usr/local/nagios/[root@Wangqilibexec]#./check_nrpe-HlocalhostNRPEv2.12监控端(1)安装nrpe[root@WangqiDesktop]#tarzxvfnrpe-2.12.tar.gz[root@WangqiDesktop]#cdnrpe-2.12[root@Wangqinrpe-2.12]#yum-yinstallopenssl-devel[root@Wangqinrpe-2.12]#./configure&&make&&makeinstall[root@Wangqinrpe-2.12]#makeinstall-plugin[root@Wangqilibexec]#./check_nrpe-HNRPEv2.12(2)定义命令[root@Wangqinagios]#vimetc/objects/commands.cfg#'check_nrpe'commanddefinitiondefinecommand{

command_name

check_nrpe

command_line

$UWangqi$/check_nrpe-H$HOSTADDRESS$-c$ARG1$

}[root@Wangqietc]#vimobjects/ser2.cfg

defineservice{

use

local-service

;Nameofservicetemplatetouse

host_name

W

service_description

BootPartition

check_command

check_nrpe!check_boot

}defineservice{

use

local-service

;Nameofservicetemplatetouse

host_name

W

service_description

RootPartition

check_command

check_nrpe!check_root

}[root@Wangqietc]#/usr/local/nagios/bin/nagios-vnagios.cfg[root@Wangqietc]#servicenagiosrestart[root@Wangqilibexec]#firefox&/nagios

六、安装cacti1.安装相关软件包[root@Wangqietc]#yum-yinstallphp-mysqlphp-ldapphp-xmlnet-snmp-utilsmysqlmysql-servernet-snmpcrondrrdtoollm_sensorsrrdtool在RHEL5的光盘中不提供,需要用源码包yuminstall-ygccgcc-c++

libart_lgpl-devel

zlib-devel

libpng-devel

freetype-devel[root@Wangqietc]#servicehttpdstart[root@Wangqietc]#servicemysqldstart2.安装cacti[root@WangqiDesktop]#tarzxvfcacti-0.8.7g.tar.gz[root@WangqiDesktop]#cp-rpcacti-0.8.7g/var/www/html/cacti[root@Wangqihtml]#useraddcactiuser[root@Wangqihtml]#chown-Rcactiuser.cactiuser./cacti/rra[root@Wangqihtml]#chown-Rcactiuser.cactiuser./cacti/rra/cacti/log/[root@Wangqihtml]#mysql-uroot-pmysql>createdatabasecactidbdefaultcharactersetutf8;mysql>showdatabases;mysql>grantalloncactidb.*to'cactiuser'@'localhost'identifiedby'cacti';[root@Wangqicacti]#mysql-ucactiuser-pcacticactidb<cacti.sql[root@Wangqicacti]#viminclude/config.php3.登陆web界面HTTP:///cacti4.被监控端[root@Wangqietc]#vim/etc/snmp/snmpd.conf

com2secnotConfigUserpublicaccess那一行的systemview改成allviewallincluded.1取消注释[root@Wangqietc]#servicesnmpdrestart5.监控端在web页上点击devices,删除原有的localhost,点击右侧的add添加新的主机。HOSTtemplate用ucd/netsnmphostAssociatedDataQueries添加以下的数据SNMP-GetMountedPartitions

SNMP-GetProcessorInformation

SNMP-InterfaceStatistics

保存save后,找到页面最上面的CreateGraphsforthisHost

把主机加入到图形树中点击左侧的graphtree->defaulttree->点击右侧的addtreeitemtype选择host,然后点击create

产生数据[root@localhost~]#su-cactiuser[runct@localhost~]$php/var/www/html/cacti/poller.php

[runct@localhost~]$crontab-e*/1****/usr/bin/php/var/www/html/cacti/poller.php&>/dev/null[runct@localhost~]$exit[root@localhost~]#servicecrondstart隔几分钟后,再点击web页的graph按钮就可以看到图形了[root@Wangqicacti]#servicesnmpdstart6.安装插件框架[root@Wangqicacti]#tarzxvfcacti-plugin-0.8.7g-PA-v2.9.tar.gz[root@Wangqicacti]#mvcacti-plugin-arch/var/www/html/cacti/[root@Wangqicacti]#cd/var/www/html/cacti/[root@Wangqicacti]#patch-p1-N<cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.9.diff[root@Wangqicacti]#mysql-ucactiuser-pcacticactidb<cacti-plugin-arch/pa.sql[root@Wangqicacti]#viminclude/global.php$database_type="mysql";$database_default="cactidb";$database_hostname="localhost";$database_username="cactiuser";$database_password="cacti";$database_port="3306";[root@Wangqicacti]#viminclude/config.php$url_path="/cacti/";WEB页面中左侧的用户管理(usermanagement)->admin用户的权限(下面的PluginManagement)加入PA7.插件安装[root@WangqiDesktop]#tarzxvfsettings-v0.71-1.tgz[root@WangqiDesktop]#tarzxvfmonitor-v1.3-1.tgz[root@WangqiDesktop]#tarzxvfthold-v0.4.9-3.tgz[root@WangqiDesktop]#mvsettingsmonitorthold/var/www/html/cacti/plugins七、整合cacti+nagios1、cacti在监控服务器资源、绘图方面比nagios有优势,但是nagios在监控服务、报警方面是cacti无法替代的。无法仅使用其中一款软件达到所有的要求。cacti可以安装多款插件,其中NagiosPluginforCacti(NPC)可以将nagios的功能以插件的方式在cacti中显示出来。2、nagios本身的插件是二进制可执行文件,运维工程师不具备高级程序语言的编程能力,因此插件改用SHELL脚本实现。整合cacti和nagios是利用了cacti的一个插件nagiosforcacti,它的原理是将nagios的数据通过ndo2db导入到mysql数据库(cacti的库中),然后cacti读取数据库信息将nagios的结果展示出来。1.安装ndoutils首先需要安装ndoutils以将nagios的数据能导入到mysql数据库中[root@localhostcacti]#yum-yinstallmysql-devel[root@Wangqindoutils-1.4b9]#tarzxvfndoutils-1.4b9.tar.gz-C/usr/src/[root@Wangqindoutils-1.4b9]#cd/usr/src/ndoutils-1.4b9/[root@Wangqindoutils-1.4b9]#./configure--prefix=/usr/local/nagios

LDFLAGS=-L/usr/lib--with-mysql-inc=/usr/include/mysql--with-mysql-lib=/usr/lib/mysql--enable-mysql--disable-pgsql

--with-ndo2db-user=nagios--with-ndo2db-group=nagios[root@Wangqindoutils-1.4b9]#make&&makeinstall2.导入数据库[root@Wangqindoutils-1.4b9]#cddb/[root@Wangqidb]#./installdb-ucactiuser-pcacti-hlocalhost-dcactidb3.配置文件[root@Wangqidb]#cd..[root@Wangqindoutils-1.4b9]#cpconfig/ndomod.cfg-sample/usr/local/nagios/etc/ndomod.cfg[root@Wangqindoutils-1.4b9]#vim/usr/local/nagios/etc/nagios.cfgbroker_module=/usr/local/nagios/bin/ndomod.oconfig_file=/usr/local/nagios/etc/ndomod.cfgprocess_performance_data=1[root@Wangqindoutils-1.4b9]#cpconfig/ndo2db.cfg-sample/usr/local/nagios/etc/ndo2db.cfg[root@Wangqindoutils-1.4b9]#grep-v-E'(^$|*#)'/usr/local/nagios/etc/ndomod.cfginstance_name=defaultoutput_type=tcpsocketoutput=tcp_port=5668use_ssl=0output_buffer_items=5000buffer_file=/usr/local/nagios/var/ndomod.tmpfile_rotation_interval=14400file_rotation_timeout=60reconnect_interval=15reconnect_warning_interval=15data_processing_options=-1config_output_options=2[root@Wangqindoutils-1.4b9]#vim

/usr/local/nagios/etc/ndomod.cfg[root@Wangqindoutils-1.4b9]#grep-v-E'(^$|*#)'/usr/local/nagios/etc/ndo2db.cfglock_file=/usr/local/nagios/var/ndo2db.lockndo2db_user=nagiosndo2db_group=nagiossocket_type=tcpsocket_name=/usr/local/nagios/var/ndo.socktcp_port=5668use_ssl=0db_servertype=mysqldb_host=localhostdb_port=3306db_name=cactidbdb_prefix=npc_db_user=cactiuserdb_pass=cactimax_timedevents_age=1440max_systemcommands_age=10080max_servicechecks_age=10080max_hostchecks_age=10080max_eventhandlers_age=44640max_externalcommands_age=44640debug_level=1debug_verbosity=1debug_file=/usr/local/nagios/var/ndo2db.debugmax_debug_file_size=1000000[root@Wangqindoutils-1.4b9]#vim

/usr/local/nagios/etc/ndo2db.cfg

二、安装jsonnpc展示部分用到json,需要在php中安装php-json的支持1、安装php的准备环境[root@localhostnpc]#yuminstall-yphp-devel2、安装json[root@localhostnpc]#tarxvjfphp-json-ext-1.2.1.tar.bz2-C/usr/src/[root@localhostphp-json-ext-1.2.1]#phpize[root@localhostphp-json-ext-1.2.1]#./configure&&make&&makeinstall

3、启用json扩展[root@localhostphp-json-ext-1.2.1]#vim/etc/php.d/json.iniextension=php_json.so[root@localhostphp-json-ext-1.2.1]#ln-s/usr/lib64/php/modules/json.so/usr/lib64/php/modules/php_json.so三、安装npc插件1、安装[root@localhostnpc]#tarxvzfnpc-2.0.4.tar.gz[root@localhostnpc]#mvnpc/var/www/html/cacti/plugins2、在WEB页中启用插件3、配置插件4、注意修改权限[root@localhostnpc]#cd/usr/local/nagios/etc[root@localhostetc]#chmod644ndo2db.cfg

[root@localhostetc]#chmod644ndomod.cfg[root@localhostet

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论