Set up cacti on nginx

Source: Internet
Author: User
Tags cairo rrdtool
CactiCacti built on nginx is a set of network traffic monitoring graphical analysis tools developed based on PHP, MySQL, SNMP and RRDTool www.2cto. comCacti and Nagios are now using a large number of network monitoring software. The difference between the two monitoring software should be said to be different in emphasis .... The establishment of cacti Cacti on nginx is a set of network traffic monitoring graphical analysis tools developed based on PHP, MySQL, SNMP and RRDTool www.2cto.com Cacti and Nagios are now using a lot of network monitoring software, the difference between the two monitoring software should be said to be the difference in focus. Cacti focuses on visual data monitoring and is easy to generate images. it is suitable for monitoring network Traffic, cpu usage, and hard disk usage. While Nagios focuses more on host and service monitoring, and has powerful alarm sending functions. By combining the two, the alarm mechanism can be efficient and timely, and various data can be easily viewed. 1. set up cacti 1 on LNMP (linux + nginx + mysql + php. modify selinux vim/etc/selinux/config to selinux = disabled disable firewall service iptables stop chkconfig iptables off restart to bring selinux into effect reboot install compilation tool and library file www.2cto.com for I in 'rpm- q make apr * autoconf automake curl-devel gcc-c ++ zlib-devel openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat * mpfr cpp glibc golibmp libstdc ++-devel ppl clo Og-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm * freetype libjpeg * libpng * php-common php-gd ncurses * libtool * libxml2 libxml2-devel patch | grep not installed '| awk' {print $2 }''; do yum-y install $ I; done install libmcrypt cd/usr/local/srctar zxvf libmcrypt-2.5.7.tar.gzcd libmcrypt-2.5.7. /configuremake & make install cmake cd/usr/local/src Tar zxvf cmake-2.8.7.tar.gzcd cmake-2.8.7. /configuremake & make install pcre cd/usr/local/srcmkdir/usr/local/pcre # Create installation directory tar zxvf pcre-8.30.tar.gzcd pcre-8.30. /configure -- prefix =/usr/local/pcremake & make install mysql groupadd mysql # Add mysql group useradd-g mysql-s/bin/false # create mysql and add it to mysql group, mysql is not allowed to log on to mkdir-p/data/mysql # create the MySQL database storage directory chown-R mysql: mysql/data/mysql # set the MySQL database directory permission m Kdir-p/usr/local/mysql # create the MySQL installation directory cd/usr/local/srctar zxvf mysql-5.5.21.tar.gzcd mysql-5.5.21cmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mysql-DSYSCONFDIR =/etc # configure makemake installcd/usr/local/mysqlcp. /support-files/my-huge.cnf/etc/my. cnf # Copy the configuration file vim/etc/my. cnf # Add datadir =/data/mysql # to the MySQL database path in [mysqld. /scripts/mysql_install_db -- user = mysql # generate mysql system database cp. /Support-files/mysql. server/etc/rc. d/init. d/mysqld # Add Mysql to the system and start chmod 755/etc/init. d/mysqld # Add execution permission chkconfig mysqld on # add to start vim/etc/rc at startup. d/init. d/mysqld # Edit basedir =/usr/local/mysql # MySQL program installation path datadir =/data/mysql # MySQl database storage directory service mysqld start # start vim/etc/profile # add the mysql service to the system environment variable: add the following line of export PATH = $ PATH at the end: /usr/local/mysql/bin to make the environment variable take effect immediately. the following two lines under source/etc/profile link the myslq library file to the default system location and compile the class Software such as PHP may not specify the mysql library file address. Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysqlln-s/usr/local/mysql/include/mysql/usr/include/mysqlreboot # restart mysql_secure_installation # set the Mysql password or directly change the password/usr/local/mysql/bin/mysqladmin-u root-p password "123456" # change the password service mysqld restart # restart (6) install nginx groupadd www # Add useradd-g www-s/bin/false # create an account www and add it to the group, do not allow www direct login cd/usr/local/srctar zxvf nginx-1.0.14.tar.gzcd nginx-1.0.14. /co Nfigure -- prefix =/usr/local/nginx -- user = www -- group = www -- with-http_stub_status_module -- with-openssl =/usr/-- with-pcre =/usr/local/src/ pcre-8.30 # -- with-pcre =/usr/local/src/pcre-8.30 refers to the path to extract the source package, it is not the installation path. otherwise, make & make install/usr/local/nginx/sbin/nginx # start nginx and set nginx to enable vim/etc/rc. d/init. d/nginx # Edit the startup file and add the following content #! /Bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig:-85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile:/var/run/nginx. pid # config:/usr/local/nginx/conf/nginx. confnginxd =/usr/local/nginx/sbin/nginxnginx_config =/usr/local/nginx/conf/nginx. confnginx_pid =/u Sr/local/nginx/logs/nginx. pidRETVAL = 0 prog = "nginx" # Source function library .. /etc/rc. d/init. d/functions # Source networking configuration .. /etc/sysconfig/network # Check that networking is up. [$ {NETWORKING} = "no"] & exit 0 [-x $ nginxd] | exit 0 # Start nginx daemons functions. start () {if [-e $ nginx_pid]; thenecho "nginx already running .... "exit 1 fiecho-n $" Starting $ prog: "daemon $ nginxd-c $ {Nginx_config} RETVAL =$? Echo [$ RETVAL = 0] & touch/var/lock/subsys/nginxreturn $ RETVAL} # Stop nginx daemons functions. stop () {echo-n $ "Stopping $ prog:" killproc $ nginxdRETVAL =$? Echo [$ RETVAL = 0] & rm-f/var/lock/subsys/nginx/usr/local/nginx/logs/nginx. pid} reload () {echo-n $ "Reloading $ prog:" # kill-HUP 'cat $ {nginx_pid} 'killproc $ nginxd-HUPRETVAL =$? Echo} # See how we were called. case "$1" instart) start; stop) stop; reload) reload; restart) stopstart; status) status $ progRETVAL =$ ?;; *) Echo $ "Usage: $ prog {start | stop | restart | reload | status | help}" exit 1 esacexit $ RETVALchmod 775/etc/rc. d/init. d/nginx # grant execution permission chkconfig nginx on # set startup/etc/rc. d/init. d/nginx restartservice nginx restart install php cd/usr/local/srctar-zvxf php-5.3.10.tar.gzcd php-5.3.10mkdir-p/usr/local/php5 # build php installation directory. /configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- with-mysql =/usr/local /Mysql -- with-mysqli =/usr/local/mysql/bin/mysql_config -- with-mysql-sock =/tmp/mysql. sock -- with-gd -- with-iconv -- with-freetype -- with-jpeg -- with-png -- with-zlib -- with-libxml -- enable-xml -- enable-discard-path -- enable-magic-quotes -- enable-safe-mode -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curlwrappers -- enable-mbregex -- enable- fastcgi -- enable-fpm -- e Nable-force-cgi-redirect -- enable-mbstring -- enable-ftp -- enable-gd-native-ttf -- with-openssl -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-gettext -- with-mime-magic -- enable-suhosin -- enable-session -- with-mcrypt -- with-curlmake & make install cp php. ini-production/usr/local/php5/etc/php. ini # Copy the php configuration file to the installation directory rm-rf/etc/php. ini # Delete the built-in configuration file ln-s/us R/local/php5/etc/php. ini/etc/php. ini # add soft link ln-s/usr/local/php5/bin/php/usr/bin/phpcp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5 /etc/php-fpm.conf # copy the template file for php-fpm configuration file vim/usr/local/php5/etc/php-fpm.conf # Edit user = www # set php-fpm run account to wwwgroup = www # set php-fpm runtime group to www pid = run/php-fpm.pid # uncomment setting php-fpm boot start cp/usr/local/src/php-5.3.10/sapi/fpm/init. d. php-fpm/etc/rc. d/init. d/php-fp M # Copy php-fpm to the Startup directory chmod + x/etc/rc. d/init. d/php-fpm # Add permission chkconfig php-fpm on # set to start vim/usr/local/php5/etc/php at startup. ini # Edit the configuration file and find:; date. timezone = changed to: date. timezone = PRC # set the time zone to find: expose_php = On to: expose_php = OFF # Disable the display of php version information: display_errors = On: display_errors = OFF # Disable the error and prompt that phpvim/usr/local/nginx/conf/nginx is supported for nginx configuration. conf modify/usr/local/nginx/conf/nginx. in the conf configuration file, modify the user www; # first line of user Drop comments, modify Nginx run group to www; must be the same as the user, group configuration in/usr/local/php5/etc/php-fpm.conf, otherwise php run error index. php index.html index.htm; # Add index. php # pass the PHP scripts to FastCGI server listening on 127.0.0.1: 9000 # location ~ \. Php $ {root html; fastcgi_pass 127.0.0.1: 9000; fastcgi_index index. php; fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; include fastcgi_params;}/etc/init. d/nginx restart # restart nginx cd/usr/local/nginx/html/# enter the default nginx website root directory rm-rf/usr/local/nginx/html/* # Delete the default test page chown www. www/usr/local/nginx/html/-R # set the directory owner chmod 755/usr/local/nginx/html/-R # set the directory permission to restart nginx, mysqld, php- install and configure the Cacti Web service for the fpm service (1) install rrdtool, net-snmp, and related dependent packages for I in 'rpm-q rrdtool net-snmp rrdtool-devel net-snmp-utils net-snmp-python net -snmp-perl lm_sensors-devel file-devel rpm-devel file intltool libart_lgpl libart_lgpl-devel elfutils pango-devel * cairo-devel * mysql-devel Mod_auth_mysql php-mysql cairo dejavu-fonts-common.noarch dejavu-lgc-sans-mono-fonts.noarch dejavu-sans-mono-fonts.noarch fontpackages-filesystem.noarch libxlibxrender libthango pango pixman perl-rrdtool net-snmp-utils tcp_wrappers-devel | grep 'not installed' | awk '{print $2 }''; do yum-y install $ I; done modifies the snmpd configuration file, vim/etc/snmp/snmpd. conf find the corresponding row and modify it to com2sec notConfigUser 127.0.0.1 public #127.0.0.1 as cacti monitoring server # view systemview embedded ded. 1.3.6.1.2.1.25.1.1 access notConfigGroup "" any noauth exact all none view all included. 1 80 start snmpd service snmpd start chkconfig snmpd on install Cacti cd/usr/local/srctar zxvf cacti-0.8.7i.tar.gzcd cacti-0.8.7icp-r */usr/local/nginx/htmlchown www. www/usr/local/nginx/html/-R # set the directory owner chmod 755/usr/local/nginx/html/-R # set the directory permission to configure the Cacti database mysql-u root -p # enter the password to enter the MySQL console create database cactidb; # create a database cactidbinsert into mysql. user (Host, User, Password) values ('localhost', 'cactiuser', password ('000000'); # create a database user cactiuser Password 123456 grant all on cactidb. * to 'cactiuser' @ '%' identified by '000000' with grant option; # authorize the user cactiuser to fully access the database cactidb flush privileges; # refresh the system authorization table, use cactidbsource/usr/local/nginx/html/cacti. SQL # import the cacti database file vim/usr/local/nginx/html/include/config. php # configure database connection $ database_type = "mysql"; $ database_default = "cactidb"; # Database name $ database_hostname = "localhost"; # host name, $ database_username = "cactiuser" by default; # Database username $ database_password = "123456"; # database password $ database_port = "3306"; # default MySQL database connection port $ database_ssl = false; open http://Cacti-IP/ On the installation page, click [OK: FILE FOUND] under each option, indicating that all the configuration FILE paths are correct. then, the default username and password of the logon interface are admin. the password needs to be changed for the first time, after modification, click save because cacti mainly uses poller. php is used to trigger data collection. in crontab, set cacti to collect data once every 5 minutes. crontab-e */5 ***** php/usr/local/nginx/html/poller. php &>/dev/null restart crond/usr/bin/php/usr/local/nginx/html/poller. php # manual data refresh
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.