设为首页 收藏本站
查看: 931|回复: 0

[经验分享] lamp cacti nagios

[复制链接]
YunVN网友  发表于 2019-1-11 14:03:15 |阅读模式
  gcc gcc-c++ ncurses ncurses-devel gd gd-devel apr apr-devel apr-util apr-util-devel libxml2-devel libmcrypt
curl curl-devel  bzip2-devel  关闭selinux
cacti&&nagios 终极版v0.1
         --------- made by zyt
1. cacti
先lamp环境
1.确认gcc gcc-c++已经安装
先配置yum安装gcc和gcc-c++
把系统默认的那个mv掉
编辑配置文件 /etc/yum.repos.d/CentOS-Media.repo
-------------------------------------------------------
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
---------------------------------------------------------
#mount /dev/cdrom /media
  #yum install gcc gcc-c++
  把 mysql-5.1.55 php-5.2.17 http-2.2.17 放到/home/lamp下
先装mysql
cd /home/lamp
先安装ncurses-devel 否则安装mysql会  
checking for termcap functions library... configure: error: No curses/termcap library found
yum install ncurses-devel
  #tar zxvf mysql-5.1.55.tar.gz
#cd mysql-5.1.55
#   ./configure \
        "--prefix=/usr/local/mysql" \
        "--localstatedir=/var/lib/mysql" \
         "--with-comment=Source" \
        "--with-server-suffix=-Comsenz" \
        "--with-mysqld-user=mysql" \
        "--without-debug" \
        "--with-big-tables" \
         "--with-extra-charsets=all" \
        "--with-pthread" \
        "--enable-static" \
        "--enable-thread-safe-client" \
        "--with-client-ldflags=-all-static" \
        "--with-mysqld-ldflags=-all-static" \
        "--enable-assembler" \
        "--without-ndb-debug"
  
#make && make install
# useradd mysql
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root:mysql .
# chown -R mysql /var/lib/mysql
# cp share/mysql/my-huge.cnf /etc/my.cnf
# bin/mysqld_safe –user=mysql &
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 3 mysqld on
# /etc/rc.d/init.d/mysqld start
# /usr/local/mysql/bin/mysqladmin -u root password 'admin'
#ln -s  /tmp/mysql.sock /var/run/mysql/mysql.sock
  安装snmp
http://sourceforge.net/projects/net-snmp/files/net-snmp/5.5.1/net-snmp-5.5.1.tar.gz/download
http://sourceforge.net/projects/net-snmp/files/net-snmp/5.5.1/net-snmp-5.5.1.tar.gz/download?use_mirror=nchc
放到lamp里
tar zxvf ...
#./configure --prefix=/usr/local/net-snmp --enable-mfd-rewrites --with-default-snmp-version="2" --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/var/net-snmp"  
make
make install
# cp EXAMPLE.conf /usr/local/net-snmp/share/snmp/snmpd.conf
1) 设置监控机的IP或监控机的网段,以及团体字映射到安全名
#       sec.name  source          community
com2sec notConfigUser  default       public
com2sec localhost      localhost      public
com2sec mynetwork      192.168.1.170  public
com2sec mynetwork     192.168.1.0/24     public
2) 映射组名和安全名
####
# Second, map the security name into a group name:
  #       groupName      securityModel securityName
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser
group   MyRWGroup v2c        local
group   MyRWGroup v2c        localhost
group   MyROGroup v2c        mynetwork
  ####
# Third, create a view for us to let the group have rights to:
3)设置mib subtree视图
# Make at least  snmpwalk -v 1 localhost -c public system fast again.
#       name           incl/excl     subtree         mask(optional)
view all  systemview    included   .1                   80
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
  ####
