博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cacti + nagios + ndoutility + nagvis安装及配置
阅读量:2435 次
发布时间:2019-05-10

本文共 15052 字,大约阅读时间需要 50 分钟。

系统CentOS 5 final

默认安装apache 、php
关闭iptables

iptables - Fchkconfig –level 23456 iptables off

修改/etc/selinux.conf

# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - SELinux is fully disabled.#SELINUX=enforcingSELINUX=disabled# SELINUXTYPE= type of policy in use. Possible values are:# targeted - Only targeted network daemons are protected.# strict - Full SELinux protection.#SELINUXTYPE=targeted

重新启动系统 init 6

用系统光盘安装以下软件

安装net-snmp

rpm -ivh lm_sensors-*rpm -ivh beecrypt-devel-4.1.2-10.1.1.i386.rpmrpm -ivh elfutils-0.125-3.el5.i386.rpm elfutils-libs-0.125-3.el5.i386.rpmrpm -ivh elfutils-devel-*rpm -ivh net-snmp-*

安装MySQL

rpm -e --nodeps mysql-5.0.22-2.1.0.1.i386rpm -ivh MySQL-server-community-5.0.51a-0.rhel5.i386.rpmrpm -ivh MySQL-client-community-5.0.51a-0.rhel5.i386.rpmrpm -ivh MySQL-shared-community-5.0.51a-0.rhel5.i386.rpmrpm -ivh MySQL-shared-compat-5.0.51a-0.rhel5.i386.rpmrpm -ivh MySQL-devel-community-5.0.51a-0.rhel5.i386.rpm

安装php支持

rpm -ivh php-gd-5.1.6-15.el5.i386.rpmrpm -ivh php-mysql-5.1.6-15.el5.i386.rpm php-pdo-5.1.6-15.el5.i386.rpmrpm -ivh php-snmp-5.1.6-15.el5.i386.rpmrpm -ivh php-mbstring-5.1.6-15.el5.i386.rpm
安装gccrpm -ivh cpp-4.1.2-14.el5.i386.rpmrpm -ivh libgomp-4.1.2-14.el5.i386.rpmrpm -ivh gcc-4.1.2-14.el5.i386.rpmrpm -ivh libstdc++-devel-4.1.2-14.el5.i386.rpmrpm -ivh gcc-c++-4.1.2-14.el5.i386.rpm
安装gd-develrpm -ivh freetype-devel-2.2.1-19.el5.i386.rpmrpm -ivh fontconfig-devel-2.4.1-6.el5.i386.rpmrpm -ivh libX11-devel-1.0.3-8.0.1.el5.i386.rpm libXau-devel-1.0.1-3.1.i386.rpm libXdmcp-devel-1.0.1-2.1.i386.rpm xorg-x11-proto-devel-7.1-9.el5.centos.i386.rpm mesa-libGL-devel-6.5.1-7.5.el5.i386.rpmrpm -ivh libXpm-devel-3.5.5-3.i386.rpmrpm -ivh libjpeg-devel-6b-37.i386.rpmrpm -ivh libpng-devel-1.2.10-7.0.2.i386.rpmrpm -ivh gd-devel-2.0.33-9.3.fc6.i386.rpm
安装libtoolrpm -ivh imake-1.0.2-3.i386.rpmrpm -ivh autoconf-2.59-12.noarch.rpmrpm -ivh automake-1.9.6-2.1.noarch.rpmrpm -ivh libtool-1.5.22-6.1.i386.rpmrpm -ivh libtool-ltdl-1.5.22-6.1.i386.rpmrpm -ivh libtool-ltdl-devel-1.5.22-6.1.i386.rpm

设置mysql密码

mysqladmin -uroot password '123456'

修改apache配置

vi /etc/httpd/conf/httpd.confAddType application/x-httpd-php .php .phtml .php3 .php4AddType application/x-httpd-php-source .phps

安装phpmyadmin

tar xzvf phpMyAdmin-2.11.6-english.tar.gzmv phpMyAdmin-2.11.6-english /usr/local/phpMyAdmincd /usr/local/phpMyAdmincp config.sample.inc.php config.inc.phpvi config.inc.php$cfg['blowfish_secret'] = 'somewords';$cfg['Servers'][$i]['controluser'] = 'root';$cfg['Servers'][$i]['controlpass'] = '123456';wqvi /etc/httpd/conf/httpd.confAlias /phpmyadmin /usr/local/phpMyAdmin

在DirectoryIndex 后面加上index.php

http://x.x.x.x/phpmyadmin/index.phphttp://x.x.x.x/phpmyadmin/browse_foreigners.phpservice httpd start

