大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

nagiocacti整合配置

所需软件:httpd-2.4.1.tar.gz  MySQL-5.0.96.tar.gz      php-5.3.25.tar.gz

成都创新互联成都企业网站建设服务,提供成都网站设计、成都做网站网站开发,网站定制,建网站,网站搭建,网站设计,成都响应式网站建设公司,网页设计师打造企业风格网站,提供周到的售前咨询和贴心的售后服务。欢迎咨询做网站需要多少钱:18982081108

nagios-3.2.0.tar.gz   nagios-plugins-1.4.16.tar.gz   nrpe-2.12.tar.gz

rrdtool-1.4.8.tar.gz  cacti-0.8.8a.tar.gz   cacti-spine-0.8.8a.tar.gz

ntop-v0.2-1.tgz   monitor-v1.3-1.tgz  ndoutils-1.5.2.tar.gz

npc-2.0.4.tar.gz  json-1.2.1.tgz  PDO_MYSQL-1.0.2.tgz

一.设置lamp环境

编译安装httpd

Shell>tar zxvf httpd-2.4.1.tar.gz

Shell>cd httpd-2.4.1

Shell>./configure  --prefix=/usr/local/apache --enable-so

Shell>make && make install

编译安装msyql

Shell>tar zxvf mysql-5.3.25.tar.gz

Shell>cd mysql-5.3.25

Shell>./configure --prefix=/usr/local/mysql  --enable-thread-safe-client

Shell>make && make install

Shell>groupadd mysql

Shell>useradd mysql -g mysql

Shell>chown -r mysql.mysql /var/lib/mysql

Shell>/usr/local/mysql/bin/mysql_install_db    ##初始化数据库##

Shell>cp support-files/my-medium.cnf /etc/my.cnf

Shell>/usr/local/mysql/bin/mysqld_safe  --defaults-file=/etc/my.cnf  --user=root &  

     ##启动mysql##

Shell>/usr/local/msyql/bin/mysqldadmin -uroot -p 123456     #修改mysql登陆密码##

Shell>ps -ef |grep mysqld    ##查看mysq进程##

编译安装

Shell>tar zxvf php-5.3.25.tar.gz

Shell>cd php-5.3.25

Shell>./confiugre --prefix=/usr/local/php  --with--mysql=/usr/local/mysql  

     --with-apxs2=/usr/local/apache/bin/apxs  --enable-sockets

     --with-config-file-path=/usr/local/php/etc  ##修改php.ini的存放位置##

Shell>make &&  make install

Shell>cp  php.ini-production  /etc/php.ini


安装pdo_mysql扩展模块

Shell>tar zxvf    PDO_MYSQL-1.0.2.tgz

Shell>cd   PDO_MYSQL-1.0.2

Shell>/usr/local/php/bin/phpize

Shell>make && make install

Shell>vim  /usr/local/php/etc/php.ini

     extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626/"

     extension = pdo_mysql.so

重启apahce  查看是否已加载  php  -m |grep pdo-mysql

二、Apache php整合

打开Apache配置文件httpd.conf

添加PHPIniDir "/etc/php.ini"

跳转到373后添加

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

跳转到246行添加index.php

保存退出重启apache  

Shell>/usr/local/apache/bin/apachectl start  

测试apache,php是否整合

Shell>vim /usr/local/apache/htdocs/text.php

Phpinfo;

?>

打开浏览器输入http://ip/test.php,输出php信息说明配置成功

测试php mysql整合

Shell>vim /usr/local/apache/htdocs/test.php

$link=mysql_connect("localhost","root","123456");

if(!$link) echo "FAILD!";

else echo "OK!";

?>

保存退出打开浏览器http://ip/test.php  输出ok说明配置成功

三、安装nagios

Shell>useradd -s /sbin/nologin nagios

Shell>mkdir -p /usr/local/nagios

Shell>chown -R nagios.nagios /usr/local/nagios

Shell>usermod  -G  nagios  -a  apache   ##将apache用户加入到nagios组中

Shell>tar zxvf nagios-3.2.0.tar.gz

Shell>cd nagios-3.2.0

