cacti简介
Cacti是基于PHP/MySQL的开源网络监控及绘图工具,它通过SNMP获取数据并使用RRDTool予以存储,然后在需要时利用RRDTool绘图引擎绘图并通过php展示。
Cacti的操作流程很简单:获取数据-->存储数据-->展示数据。Cacti通过poller获取数据。poller是一个通过调度的方式每隔一段时间(通常为5分钟)执行的程序,它通常通过SNMP来获取远程主机上的数据。
cacti的安装及配置
本文档中的平台是RHEL5.8用到的程序为:
cacti-0.8.8a (安装路径:/web/vhosts/cacti)
httpd-2.4.2 (安装路径:/usr/local/apache)
php-5.4.4 (安装路径:/usr/local/php)
MySQL-5.5.25a (安装路径:/usr/local/mysql)
rrdtool-1.4.7.tar.gz(安装路径:/usr/local/rrdtool)
一、 编译安装lamp平台
(这里不再给出详细步骤,若没有lamp平台以下是一个脚本,执行即可;若已经安装了则跳过此步骤,从“二” 开始即可)
准备工作:
1、若想支持mcrypt扩展,下载libmcrypt-2.5.7-5.el5.i386.rpm libmcrypt-devel-2.5.7- 5.el5.i386.rpm 并安装 rpm -ivh libmcrypt-*
2、提供了一个httpd服务的脚本,如下,放到/root目录下,命名为httpd.sh
注意:要求php在configure时指定了--enable-sockets选项,否则,cacti将无法运行。
- #!/bin/bash
- #
- # httpd Startup script for the Apache HTTP Server
- #
- # chkconfig: - 85 15
- # description: Apache is a World Wide Web server. It is used to serve \
- # HTML files and CGI.
- # processname: httpd
- # config: /etc/httpd/conf/httpd.conf
- # config: /etc/sysconfig/httpd
- # pidfile: /var/run/httpd.pid
- # Source function library.
- . /etc/rc.d/init.d/functions
- if [ -f /etc/sysconfig/httpd ]; then
- . /etc/sysconfig/httpd
- fi
- # Start httpd in the C locale by default.
- HTTPD_LANG=${HTTPD_LANG-"C"}
- # This will prevent initlog from swallowing up a pass-phrase prompt if
- # mod_ssl needs a pass-phrase from the user.
- INITLOG_ARGS=""
- # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
- # with the thread-based "worker" MPM; BE WARNED that some modules may not
- # work correctly with a thread-based MPM; notably PHP will refuse to start.
- # Path to the apachectl script, server binary, and short-form for messages.
- apachectl=/usr/local/apache/bin/apachectl
- httpd=${HTTPD-/usr/local/apache/bin/httpd}
- prog=httpd
- pidfile=${PIDFILE-/var/run/httpd.pid}
- lockfile=${LOCKFILE-/var/lock/subsys/httpd}
- RETVAL=0
- start() {
- echo -n $"Starting $prog: "
- LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && touch ${lockfile}
- return $RETVAL
- }
- stop() {
- echo -n $"Stopping $prog: "
- killproc -p ${pidfile} -d 10 $httpd
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
- }
- reload() {
- echo -n $"Reloading $prog: "
- if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
- RETVAL=$?
- echo $"not reloading due to configuration syntax error"
- failure $"not reloading $httpd due to configuration syntax error"
- else
- killproc -p ${pidfile} $httpd -HUP
- RETVAL=$?
- fi
- echo
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status -p ${pidfile} $httpd
- RETVAL=$?
- ;;
- restart)
- stop
- start
- ;;
- condrestart)
- if [ -f ${pidfile} ] ; then
- stop
- start
- fi
- ;;
- reload)
- reload
- ;;
- graceful|help|configtest|fullstatus)
- $apachectl $@
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
- exit 1
- esac
- exit $RETVAL
接下来就可以执行脚本了
- #!/bin/bash
- #
- <<mark
- prepare the source packages
- apr-1.4.6.tar.bz2
- apr-util-1.4.1.tar.bz2
- httpd-2.4.2.tar.bz2
- cmake-2.8.8.tar.gz
- mysql-5.5.25a.tar.gz
- libmcrypt-2.5.7-5.el5.i386.rpm
- libmcrypt-devel-2.5.7-5.el5.i386.rpm
- php-5.4.4
- mark
- ################compileing httpd######################
- #yum -y groupinstall "Development Libraries" "Development Tools" "X Software Development"
- #setenforce 0
- #mkdir /source
- SOURCE=/source
- SysDir=/etc/rc.d/init.d
- PathDir=/etc/profile
- cd $SOURCE
- wget http://apache.etoak.com//apr/apr-1.4.6.tar.bz2
- wget http://apache.etoak.com//apr/apr-util-1.4.1.tar.bz2
- wget http://apache.etoak.com//httpd/httpd-2.4.2.tar.bz2
- wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
- wget http://anduin.linuxfromscratch.org/sources/BLFS/svn/m/mysql-5.5.25a.tar.gz
- wget http://downloads.php.net/stas/php-5.4.4.tar.bz2
- tar xf apr-1.4.6.tar.bz2
- cd apr-1.4.6
- ./buildconf
- ./configure --prefix=/usr/local/apr
- make
- make install
- cd $SOURCE
- tar xf apr-util-1.4.1.tar.bz2
- cd apr-util-1.4.1
- ./buildconf --with-apr=$SOURCE/apr-1.4.6
- ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
- make
- make install
- cd $SOURCE
- yum -y install pcre-devel
- tar xf httpd-2.4.2.tar.bz2
- cd httpd-2.4.2
- ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-suexec --enable-ssl --enable-rewrite --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-modules-shared=most --enable-mpms-shared=all
- make
- make install
- cd $SOURCE
- echo "PidFile \"/var/run/httpd.pid\" " >> /etc/httpd/httpd.conf
- cp /root/httpd.sh $SysDir/httpd
- chmod +x $SysDir/httpd
- chkconfig --add httpd
- service httpd start
- echo "PATH=\$PATH:/usr/local/apache/bin" >> $PathDir
- export PATH=$PATH:/usr/local/apache/bin
- echo "MANPATH /usr/local/apache/man " >> /etc/man.config
- ln -sv /usr/local/apache/include /usr/include/httpd
- service httpd start
- #########################compileing mysql###################################
- cd $SOURCE
- tar xf cmake-2.8.8.tar.gz
- cd cmake-2.8.8
- ./bootstrap
- make
- make install
- cd $SOURCE
- groupadd -r mysql
- useradd -g mysql -r -d /data/mysql mysql
- tar xf mysql-5.5.25a.tar.gz
- cd mysql-5.5.25a
- cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLE_PROFILING=1
- make
- make install
- cd /usr/local/mysql
- chown -R :mysql .
- mkdir -pv /data/mysql
- chown -R mysql:mysql /data/
- cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
- cp /usr/local/mysql/support-files/mysql.server $SysDir/mysqld
- chmod +x $SysDir/mysqld
- chkconfig --add mysqld
- scripts/mysql_install_db --user=mysql --datadir=/data/mysql
- sed -i '/\[mysqld\]/a \datadir = /data/mysql' /etc/my.cnf
- sed -i 's/thread_concurrency = 8/thread_concurrency = 2/g' /etc/my.cnf
- echo "PATH=\$PATH:/usr/local/mysql/bin" >> $PathDir
- export PATH=$PATH:/usr/local/mysql/bin
- echo "MATHPATH /usr/local/mysql/man" >> /etc/man.config
- ln -sv /usr/local/mysql/include /usr/include/mysql
- echo " /usr/local/mysql/lib " >> /etc/ld.so.conf.d/mysql.conf
- ldconfig
- service mysqld start
- cd
- ##########################compiling php#########################
- cd $SOURCE
- tar xf php-5.4.4.tar.bz2
- cd php-5.4.4
- ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-sockets
- cd $SOURCE
- make
- make install
- cd $SOURCE
- cp php-5.4.4/php.ini-production /etc/php.ini
- echo "AddType application/x-httpd-php .php " >> /etc/httpd/httpd.conf
- echo "AddType application/x-httpd-php-source .phps" >> /etc/httpd/httpd.conf
- sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/g' /etc/httpd/httpd.conf
- service httpd restart
- cd
- echo "The End!"
OK,此时lamp平台架构好了