安装Cacti

BUILD_DIR=/tmp/rrdbuildINSTALL_DIR=/usr/local/rrdtoolexport $BUILD_DIRexport $INSTALL_DIRmkdir -p $BUILD_DIRmkdir $BUILD_DIR/lbcd /home/testtar xzvf zlib-1.2.3.tar.gzcd zlib-1.2.3env CFLAGS="-O3 -fPIC" ./configure --prefix=$BUILD_DIR/lbmakemake installcd .. tar xzvf libpng-1.2.26.tar.gzcd libpng-1.2.26env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" /CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lbmakemake installcd .. tar xzvf freetype-2.3.5.tar.gzcd freetype-2.3.5env CPPFLAGS="-I$BUILD_DIR/lb/include" LDFLAGS="-L$BUILD_DIR/lb/lib" CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lbmakemake installcd .. tar xzvf libart_lgpl-2.3.17.tar.gzcd libart_lgpl-2.3.17env CFLAGS="-O3 -fPIC" ./configure --disable-shared --prefix=$BUILD_DIR/lbmakemake installcd .. tar xzvf cgilib-0.5.tar.gzcd cgilib-0.5make CC=gcc CFLAGS="-O3 -fPIC -I."mkdir -p $BUILD_DIR/lb/includecp *.h $BUILD_DIR/lb/includemkdir -p $BUILD_DIR/lb/libcp libcgi* $BUILD_DIR/lb/libcd .. ranlib $BUILD_DIR/lb/lib/*.a # 优化IR=-I$BUILD_DIR/lb/includeCPPFLAGS="$IR $IR/libart-2.0 $IR/freetype2 $IR/libpng"LDFLAGS="-L$BUILD_DIR/lb/lib"CFLAGS=-O3export CPPFLAGS LDFLAGS CFLAGStar xzvf rrdtool-1.2.23.tar.gzcd rrdtool-1.2.23./configure --prefix=$INSTALL_DIR --disable-python --disable-tclmakemake installcd .. tar xzvf cacti-0.8.7b.tar.gzmv cacti-0.8.7b /usr/local/cacticd /usr/local/cacti/mysql -u root -pcreate database cacti;grant all on cacti.* to root;grant all on cacti.* to root@localhost;grant all on cacti.* to cactiuser;grant all on cacti.* to cactiuser@localhost;set password for cactiuser@localhost=password('123456');/qmysql --user=root --password=123456 cacti < cacti.sqlgroupadd cactiuseradd -g cacti cactiuserchown -R cactiuser rra/ log/chmod -R 777 rra/ log/vi include/config.php$database_type = "mysql";$database_default = "cacti";$database_hostname = "localhost";$database_username = "cactiuser";$database_password = "123456";$database_port = "3306";wqvi /etc/crontab*/5 * * * * cactiuser php /usr/local/cacti/poller.php > /dev/null 2>&1wqvi /etc/httpd/conf/httpd.confAlias /cacti /usr/local/cactiwqservice httpd restart

http://x.x.x.x/cacti

选择new install

安装spine

tar xzvf cacti-spine-0.8.7a.tar.gzcd cacti-spine-0.8.7a

编译需要libtool

rpm -ivh imake-1.0.2-3.i386.rpmrpm -ivh autoconf-2.59-12.noarch.rpmrpm -ivh automake-1.9.6-2.1.noarch.rpmrpm -ivh libtool-1.5.22-6.1.i386.rpmrpm -ivh libtool-ltdl-1.5.22-6.1.i386.rpmrpm -ivh libtool-ltdl-devel-1.5.22-6.1.i386.rpm./configuremake

把spine 和spine.conf copy到/usr/local/spine

mkdir /usr/local/spinecp spine spine.conf /usr/local/spine

编辑 spine.conf 文件,输入数据库名、数据库用户名和密码等信息.

指定spine的物理路径
Console -> Configuration -> Settings -> Paths -> Alternate Poller Path -> Spine Poller File Path
路径为/usr/local/spine/spine

Cacti Plugins

Cacti插件是对cacti的扩展。
要使用cacti插件必须先扩展cacti架构,来支持插件。
安装cacti插件架构扩展
下载地址:http://cactiusers.org/downloads/
1).解压下载的tar包,你会得到一个cacti-plugin-arch目录

# tar –zxvf cacti-plugin-arch.tar.gz# cd cacti-plugin-arch# ls

2).安装插件扩展

cp cacti-plugin-0.8.7b-PA-v2.1.diff /usr/local/cacti

//备份cacti目录,以备插件扩展安装失败后能恢复到原状态