Shell>./configure --prefix=/usr/local/nagios

Shell>make all

Shell>make install

Shell>make install-init

Shell>make install-commandmode

Shell>make install-config

安装nagios插件

Shell>tar zxvf nagios-plugins-1.4.16.tar.gz

Shell>cd nagios-plugins-1.4.16

Shell>./configure --prefix=/usr/local/nagios

Shell>make && make install

打开apache配置文件httpd.conf在末尾添加以后代码:

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

   AuthType Basic

   Options ExecCGI

   AllowOverride None

   Order allow,deny

   Allow from all

   AuthName "Nagios Access"

   AuthUserFile /usr/local/nagios/etc/htpasswd

   Require valid-user

Alias /nagios /usr/local/nagios/share

   AuthType Basic

   Options None

   AllowOverride None

   Order allow,deny

   Allow from all

   AuthName "nagios Access"

   AuthUserFile /usr/local/nagios/etc/htpasswd

   Require valid-user

创建nagios登陆用户

Shell>/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd admin     ##输入登陆密码

修改nagios目录下cgi.cfg

Shell>vim /usr/local/nagios/etc/cgi.cfg

authorized_for_system_information=admin       #多个用户用逗号分隔

authorized_for_configuration_information=admin

authorized_for_system_commands=admin

authorized_for_all_services=admin

authorized_for_all_hosts=admin

authorized_for_all_service_commands=admin

authorized_for_all_host_commands=admin

修改nagios目录下nagios.cfg

command_check_interval=10s    ##检查时间间隔

check_external_commands=1    ##允许web界面下重启、关闭nagios进程等

检查下nagios配置文件是否正确

Shell>/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

修改apache运行的用户

Shell>vim /usr/local/apache/conf/httpd.conf

    User  apache

    Group  apache

启动nagios

Shell>/usr/local/nagios/bin/nagios -d  /usr/local/nagios/etc/nagios.cfg

启动apache

Shell>/usr/local/apache/bin/httpd -k start

打开浏览器输入http://ip/nagios就可以看到nagios的主界面

四、安装nrpe

被监控机上安装

Shell>groupadd nagios

Shell>useradd -g nagios -d  /usr/local/nagios  -s  /sbin/nologin  nagios

Shell>tar zxvf  nagios-plugins-1.4.16.tar.gz

Shell>cd  nagios-plugins-1.4.16

Shell>./configure --prefix=/usr/local/nagios

Shell>make && make install

Shell>tar zxvf nrpe-2.12.tar.gz

Shell>cd nrpe-2.12

Shell>./configure

Shell>make all

Shell>make instlal-plugin

Shell>make install-daemon

Shell> make install-daemon-config

Shell>chown  -R  nagios.nagios  /usr/local/nagios

配置nrpe

Shell>vim /usr/local/nagios/etc/nrpe.cfg

allowed_hosts=127.0.0.1,监控机ip

Shell>echo “nrpe:监控机ip” >>/etc/host.allow

启动nrpe

Shell>/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

Shell>echo “/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d “ >>/etc/rc.local  

    ## 设置开机启动nrpe

检查nrpe是否正常

Shell>netstat -atnlp |grep 5666

Shell>/usr/local/nagios/libexec/check_nrpe -H localhost

    NRPE v2.12                      ##说明nrpe启动成功

监控机上安装

Shell>tar zxvf  nrpe-2.12.tar.gz

Shell>cd nrpe-2.12

Shell>./configure --prefix=/usr/local/nagios

Shell>make

Shell>make install-plugin

测试是否可以连接被监控机

Shell>/usr/local/nagios/libexec/check_nrpe  -H  被监控机ip

     NRPE v2.12                    ##说明可以和被监控机通信

五.安装cacti

安装rrdtool

Shell>tar zxvf  rrdtool-1.4.8.tar.gz

Shell>cd rrdtool-1.4.8

Shell>./configure

Shell>make &&make install

安装net-snmp

Shell>yum install net-snmp* -y

配置mysql

Shell>/usr/local/mysql/bin/mysql -uroot -p

Mysql>create database cactidb;

Mysql>grant all privileges on cactidb.* to “cactier”@”locahost” identified by “123456”