# Finally, grant the group read-only access to the systemview view.
设置read/write权限
#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup ""      any       noauth    exact  systemview none none
access  MyROGroup      ""      any       noauth    exact all    none   none
access  MyRWGroup       ""      any       noauth    exact all    all    none
-----------------------------------------------------------------------------------------------------------
Sec.name是定义的别名,在后面的组中使用,组要用来赋予权限,是只读还是读写,source是允许那个地址来连接你的snmp,我现在写的这个是允许192.168.1.163这个地址来连接,如果你需要使用一个网段的话,那么就可以这么写了192.168.1.0/24,这个看的明白吧,community是共同体的名称,你用client连接snmp使用的,相当于密码
7. net-snmp自动设置
在/etc/rc.local未尾加上这句
/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf &
/usr/local/net-snmp/sbin/snmpd
8.设置环境变量为了下一步的测试命令
9在/etc/profile文件开头加这句
PATH=/usr/local/net-snmp/bin:/usr/local/net-snmp/sbin:$PATH
  # /usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmpd.conf   //启动snmp服务
  
snmp服务就会开机启动
测试:#snmpwalk -v 2c -c zjhcsoft 127.0.0.1 if
如果有数据返回没问题
如果显示超时,那就需要重启服务器
  安装apache的准备工作
==========================
apr-1.4.2.tar.gz
(APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如其名称一样,主要为上层的应用程序提供一个可以跨越多操作系统平台使用的底层支持接口库。)
下载地址:http://apr.apache.org/download.cgi
安装apr-1.4.2.tar.gz
# tar zxvf apr-1.4.2.tar.gz
# cd apr-1.4.2
# ./configure
#make
#make install
  
apr-util-1.3.10.tar.gz
下载地址:http://apr.apache.org/download.cgi
安装apr-util-1.3.10.tar.gz
# tar zxvf apr-util-1.3.10.tar.gz
# cd apr-util-1.3.10
# . /configure --with-apr=/usr/local/apr
# make
# make install
  
1.2.3 httpd-2.2.17.tar.gz
(apr和apache的版本要对应,如果Apache为2.0.x,对应的APR版本应为0.9.x;Apache为2.2.x,对应的APR版本应为1.2以上版本)
下载地址:http://httpd.apache.org/download.cgi
  2.2 安装httpd-2.2.17.tar.gz
# tar zxvf httpd-2.2.17.tar.gz
# ./configure --prefix=/usr/local/apache2 --enable-dav --enable-modules=so --enable-maintainer-mode --enable-rewrite=shared --enable-expires=shared --enable-static-support --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config
  # make
# make install
# echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local
  ===================================================================================================
  GD的安装(php的准备工作)
=====================================================================================================

详细编译安装GD库整个过程,让php对更多图形方面gif jpg(jpeg) png wbmp xml 和 ttf字体 的支持。
我先启动CentOS5.3 Linux
可以说如果要配置一台LAMP服务器,都离不开安装gd库,就算自己php开发不涉及到图形方面,
但是如果使用其他一些php开发的工具也会涉及到。
  我安装的环境是使用 CentOS5.3 Linux 操作系统.
  简单介绍一下gd库:
gd库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成图片。
在网站上GD库通常用来生成缩略图或者用来对图片加水印或者对网站数据生成报表。
也就是有了gd库,我们用php对图片的处理将会得心应手。
  我们先安装ncurses-5.6.tar.gz,安装gd库会用到的
  去下载一个ncurses-5.6.tar.gz
也可以到我们站点下载:http://www.17rumen.com/download/tools/ncurses-5.6.7z
解压密码:www.17rumen.com
  把 ncurses-5.6.tar.gz 放入 webserv 目录, 看上去像我现在这样。
tar zxvf ncurses-5.6.tar.gz
进入目录
cd ncurses-5.6
生成 makefile文件,再进一步编译
./configure --prefix=/usr --with-shared --without-debug
编译,编译时间稍微长些,稍等
make
编译好最后就是安装了
make install
  -------------------------------------------------------------
  下面才开始安装 GD库,安装gd库成功与否,与下面的安装顺序有一定的关系
我们就一步步来演示安装, 下面所有用到的文件,可以到
http://www.17rumen.com/download/tools/gd-all-17rumen.7z 下载
解压密码:www.17rumen.com
解压后就下面所用到的所有文件都在这里了,省得大家到处找,浪费不必要的时间
  把全部的文件 都放进 webserv 目录下
  1:安装zlib2