cd /usr/localcp –r cacti ./cacti.bakcd ./cacti

//首先使用以下命令进行测试

# patch -p1 -N --dry-run < cacti-plugin-0.8.7b-PA-v2.1.diff

//以上命令成功后,使用以下命令进行安装

# patch -p1 -N < cacti-plugin-0.8.7b-PA-v2.1.diff

将pa.sql导入数据库,支持Plugin Management

mysql --user=root --password=123456 cacti < pa.sql

3).安装后配置,首先查看你的cacti配置文件,看cacti相关的数据库信息是否被覆盖,如果被覆盖请直接从备份中拷贝一份到配置文件目录。

# cp ../include/config.php ./include/config.php

4).修改global.php以正常访问cacti

vi /usr/local/cacti/include/global.php

将$config['url_path'] = “/”;修改为$config['url_path'] = “/cacti/”;

注:如果cacti安装在 /var/www/html下则不用修改global.php

安装插件 下载地址为:http://cactiusers.org/downloads/

安装Monitor

tar xzvf monitor-0.8.2.tar.gzmv monitor /usr/local/cacti/plugins/

安装插件,只需要将插件目录拷贝到cacti/plugins/目录下即可。如果是升级安装,只需要完全覆盖原插件目录即可。

vi /usr/local/cacti/include/global.php

在配置中查找$plugins = array();行,在此行下面加入:

$plugins[] = 'monitor';

注意:上面monitor的名字必须与cacti/plugins/目录下插件目录的名字相同。

在console选项卡下,点击左侧菜单中的Settings链接,在右侧出现的web页中点击Misc选项卡来配置Monitor插件。
在console - User Management – admin – 在View Monitoring前打勾

安装thold

tar xzvf thold-0.3.9.tar.gzmv thold /usr/local/cacti/plugins/tar xzvf settings-0.5.tar.gzmv settings /usr/local/cacti/plugins/vi /usr/local/cacti/include/global.php$plugins[] = ' thold ';$plugins[] = ' settings ';

在console – settings里修改thold相关属性

注:thold要和settings一起安装才能使用
用thold插件监控硬盘实现报警功能
适用版本cacti 0.8.7b
在cacti目录下,vi global_arrays.php
搜索custom_data_source_types,修改这一段如下:

$custom_data_source_types = array("CURRENT_DATA_SOURCE" => "Current Graph Item Data Source","ALL_DATA_SOURCES_NODUPS" => "All Data Sources (Don't Include Duplicates)","ALL_DATA_SOURCES_DUPS" => "All Data Sources (Include Duplicates)","SIMILAR_DATA_SOURCES_NODUPS" => "All Similar Data Sources (Don't Include Duplicates)","SIMILAR_DATA_SOURCES_DUPS" => "All Similar Data Sources (Include Duplicates)","CURRENT_DS_MINIMUM_VALUE" => "Current Data Source Item: Minimum Value","CURRENT_DS_MAXIMUM_VALUE" => "Current Data Source Item: Maximum Value","CURRENT_GRAPH_MINIMUM_VALUE" => "Graph: Lower Limit","CURRENT_GRAPH_MAXIMUM_VALUE" => "Graph: Upper Limit","VALUE_OF_HDD_TOTAL" => "Value of hdd_total data source");

在cacti界面的Graph Management-cdefs新建cdef模块,名字自己起,添加字段如下:

Item #1 Special Data Source: CURRENT_DATA_SOURCEItem #2 Custom String: 100Item #3 Operator: *Item #4 Special Data Source: VALUE_OF_HDD_TOTALItem #5 Operator: /

这样就可以在Threshold Templates里面添加监控硬盘的模块了,我添加的是Host MIB - Hard Drive Space ,最后在Threshold CDEF里面选择刚自定义的cdef,这样就可以正常监控硬盘使用率了。

安装realtime

tar xzvf realtime-0.32.tar.gzmv realtime /usr/local/cacti/plugins/vi /usr/local/cacti/include/global.php$plugins[] = ' realtime ';mkdir /usr/local/cacti/rcachechmod a+wx /usr/local/cacti/rcache

在console – settings – Misc 里修改Cache Directory的路径为/usr/local/cacti/rcache

如果安装0.34版则需要修改

1. poller_rt.php#if (file_exists("./include/global.php")) {
# include("./include/global.php");#} else {
# include("./include/config.php");#} include(dirname(__FILE__) . "/../../include/global.php"); #include_once($config["base_path"] . "/lib/poller.php");#include_once($config["base_path"] . "/lib/data_query.php");#include_once($config["base_path"] . "/lib/graph_export.php");#include_once($config["base_path"] . "/lib/rrd.php"); include_once($config["library_path"] . "/poller.php");include_once($config["library_path"] . "/data_query.php");include_once($config["library_path"] . "/graph_export.php");include_once($config["library_path"] . "/rrd.php");