Mysql>grant all privileges on cactidb.* to “cactier”@”localhost” identified by “123456”

配置snmp.conf  (红色字体为修改部分)

Shell>vim /etc/snmp/snmp.conf

    #       sec.name  source          community

    com2sec notConfigUser  default       public

    #       name           incl/excl     subtree         mask(optional)

    view    systemview    included   .1.3.6.1.2.1.1

    view    systemview    included   .1.3.6.1.2.1.25.1.1

    #       group          context sec.model sec.level prefix read   write  notif

    access  notConfigGroup ""      any       noauth    exact all  none  none

    ##           incl/excl subtree                          mask

view all    included  .1                               80

Shell>service snmpd start

安装cacti

Shell>tar zxvf  cacti-0.8.8a.tar.gz

Shell>mv  cacti-0.8.8a   cacti

Shell>mv  cacti  /usr/local/apache/htdocs

Shell>cd /usr/local/apache/htdocs/cacti

Shell>/usr/local/mysql/bin/mysql  -uroot -p  cactidb

Shell>chown -R  cactier /usr/local/apache/htdocs/cacti/rra   /usr/local/apache/htdocs/cacti/log  

编辑cacti/include/config.php文件

Shell>vim /usr/local/apache/htdocs/cacti/config.php

    $database_type = "mysql";

    $database_default = "cactidb";

    $database_hostname = "localhost";

    $database_username = "cactier";

    $database_password = "123456";

    $database_port = "3306";

保存退出

Shell>useradd  cactier

Shell>passwd  cactier

Shell>crontab -u cactier -e

*/1 * * * * *  /usr/bin/php /var/www/html/cacti/poller.php >/dev/null 2>&1  

登陆cacti

打开浏览器输入http://ip/cacti   ---->设置

注意第一次登陆cacti默认用户名和密码为admin,登陆后要修改密码

安装spine

Shell>tar zxvf   cacti-spine-0.8.8a.tar.gz

Shell>cd cacti-spine-0.8.8a

Shell>./configure  --prefix=/usr/local/spine

Shell>make &&make install

Shell>mv /usr/local/spine/etc/spine.conf.dist   /usr/local/spine/etc/spine.conf

Shell>vim /usr/local/spine/etc/spine.conf

     DB_Host         localhost

     DB_Database     cactidb

     DB_User         cactier

     DB_Pass         123456

     DB_Port         3306

     DB_PreG         0

Shell>ln -s  /tmp/mysql.sock   /var/lib/mysql/mysql.sock

设置spine路径,Console——Settings——Paths--->>/usr/local/spine/bin/spine

更改cacti轮询器为spine,Console——Settings——Poller--->>poller type:spine    -->>Poller Interval:every minute   Cron Interval:every minute

Shell>/usr/local/spine/bin/spine

整合ntop monitor到cacti中

Shell>tar zxvf  ntop-4.0.tar.gz

Shell>cd  ntop-4.0

Shell>./autogen.sh

Shell>./configure --prefix=/usr/local/ntop

Shell>make && make install

Shell>chown -R  ntop.ntop  /usr/local/ntop/share/ntop

Shell>chown -R  ntop.ntop  /usr/local/ntop/var/ntop

配置启动ntop

Shell>ntop  -A    输入密码

Shell>n/usr/local/ntop/bin/top -i eth0 -d -L -u ntop

Shell>echo '/usr/local/ntop/bin/ntop -i eth0 -d -L -u ntop &> /dev/null' >> /etc/rc.local

安装ntop插件

Shell>tar zxvf  ntop-v0.2-1.tgz  -C  /usr/local/apache/htdocs/cacti/plugins/

Shell>vim /usr/local/apache/htdocs/cacti/include/config.php

    添加$plugins[] = "ntop";

设置cacti:console---utilities---user managemet---admin---plugin management  view ntop

两个选项选上,保存  console---configureation---plugin management---启用ntop

安装monitor

Shell>tar zxvf  monitor-v1.3-1.tgz  -C  /usr/local/apache/htdocs/cacti/plugins/