同样, 在Linux下使用 wget 来下载文件
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
  ---------------------------------
  2:安装PNG
  tar zxvf libpng-1.2.26.tar.gz
cd libpng-1.2.26
  cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
  make
make install
  
---------------------------------
  3:安装ttf ( ttf 是字体的支持 ) freetype
  
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype
  make
make install
  ---------------------------------
  4:安装JPEG6
  
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
  mkdir -pv /usr/local/libjpeg/{,bin,lib,include,man/man1,man1}
上面这个命令具体是实现这样的:
mkdir: created directory `/usr/local/libjpeg'
mkdir: created directory `/usr/local/libjpeg/bin'
mkdir: created directory `/usr/local/libjpeg/lib'
mkdir: created directory `/usr/local/libjpeg/include'
mkdir: created directory `/usr/local/libjpeg/man'
mkdir: created directory `/usr/local/libjpeg/man/man1'
mkdir: created directory `/usr/local/libjpeg/man1'
可以说是一个小小的bug吧,要我们手动建立这些目录,否则configure时候会说找不到目录。
  ./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
  make
make install
  ---------------------------------
  5:安装 libxml2
  tar zxvf libxml2-2.6.31.tar.gz
cd libxml2-2.6.31
./configure --prefix=/usr/local/libxml2
  make
这一步make 操作 时间相对也会比较长,呵呵
  make install
  cp xml2-config /usr/bin
  ---------------------------------
  6:安装 libmcrypt-2.5.7.tar.gz
  tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
  ./configure --prefix=/usr/local/libmcrypt
make
make install
  ---------------------------------
  7:安装Fontconfig
  tar -zxvf fontconfig-2.4.2.tar.gz
cd fontconfig-2.4.2
  可以看到, 参数比较长, 我建议用记事本的朋友不要选择 自动换行。
看我操作, 自动换行 复制过去执行有时会出错。去掉 自动换行
./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config
  这里显示一个错误信息:
checking for LIBXML2... configure: error: Package requirements (libxml-2.0 >= 2.6) were not met:
  No package 'libxml-2.0' found
  Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
  Alternatively, you may set the environment variables LIBXML2_CFLAGS
and LIBXML2_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
  但是我们在上面其实已经安装上 libxml2 了的,这里只是一个 环境变量没有设置好而已。
  解决办法: 确定 /usr/local/libxml2/lib/pkgconfig 目录下有 libxml-2.0.pc
  export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH
  再次生成 makefile , 这样就成功了
  ./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config
好了吧,没有出现那个错误了。
  make
make install
  -============================================================参考资料--------------------------------
------------yum install fontconfig-devel (今天装rrdtool编译没出错,但是在执行rrdtool时提示缺少/usr/local/rrdtool/bin/rrdtool: error while loading shared libraries: libpng15.so.15: cannot open shared object file: No such file or directory
所以用yum安装了cairo-devel包
2.3 安装 rrdtool
在安装rrdtool-1.3X 时需要 cairo 包的支持,而cairo 又需要pango、pixman、pkg-config、glib、
freetype、fontconfig、包的支持

http://oss.oetiker.ch/rrdtool/pub/
命令如下:
# tar zvfx rrdtool-1.2.30.tar.gz
# cd rrdtool-1.2.30
# ./configure  --disable-tcl --disable-python  --prefix=/usr/local/rrdtool
# make
# make install
===========================================
yum install cairo-devel pango pango-devel glib glib-devel 这些装完后就可以装rddtool了
  8:安装GD库,我们把这一步放在最后面
  tar zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/libgd --with-png=/usr/local/ --with-fontconfig --with-freetype=/usr/local/freetype  --with-jpeg=/usr/local/libjpeg --with-fontconfig=/usr/local/fontconfig
  看到下面的信息, 呵呵  很多都显示支持了
Support for PNG library:          yes
Support for JPEG library:         yes
Support for Freetype 2.x library: yes
Support for Fontconfig library:   yes
Support for Xpm library:          no
Support for pthreads:             yes
  
make
make install
  安装CURL =============这个东西如果不装,php的bin下就缺少php等文件 ,还有php的etc文件也没有
tar zxvf curl-7.15.1.tar.gz
cd curl-7.15.1
./configure --prefix=/usr/local/curl
  
-----------------------------------------------------------------------------------------------------------
安装libpng
./configure --prefix=/usr/local/libpng
提示:
  configure: error: ZLib not installed
  在装libpng之前,我先装了zlib。可为什么还是提示找不到呢?
我接着查了资料,有文档说libpng不用configure,是拷贝scripts/makefile.linux
我又执行如下命令:
cp scripts/makefile.linux makefile
make
结果,,出错更多了,。。
  最后的解决方案是:
  1.进入zlib的源文件目录,执行命令 make clean,清除zlib;
  2.重新配置 ./configure,后面不要接--prefix参数;
  3.编辑 && 安装;
  4.进入libpng目录,执行命令 ./configure --prefix=/usr/local/libpng;
  5.编译 && 安装;
  6.安装成功;
========================================================================================---------------------------------------------------------------------------------------
安装php(没有配置fontconfig因为系统已经装了,没解决详细看安装gd)
with-pdo-mysql是cacti里的npc用的没有的话npc不能正常工作
  
编译源文件
./configure '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-config-file-path=/usr/local/php/etc' '--with-pear=/usr/share/php' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-mcrypt=/usr/local/libmcrypt' '--with-zlib-dir=/usr/local/zlib/' '--with-bz2=/usr/local/bzip2/' '--with-libxml-dir=/usr/local/libxml2' --with-gd=/usr/local/libgd '--enable-gd-native-ttf' '--enable-gd-jis-conv' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir=/usr/local/libjpeg' '--with-png-dir' '--with-ttf=shared,/usr' '--enable-mbstring' '--enable-exif' '--with-iconv' '--disable-ipv6' '--enable-static' '--enable-sockets' '--enable-magic-quotes' '--enable-ftp' '--enable-soap' '--with-pdo-mysql=/usr/local/mysql' '--with-curl=/usr/local/curl' --with-snmp=/usr/local/net-snmp
网页显示文件
'./configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-config-file-path=/usr/local/php/etc' '--with-pear=/usr/share/php' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-mcrypt=/usr/local/libmcrypt' '--with-zlib-dir=/usr/local/zlib/' '--with-bz2=/usr/local/bzip2/' '--with-libxml-dir=/usr/local/libxml2' '--with-gd=/usr/local/libgd' '--enable-gd-native-ttf' '--enable-gd-jis-conv' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir=/usr/local/libjpeg' '--with-png-dir' '--with-ttf=shared,/usr' '--enable-mbstring' '--enable-exif' '--with-iconv' '--disable-ipv6' '--enable-static' '--enable-sockets' '--enable-magic-quotes' '--enable-ftp' '--enable-soap' '--with-pdo-mysql=/usr/local/mysql' '--with-curl=/usr/local/curl' '--with-snmp=/usr/local/net-snmp'
make
make install

cp php.ini-dist /usr/local/php/etc/php.ini


  
安装Zend Optimizer
    # cd /usr/local/src
    # tar xzvf ZendOptimizer-3.2.8-linux-glibc21-i386.tar.gz
    # ./ZendOptimizer-3.2.8-linux-glibc21-i386/install.sh
    安装Zend Optimizer过程的最后不要选择重启Apache。
  
收尾工作:
编辑apache的配置文件httpd.conf
vi /etc/httpd/httpd.conf
找到“#AddType application/x-gzip .gz .tgz”
并在后面加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
这两行的目的是让apache识别php。
再找到“DirectoryIndex index.html”
加上 index.php 让它把index.php做为默认页
  6.测试环境:
在/usr/local/apache/htdocs/下面建立php文件。
# vi /usr/local/apache/htdocs/index.php
输入:

重启apache服务器
# /usr/local/apache/bin/apachectl restart
6. 整合Apache与PHP
编辑apache的配置文件httpd.conf
vi /etc/httpd/httpd.conf
找到“#AddType application/x-gzip .gz .tgz”
并在后面加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
这两行的目的是让apache识别php。
再找到“DirectoryIndex index.html”
加上 index.php 让它把index.php做为默认页
  # vi /usr/local/apache2/conf/httpd.conf
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加
AddType application/x-httpd-php .php
  找到:
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
将该行改为
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>
  找到:
#Include conf/extra/httpd-mpm.conf
#Include conf/extra/httpd-info.conf
#Include conf/extra/httpd-vhosts.conf
#Include conf/extra/httpd-default.conf
去掉前面的“#”号,取消注释。
  注意:以上 4 个扩展配置文件中的设置请按照相关原则进行合理配置!
  修改完成后保存退出。
# /usr/local/apache2/bin/apachectl restart

启动httpd出错
==================================================================================================================================================
编译安装php后,重新起动apache出现如下错误:
httpd: Syntax error on line 61 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
  这是由于selinux引起的,所以需要这样一下:
chcon -t textrel_shlib_t libphp5.so
  
原因是Linux有一个SELinux保护模式引起的。
  Syntax error on line 268 of /usr/local/apache2/conf/httpd.conf:
  Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
  解决办法
  2.不关闭SELINUX的方法:
  # setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart
# setenforce 1
  
或者按照以下方法:
  编辑/etc/selinux/config,找到这段:
# 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=enforcing
  把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。
  编辑/etc/sysconfig/selinux,找到:
# 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=enforcing
  如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。
  
安装rddtool
需要先安装
libart
./configure -prefix=/usr/local/libart
已经安装过了freetype了就不需要再装了

安装rrdtool 时的参数

./configure --disable-tcl --disable-python --prefix=/usr/local/rrdtool --with-freetype=/usr/local/include/  --with-libart=/usr/local/libart
  安装cacti


Cacti的安装
1.下载Cacti软件包,并安装到/var/www/html/cacti
wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
tar -xvzf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /var/www/html/cacti
2.配置数据库
mysql -u root -p 123456
mysql> create database cacti;
mysql> grant all privileges on cacti.* to cacti@localhost identified by 'cacti'
with grant option;
mysql> grant all privileges on cacti.* to cacti@127.0.0.1 identified by 'cacti'
with grant option;
mysql>flush privileges;
mysql> use cacti;
mysql> source /var/www/html/cacti/cacti.sql;
3.配置Cacti以连接数据库
vi /var/www/html/cacti/include/config.php 依照如下修改:
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
vi /var/www/html/cacti/include/global.php 依照如下修改:
/* Default database settings*/
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$config['url_path'] = '/cacti/';
4.添加cacti用户
[root@localhost proc]#useradd -s nologin cacti
[root@localhost proc]#passwd cacti
5.修改cacti目录属主
[root@localhost proc]#chown -R cacti:cacti /var/www/html/cacti/
6.编辑crontab
[root@localhost proc]#crontab -e cacti
*/5 * * * *  /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1
/usr/bin/php /usr/local/apache2/
7.关闭SELinux
[root@localhost proc]#setenforce 0
8.用浏览器访问http://localhost/cacti/
若看到以下画面,则可以进行之后的配置(默认用户名、密码:admin)
  装rddtool和版本有关,起先装的1.2.3,怎么也不行,后来装了1.4.4就可以了.人品问题了
  然后需要给rra以及cacti目录权限 属于cacti
  Cacti插件安装及配置
必须现安装好插件扩展PIA 2.8,才能安装、使用其他插件
wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.tar.gz
tar -xvzf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
mv cacti-plugin-arch /var/www/html/cacti/
cd /var/www/html/cacti/
mysql -u root -p 123456 cacti < cacti-plugin-arch/pa.sql
patch -p1 -N < cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.8.diff
rm -rf cacti-plugin-arch
chown -R cacti:cacti /var/www/html/cacti
1. 修改global.php,设定数据库的相关参数,以及config路径.
vi /var/www/html/cacti/include/global.php,修改并增加如下内容:
/* Default database settings*/
$database_type = &quot;mysql&quot;;
$database_default = &quot;cacti&quot;;
$database_hostname = &quot;localhost&quot;;
$database_username = &quot;cacti&quot;;
$database_password = &quot;cacti&quot;;
$database_port = &quot;3306&quot;;
$config['url_path'] = '/cacti/';
$plugins = array();
修改Cacti用户权限,增加插件使用权限
显示 Plugin-Management
User Management -> &quot;admin&quot; or &quot;other user&quot; -> &quot;Realm Permissions&quot; -> &quot;Plugin
安装插件
  a)下载插件
  wget http://cactiusers.org/downloads/settings.tar.gz
  wget http://cactiusers.org/downloads/monitor.tar.gz
  wget http://cactiusers.org/downloads/realtime.tar.gz
  wget http://cactiusers.org/downloads/syslog.tar.gz
  wget http://cactiusers.org/downloads/thold.tar.gz
  wget http://cactiusers.org/downloads/tools.tar.gz
  wget http://cactiusers.org/downloads/update.tar.gz
  wget http://downloads.sourceforge.net/project/cacti-reportit/cacti-reportit/reportit_v061/reportit_v061.tar.gz
  wget http://www.constructaegis.com/downloads/npc-2.0.4.tar.gz
插件都放到plus里

c)修改global.php,增加插件说明
           vi /var/www/html/cacti/include/global.php
           $plugins[] = 'settings';
           $plugins[] = 'thold';
           $plugins[] = 'npc';
           $plugins[] = 'syslog';
           $plugins[] = 'aggregate';
           $plugins[] = 'reportit';
           $plugins[] = 'update';
           $plugins[] = 'tools';
           d)下载安装json(NPC插件需要json支持) 这个默认系统支持
e) 修改权限
          将所有插件mv到/var/www/html/cacti/plugins目录下,然后User Management -> &quot;admin&quot;
or &quot;other user&quot; -> &quot;Realm Permissions&quot; -> &quot;Plugin Management&quot; -> 打勾并保存,
  插件安装排错
a)realtime插件安装问题
realtim插件安装好后,点击web界面的[graphs]页,选一个图,可发现在其右下角已经出
现了一个realtime的logo,但当点此logo进行realtime查看时,会发现弹出的窗口中显示:
“The image cache directory doesn't exist.Please create it and set permissions
and then attempt to open an other realtime graph.”
提示没有Cache目录以及权限等。
解决方案:
[root@localhost proc]#makedir /var/www/html/cacti/cache
[root@localhost proc]#chmod 777 -R /var/www/html/cacti/cache
之后,还要进入console-->configuration-->settings-->misc,设置”Cache Directory”为
/var/www/html/cacti/cache/b)
Syslog插件安装问题
在cacti中访问syslog栏目是会出现以下提示:
1 Warning: include(./include/html/inc_timespan_settings.php) [function.include]:
failed to open stream: No such file or directory in
/var/www/html/plugins/syslog/syslog.php on line 126
2 Warning: include() [function.include]: Failed opening
'./include/html/inc_timespan_settings.php' for inclusion
(include_path='.:/usr/share/pear') in /var/www/html/plugins/syslog/syslog.php on
line 126
只需将/plugins/syslog/syslog.php的第126行
#include($syslog_config[&quot;graphtime&quot;] ? &quot;./include/html/inc_timespan_settings.php&quot;
: &quot;plugins/syslog/html/syslog_timespan_settings.php&quot;);
修改为:
#include($syslog_config[&quot;graphtime&quot;] ?
&quot;./lib/timespan_settings.phpplugins/syslog/html/syslog_timespan_setti
ngs.php&quot;);即可
  、Nagios安装及配置
1. 依赖软件包安装
yum -y install gcc glibc glibc-common gd gd-devel
搭建nagios环境
日期:2010-03-27 作者:root
1.安装nagios
       1)nagios需要一些基础支持套件才能运行,如apache,gcc,glibc,gd库等。
#/usr/sbin/useradd -m nagios   添加一个名为nagios的用户用以专门跑nagios           
#/usr/sbin/groupadd nagios  添加nagios用户组,用以通过web页面提交外部控制命令
#/usr/sbin/usermod -a -G nagios daemon 将运行apache用户daemon加入nagios组
     2)安装nagios
编译nagios前要安装gd-devel否则nagios的map不能显示
在安装nagios时#./configure步骤加一组参数:--with-gd-lib=/usr/local/modules/gd/lib
  原始的Nagios中文版不能绘制中文字符串,与GD的字库处理方式有关。GD有自己的字库文件(点阵形式、ASC码编码)。gdImageString的第二个参数即GD自己的字库的索引,第五个参数则是一个ASC编码的字符串。而GD自己的字库是不支持中文的。显然,大名鼎鼎的GD不可能只支持自己的字库,他用函数gdImageStringFT来支持用外部字库绘制utf-8编码的字符串,这里面包含了中文的支持。
  #tar xzf nagios-cn-3.2tar.gz
#cd nagios-cn-3.2
  yum -y install gcc glibc glibc-common gd gd-devel
  /configure  -prefix=/usr/local/nagios/ --with-nagios-user=nagios  --with-httpd-conf=/usr/local/apache2/conf/extra/ --with-gd=/usr
搭建nagios环境
日期:2010-03-27 作者:root
1.安装nagios
       1)nagios需要一些基础支持套件才能运行,如apache,gcc,glibc,gd库等。
#/usr/sbin/useradd -m nagios   添加一个名为nagios的用户用以专门跑nagios           
#/usr/sbin/groupadd nagios  添加nagios用户组,用以通过web页面提交外部控制命令
#/usr/sbin/usermod -a -G nagios daemon 将运行apache用户daemon加入nagios组
  2)安装nagios
  #tar xzf nagios-cn-3.2tar.gz
#cd nagios-cn-3.2
#./configure --with-command-group=nagios --with-httpd-conf=/usr/local/apache/conf/extra/ --with-apache=/usr/local/apache2 --with-gd
#make all
#make install
#make install-init   
#make install-config
#make install-commandmode
这时nagios基本已经安装完成,默认安装后的配置文件用于启动nagios是没有问题的。
#vi usr/local/nagios/etc/objects/contacts.cfg
修改nagiosadmin这行其中的邮件地址为你的email地址,以将报警邮件发到你的邮箱
#make install-webconf   安装nagios的web接口
#/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
设置登陆web界面时HTTP验证的账号密码
vi /usr/local/apache/conf/httpd.conf
添加一下两行
# nagios  default settings
Include conf/extra/nagios.conf
#/usr/local/apache/bin/apachectl -k restart
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 验证配置文件没问题
#service nagiosrestart  启动nagios
2 安装nagios-plugins
nagios-plugins是nagios官方提供的一套插件程序,nagios监控主机的功能其实都是通过执行插件程序来实现的。
#tar xzf nagios-plugins-1.4.13.tar.gz
#cd nagios-plugins-1.4.13
#./configure –with-nagios-user=nagios –with-nagios-group=nagios
#make
#make install
安装插件,安装后所有插件命令将被安装到/usr/local/nagios/libexec 目录下
编译安装ndoutils  先安装mysql-devel
./configure --prefix=/usr/local/nagios --enable-mysql --disable-pgsql LDFLAGS=-L/usr/local/mysql/lib --with-mysql-inc=/usr/local/mysql/include/mysql --with-mysql-lib=/usr/local/mysql/lib/mysql
  /usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg 向数据库写数据的服务
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
在web上看到这样一个问题,这个是我自己定义在nrpe.cfg里面的,换了N多方式,看了N多文章,都没能找到这个问题出在哪里,百思不得其解。就要把我郁闷死了!!!!!!~~~~
  (硬态 状态) 当前的状态:    紧急     
状态信息: NRPE: Command 'check_disk' not defined
  在命令行下:
[root@nagiosserver etc]# ../libexec/check_nrpe -H 192.168.1.12 -c check_disk
NRPE: Command 'check_disk' not defined
  
在按照别人的步骤一步一步走下来还是出现这样的问题,试验了n多方法之后还是无果。
在今天这个时刻,突然开窍了。
之前怎么就没想到这个需要监控与被监控端命令配置要必须一致,否则就会出现如上的错误。
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  待续................

  2011.3.27 夜
  
nagios
  9. NRPE安装
cd nrpe-2.12
  需要先装openssl openssl-devel
./configuremake all
make  install plugin
make  install-daemon
make  install-daemon-config
  执行
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
  编辑/etc/rc.local,增加如下命令语句:
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
  /usr/local/nagios/libexec/check_nrpe -H localhost
  
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  我在安装nagios过程中, 监控机和被监控机的配置都配好了,可以监控端口了,我在被监控机(192.168.1.113)上装好了nagios-plugin 、nrpe,如下:
[root@yibaner install]# useradd nagios -s /sbin/nologin -M
[root@yibaner install]# tar xvf nagios-plugins-1.4.13.tar
[root@yibaner install]# cd nagios-plugins-1.4.13
[root@yibaner nagios-plugins-1.4.13]# ./configure --prefix=/usr/local/nagios
[root@yibaner nagios-plugins-1.4.13]# make && make install
[root@yibaner nagios-plugins-1.4.13]# chown -R nagios:nagios /usr/local/nagios/     //修改文件权限
(2) nrpe的程序的安装:
[root@yibaner src]# tar zxvf nrpe-2.12.tar.gz
[root@yibaner nrpe-2.12]# cd nrpe-2.12
[root@yibaner nrpe-2.12]# ./configure
[root@yibaner nrpe-2.12]# make all
[root@yibaner nrpe-2.12]# make install-plugin
[root@yibaner nrpe-2.12]# make install-daemon
[root@yibaner nrpe-2.12]# make install-daemon-config   //都没报错
修改nrpe.cfg配置文件
   server_address=127.0.0.1      
    allowed_hosts=192.168.1.115,127.0.0.1   //192.168.1.115是我的监控机
  [root@localhost ~]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@localhost ~]# netstat -apl | grep 5666
tcp        0      0 localhost.localdomain:5666  *:*                         LISTEN      3582/nrpe
   5666端口也开启了,iptables我也关了!
[root@yibaner nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
正常的返回值为被监控服务器上安装的NRPE的版本信息:
NRPE v2.12
  在监控机上我装上了nrpe,安装如下:
[root@server1 yahoon]# tar -zxvf nrpe-2.8.1.tar.gz
[root@server1 yahoon]# cd nrpe-2.8.1
[root@server1 nrpe-2.8.1]# ./configure
[root@server1 nrpe-2.8.1]# make all
[root@server1 nrpe-2.8.1]# make install-plugin     //成功配置,都不报错的
iptables也关了
测试:
[root@server1 nrpe-2.8.1]# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.113    //113是我的被监控机
显示如下:Connection refused by host
  什么原因!谢谢了!非常谢谢!
  
我在115监控机用telnet连113上的5666时出现如下:
[root@localhost nagios]# telnet 192.168.1.113 5666
Trying 192.168.1.113...
telnet: connect to address 192.168.1.113: Connection refused
telnet: Unable to connect to remote host: Connection refused
这是不是说明5666端口关闭了? 可是端口5666确实是开启了,iptables也关了,selinux 也关了 ,两台电脑之间能PING通,我都测试了,这又是什么原因呢?搞晕了!
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  注意,该命令为nagios启动进程,只能有一个在运行.特此声明.
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-662119-1-1.html 上篇帖子: CentOS 5 安装cacti (2) 下篇帖子: Cacti故障排除(1)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表