2. cmd_rt.php

# include("./include/global.php");#} else {
# include("./include/config.php");#} include(dirname(__FILE__) . "/../../include/global.php"); #include_once($config["base_path"] . "/lib/snmp.php");#include_once($config["base_path"] . "/lib/poller.php");#include_once($config["base_path"] . "/lib/rrd.php");#include_once($config["base_path"] . "/lib/ping.php"); include_once($config["library_path"] . "/snmp.php");include_once($config["library_path"] . "/poller.php");include_once($config["library_path"] . "/rrd.php");include_once($config["library_path"] . "/ping.php");

安装syslog

需要的软件syslog-ng 、eventlog 、libol
1. 安装syslog-ng

tar xzvf eventlog-0.2.7.tar.gzcd eventlog-0.2.7./configure --prefix=/usr/local/eventlogmakemake installcd ..tar xzvf libol-0.3.18.tar.gzcd libol-0.3.18./configure --prefix=/usr/local/eventlog/libolmakemake installcd ..tar xzvf syslog-ng-2.0.9.tar.gzcd syslog-ng-2.0.9export PKG_CONFIG_PATH=/usr/local/eventlog/lib/pkgconfig/./configure --prefix=/usr/local/syslog-ngmakemake installmkdir /usr/local/syslog-ng/etc/cp doc/examples/syslog-ng.conf.sample /usr/local/syslog-ng/etc/syslog-ng.conf

修改syslog-ng.conf文件如下:

需要执行的bash文件如下:(脚本文件放在/usr/local/syslog-ng/sbin下)

安装cacti插件syslog

tar xzvf syslog-0.5.2.tar.gzmv syslog-0.5.2 /usr/local/cacti/plugins/syslogvi /usr/local/cacti/include/global.php$plugins[] = ' syslog ';

将syslog的表导入数据库

mysql –u root –puse cacti;source /usr/local/cacti/plugins/syslog/syslog.sql

停止系统自带的syslog

 pkill -9 syslog

启动syslog-ng

/usr/local/syslog-ng/sbin/syslog-ng

启动bash脚本

nohup /usr/local/syslog-ng/sbin/syslog2mysql.sh

安装advanced ping

0.8.7b本身带有ss_fping.php,需要加入一行

vi /usr/local/cacti/scripts/ss_fping.phpinclude_once(dirname(__FILE__) . "/../include/global_settings.php");

然后将xml模板导入到Graph Templates即可使用

NTOP

rpm -ivh libpcap-devel-0.9.4-11.el5.i386.rpmtar xzvf ntop-3.3.6.tar.gzcd ntop./autogen.sh./configure --prefix=/usr/local/ntop --with-rrd-home=/makemake installuseradd ntoppasswd ntopchown -R ntop.ntop /usr/local/ntop/share/ntop/cp packages/RedHat/ntop.conf.sample /usr/local/ntop/etc/ntop/ntop.conf/usr/local/ntop/bin/ntop -P /usr/local/ntop/share/ntop -u ntop –Avi /usr/local/ntop/etc/ntop/ntop.conf

#程序运行用户

–user ntop
#设置ntop为服务
–daemon
#数据文件存放目录
–db-file-path /usr/local/ntop/share/ntop
#监控的网卡
–interface eth0
–trace-level 3
#web访问的端口
–http-server 3000
–disable-schedyield
启动ntop服务,指定读取的配置文件,只监控192.168.1.0/24网段
/usr/local/ntop/bin/ntop @/usr/local/ntop/etc/ntop/ntop.conf -m 192.168.1.0/24
设置开机自启动

vi /etc/rc.local/usr/local/ntop/bin/ntop @/usr/local/ntop/etc/ntop/ntop.conf –m 192.168.1.0/24

Nagios

useradd nagiospasswd nagiosgroupadd nagcmdusermod -G nagcmd nagiosusermod -G nagcmd apachecd /home/test/tar xzvf nagios-3.0b6.tar.gzcd nagios-3.0b6./configure --prefix=/usr/local/nagios --with-gd-lib=/usr/lib --with-gd-inc=/usr/includemake allmake installmake install-initmake install-configmake install-commandmodemake install-webconfhtpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosservice httpd restartcd ..tar xzvf nagios-plugins-1.4.12.tar.gzcd nagios-plugins-1.4.12./configure --with-nagios-user=nagios --with-nagios-group=nagiosmakemake installchkconfig --add nagioschkconfig nagios on/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgIf there are no errors, start Nagios.service nagios startvi /usr/local/nagios/etc/cgi.cfg

