Article title: cacti batch monitors servers and its PHP operating environment. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
This article describes how to configure the PHP + RRDtool environment that supports Cacti operations. Enables centralized monitoring of multiple servers on different platforms. And supports the operating status of SNMP Network devices.
Preface
The Cacti function is similar to the MRTG we are familiar. MRTG is indeed a well-established system monitoring tool. However, due to its long history, it lags behind in many functions and configurations. It is difficult to implement and manage. For example, I have hundreds of monitoring sites distributed in different data centers, and I need to classify these servers and network devices. in this way, I need to put these monitoring sites in different mrtg configuration files, run multiple crontabs and write some html pages to manage them.
Cacti is actually a php program, an rrdtool. It uses snmpget to collect data and rrdtool to plot data. The interface is very beautiful. It provides powerful data management and user management functions. a graph belongs to a host, and each host can be attached to a tree structure.
In terms of user management, as an open-source software, it can specify a "tree", host ", or even each graph that a user can view, and can also be used with LDAP for user verification. Cacti also provides its own template function, allowing you to add your own snmp_query and script. Powerful functions!
The first half of this article is the tutorial, which mainly introduces the installation and configuration of Cacti and its PHP runtime environment. The second part will show how to use Cacti to monitor Linux and Windows. And network devices such as routers that support the SNMP management protocol.
Environment Construction
The Cacit runtime environment must support PHP + Mysql + rrdtool and snmp tools.
Below are the software required for this configuration.
Catci:
Cacti-0.8.6j.tar.gz
Rrdtool-1.2.27.tar
Net-snmp-5.0.9-2.30E.15
Net-snmp-devel-5.0.9-2.30E.15
Net-snmp-libs-5.0.9-2.30E.15
Net-snmp-utils-5.0.9-2.30E.15
PHP:
Php-5.2.6.tar.gz
Curl-7.15.0.tar.gz
Freetype-2.1.9.tar.gz
Gettext-0.16.1.tar.gz
Gd-2.0.35.tar.gz
Jpegsrc.v6b.tar.gz
Libart_lgpl-2.3.17.tar.gz
Libpng-1.2.18.tar.gz
Libxml2-2.6.32.tar.gz
ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
Zlib-1.2.3.tar.gz
Libxml2-2.6.32.tar.gz
Apache:
Httpd-2.2.6.tar.gz
Mysql:
Mysql-5.1.24-rc.tar.gz
Start to build a complete PHP running environment. let's take the newly installed RedHatAs4 updata4 operating system environment as an example.
First, compile and install Apache httpd server
# Tar zxvf httpd-2.2.6.tar.gz
# Cd httpd-2.2.6
#./Configure -- prefix =/usr/local/apache26 -- enable-module = so -- with-mpm = worker -- enable-module = rewrite
# Make & make install
Step 2 install required support plug-ins such as PHP + GD
Compile and install libxml
# Tar zxvf libxml2-2.6.32.tar.gz
# Cd libxml2-2.6.32.tar.gz
#./Configure -- prefix =/usr/local/libxml2/
# Make & make install
Compile and install zlib
# Tar zxvf zlib-1.2.3.tar.gz
# Cd zlib-1.2.3
#./Configure -- prefix =/usr/local/zlib2/
# Make & make install
Compile and install jpeg support
# Tar-zxf restart src.v6b.tar.gz
# Cd jpeg-6b/
#./Configure -- prefix =/usr/local/Issue 6
# Make
# Make install-lib
# Make install
(During the actual installation process of jpeg of this version, several errors may not be found during make install, or the directory does not exist. Follow the prompts to manually create the missing directory, and then make it install until there is no error message and the directory is successfully completed. )
Compile and install libpng
# Tar zxvf libpng-1.2.18.tar.gz
# Cd libpng-1.2.18.tar.gz
# Cp scripts/makefile. gcmmx makefile
#./Configure -- disable-shared -- prefix =/usr/local/libpng2/
# Make & make install
Compile and install freetype
# Tar zxvf freetype-2.1.9.tar.gz
# Cd freetype-2.1.9
#./Configure -- disable-shared -- prefix =/usr/local/freetype2/
# Make & make install
Compile and install libart_lgpl
# Tar zxvf libart_lgpl-2.3.17.tar.gz
# Cd ibart_lgpl-2.3.17
#./Configure -- disable-shared -- prefix =/usr/local/libart/
# Make & make install
Compile and install gettext
# Tar zxvf gettext-0.16.1.tar.gz
# Cd gettext-0.16.1
#./Configure -- prefix =/usr/local/gettext/
# Make & make install
Compile and install the gd Library:
# Tar zxvf gd-2.0.35.tar.gz
# Cd gd-2.0.35
#. /Configure -- prefix =/usr/local/gd2 -- with-zlib =/usr/local/zlib2/-- with-png =/usr/local/libpng2/-- with-jpeg = /usr/local/Release 6/-- with-freetype =/usr/local/freetype2/-- with-libart =/usr/local/libart/-- with-gettext =/usr/local /gettext/-- with-libxml =/usr/local/libxml2
# Make & make install
Support for compiling and installing Curl
# Tar zxvf curl-7.15.0.tar.gz
# Cdcurl-7.15.0
#./Configure -- prefix =/usr/local/curl
# Make & make install
Compile and install PHP
# Tar zxvf php-5.2.6.tar.gz
# Cd php-5.2.6
#. /Configure -- prefix =/usr/local/php -- with-apxs2 =/usr/local/apache26/bin/apxs -- with-jpeg-dir =/usr/local/defaults 6/-- -png-dir =/usr/local/libpng2/-- with-gd =/usr/local/gd2/-- with-freetype-dir =/usr/local/freetype2/-- -zlib-dir =/usr/local/zlib2/-- with-mysql =/usr/local/mysql -- with-curl =/usr/local/curl -- with-gettext =/ usr/local/gettext
# Make & make install
# Cp php. ini-dist/usr/local/php/lib/php. ini (copy the PHP configuration file to the installation directory)
# Vi/usr/local/apach26/conf/httpd. conf (modify the apache configuration file and load PHP support)
There are the following items to change:
Generally, add a line under # AddType application/x-tar. tgz:
# LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php. php
If you do not search for any of the following lines:
LoadModule php5_module modules/libphp5.so
Please remove the # above and find
DirectoryIndex index.html. var
Add index. php to the end to make index. php a response page.
Save the httpd. conf file.
Start apache
#/Usr/local/apache2/bin/apachectl start
If no error occurs, write a test page and put it in your webpage Directory. you can see the php version and other information when accessing it!
Accelerate PHP with ZendOptimizer
# Tar zxvf ZendOptimizer-2.5.3-linux-glibc21-i386.tar.gz
# Cd ZendOptimizer-2.5.3-linux-glibc21-i386
#./Install. sh
During installation, enter the correct path for installing apache!
After installation, check the zend option on the phpinfo page !!
Install MYSQL # groupadd mysql
# Useradd-g mysql
# Tar zxvf mysql-5.1.24-rc.tar.gz
# Cd mysql-5.1.24-rc
#./Configure -- prefix =/usr/local/mysql
-- Localstatedir =/data/mysql (specify the data file directory)
-- Without-innodb -- without-debug -- with-extra-charsets = gbk
-- With-extra-charsets = all -- enable-encryption er -- with-pthread
-- Enable-thread-safe-client -- with-client-ldflags =-all-static
# Make & make install
# Cp./support-files/mysql. server/etc/init. d/mysql (copy Mysql to start the service to the system)
# Chmod 777/etc/init. d/mysql (Grant executable permissions)
# Chown mysql: mysql/data/mysql (set the data file directory attribute)
Setting the directory attribute of a data file is very important. many friends cannot start Mysql because of the directory permission problem when installing Mysql using the tar package for the first time. Very large.
#/Usr/local/mysql/bin/mysql_install_db (Initialize the database)
# Service mysql start (start Mysql)
#/Usr/local/mysql/bin/mysqladmin-u root-p password 'xxxxx' (set the administrator password xxx to null by default)
Now mysql has been installed.
In this way, the PHP + Mysql environment for Cacit running is basically complete.
Install the rrdtools and snmp tools required by Cacit.
Compile and install rrdtools
# Tar zxvf rrdtool-1.2.27.tar
# Cd rrdtool-1.2.27
#./Configure -- prefix =/usr/local/rrdtool
# Make & make install
If the following error occurs during./configure
Configure: error: Please fix the library issues listed above and try again.
Indicates that the system has a function missing, need to install the libart_lgpl-devel.rpm package
If a sample error is prompted, FreeType may not be found.
Copy the. pc file under/usr/local/freetype2/lib/pkgconfig to/usr/lib/pkgconfig.
If the [tclrrd. o] error occurs during make install
Install the tcl-8.4.7-2.i386.rpm and the tcl-devel-8.4.7-2.i386.rpm.
Install the net-snmp, snmpwalk, and snmpget commands
# Rpm-qa | grep net-snmp (check whether the required software is installed in the system)
Net-snmp-5.0.9-2.30E.15
Net-snmp-devel-5.0.9-2.30E.15
Net-snmp-libs-5.0.9-2.30E.15
Net-snmp-utils-5.0.9-2.30E.15
If none or none of them exist, install them one by one.
In addition, it is likely that the rpm dependency cannot be successfully installed. the--nodeps parameter must be used.
The above rpm installation packages can be found on the RedHatAs4 installation disc.
[1] [2] [3] [4] Next page