Shell>vim /usr/local/apache/htdocs/cacti/include/config.php

   添加$plugins[] = "monitor";

设置cacti:略  (步骤和安装ntop一样)

Nagios、cacti整合

安装ndoutils

Shell>tar zxvf    ndoutils-1.5.2.tar.gz

Shell>cd ndoutils-1.5.2

Shell>./configure --prefix=/usr/local/nagios --enable-mysql --disable-pgsql  

   --with-mysql-inc=/usr/local/mysql/include

   --with-mysql-lib=/usr/local/mysql/lib/mysql

Shell>make  && make install

Shell>cp -v src/{ndomod-3x.o,ndo2db-3x,file2sock,log2ndo} /usr/local/nagios/bin/

Shell>./installdb -ucactier -p123456 -hlocalhost -d cactidb

Shell>cp -v config/{ndo2db.cfg-sample,ndomod.cfg-sample} /usr/local/nagios/etc/

Shell>mv /usr/local/nagios/etc/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg

Shell>mv /usr/local/nagios/etc/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg

Shell>chown -R nagios.nagios /usr/local/nagios/etc/ndo*

Shell>chown -R nagios.nagios /usr/local/nagios/bin/*

Shell>vim /usr/local/nagios/etc/nagios.cfg添加

        broker_module=/usr/local/nagios/bin/ndomod-3x.o

        config_file=/usr/local/nagios/etc/ndomod.cfg

        event_broker_options=-1

Shell>vim /usr/local/nagios/etc/ndo2db.cfg

    socket_type=tcp  

    db_servertype=mysql  

    db_host=localhost  

    db_port=3306  

    db_name=cactidb  

    db_prefix=nagios_  

    db_user=cactier

    db_pass=123456

Shell>vim /usr/local/nagios/etc/ndomod.cfg

      output_type=tcpsocket  

      output=127.0.0.1

Shell>cp ./daemon-init /etc/init.d/ndo2db

Shell> vi /etc/init.d/ndo2db

# 检查里面的路径确保不会出现“//”,并将Ndo2dbBin修改成下面的值:

Ndo2dbBin=/var/www/html/nagios/bin/ndo2db-3x

Shell>chmod +x /etc/init.d/ndo2db

Shell>service ndo2db start

查看是否有错误

Shell>tail -f /var/logl/messages   或者    tail -f  /usr/local/nagios/var/nagios.log

安装npc

Shell> tar zxvf  npc-2.0.4.tar.gz  -C /usr/local/apache/htdocs/cacti/plugins

Shell>vim /usr/local/apache/htdocs/cacti/include/config.php

    添加$plugins[] = 'npc';

安装npc支持json

Shell>tar zxvf  json-1.2.1.tgz

Shell>cd json-1.2.1

Shell>/usr/local/php/bin/phpize

Shell>./configure

Shell>make && make install

安装完后会有类似这样的提示:

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/

查看是否有导入信息

Shell>/usr/local/php/bin/php -i |grep php.ini  

##Configuration File  Loaded Configuration File  php.ini路径

Shell>vim  /etc/php.ini

    添加extension = json.so

查看json是否加载

Shell>/usr/local/php/bin/php -m |grep json  

修改ndo2db.cfg文件

Shell>vim /usr/local/nagios/etc/ndo2db.cfg

     db_prefix=nagios_   修改为db_prefix=npc_

修改cacti npc插件

Console-->settings-->npc -->Remote Commands选项打勾--->输入nagios command file pathc -->输入nagios URL -->host icons   service icons选项打勾

-->logging level  选择DEBUG   保存

修改数据库表结构:

Shell>/usr/local/mysql/bin/mysql  -uroot -p

Msyql>use cactidb;

Msyql>

ALTER TABLE `npc_hostchecks` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_hoststatus` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_servicechecks` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_servicestatus` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_statehistory` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_eventhandlers` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_systemcommands` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_notifications` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

Mysql>exit

重启ndo2db nagios服务

Shell>service  ndo2db  restart

Shell>/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg


当前名称:nagiocacti整合配置
网页地址:http://dzwzjz.com/article/joicih.html
在线咨询
服务热线
服务热线:028-86922220
TOP