将默认的nagiosadmin修改为nagios

一开始会提示“HTTP WARNING: HTTP/1.1 403 Forbidden ”是因为nagios监控/var/www/html/下面的index.html文件,若没有就会提示错误,创建一个文件即可!
vi /var/www/html/index.html
hello !
wq
NdoUtility

rpm -ivh perl-DBD-MySQL-3.0007-1.fc6.i386.rpmexport PERL5LIB=/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/DBDmysql -u root -pcreate database nagios;GRANT ALL ON nagios.* TO nagios@localhost IDENTIFIED BY "123456";/qcd /home/testtar xzvf ndoutils-1.4b7.tar.gzcd ndoutils-1.4b7./configure --with-mysql-lib=/usr/libmakecd db./installdb -u nagios -p 123456 -h localhost -d nagioscd ..cp src/ndomod-3x.o /usr/local/nagios/bin/ndomod.ocp config/ndomod.cfg /usr/local/nagios/etccp src/ndo2db-3x /usr/local/nagios/bin/ndo2dbcp config/ndo2db.cfg /usr/local/nagios/etcvi /usr/local/nagios/etc/ndo2db.cfgdb_user=nagiosdb_pass=123456wq

vi /usr/local/nagios/etc/nagios.cfg

修改如下:

broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg event_broker_options=-1 check_external_commands=1 command_check_interval=10s

启动ndo

/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfgservice nagios restart

tail –f /var/log/messages | grep ndo 查看log

Nagvis

cd /home/testtar xzvf nagvis-1.2.2.tar.gzmv nagvis-1.2.2 /usr/local/nagios/share/nagvisYou should see the directorys etc, nagvis and wui onls -l /usr/local/nagios/share/nagviscd /usr/local/nagios/share/nagviscp etc/nagvis.ini.php-sample etc/nagvis.ini.phpvi etc/nagvis.ini.php

去掉注释

wq
check which unix user account is used to run your webserver (in my case it is apache).

grep -e '^User' /etc/httpd/conf/* chown apache:apache /usr/local/nagios/share/nagvis -Rchmod 664 /usr/local/nagios/share/nagvis/etc/nagvis.ini.phpchmod 775 /usr/local/nagios/share/nagvis/nagvis/images/mapschmod 664 /usr/local/nagios/share/nagvis/nagvis/images/maps/*chmod 775 /usr/local/nagios/share/nagvis/etc/mapschmod 664 /usr/local/nagios/share/nagvis/etc/maps/*

http:///nagvis/config.php

若安装nagvis-1.3需要安装以下rpm用作支持automap

graphviz的rpm包可以到官方网站去下载
http://www.graphviz.org/

rpm -ivh urw-fonts-2.3-6.1.1.noarch.rpmrpm -ivh tk-8.4.13-3.fc6.i386.rpmrpm -ivh graphviz-2.20.2-1.el5.i386.rpmrpm -ivh graphviz-devel-2.20.2-1.el5.i386.rpmrpm -ivh graphviz-doc-2.20.2-1.el5.i386.rpmrpm -ivh graphviz-graphs-2.20.2-1.el5.i386.rpmrpm -ivh graphviz-tcl-2.20.2-1.el5.i386.rpm

转载地址:http://semmb.baihongyu.com/

你可能感兴趣的文章
Symbian OS 开发初级手册(转)
查看>>
限制只能中文输入的方法(转)
查看>>
MySQL进阶SELECT篇(转)
查看>>
SQL Server中死锁产生的原因及解决办法(转)
查看>>
南阳铁通推出宽带“网吧式”服务(转)
查看>>
共享池 shared pool
查看>>
一张图搞定Java面向对象
查看>>
DOORS需求管理工具的其他资料
查看>>
使用 Rational RequisitePro 进行需求管理的新技术
查看>>
最新解决方案助力Borland ALM亚太应用
查看>>
Borland ALM之需求定义和管理解决方案
查看>>
需求管理详解
查看>>
Verizon选择Borland控制开发流程并降低风险
查看>>
Borland 崭新的Caliber Define IT产品
查看>>
IBM Rational RequisitePro集成简介
查看>>
EDS用Borland作为它的全球标准
查看>>
CMMI模型与Rational软件相结合
查看>>
集成 IBM Rational RequisitePro 与 IBM Rational Portfolio Manager
查看>>
OOAD利器Rational Rose的介绍
查看>>
SCA客户端以及基于Java的模型实现(一)
查看>>