标签:
一、Cacti安装说明
一般性的安装说明,详细的操作系统具体的安装说明可用于Linux.
2.服务器安装要求
验证httpd和mysqld是在系统启动时启动,确保yum源是原始的源。
2.需要包基于yum的操作系统
3 。对于安装官方补丁,您将需要一些工具
#yum makecache
#yum install php-xml php-mysql php-snmp php-ldap php-pdo php-devel php
#yum install rrdtool
#yum install httpd httpd-tools
#yum install net-snmp net-snmp-libs net-snmp-utils
#yum install perl perl-libwww-perl
#yum install mysql mysql-server mysql-devel mysql-libs
#yum install python
#wget https://pypi.python.org/packages/source/s/setuptools/setuptools-12.0.5.tar.gz#md5=066e16290f8edcbc8b4b67808b2cbdb2
#tar –xvf setuptools-12.0.5.tar.gz
#cd setuptools-12.0.5
#python setup.py install
#easy_install python boto
#yum wget
#wget http://www.cacti.net/downloads/cacti-0.8.8c.tar.gz
#tar –xvf cacti-0.8.8c.tar.gz
#mv cacti-0.8.8c cacti
#mv cacti /var/www/html
#chmod –R 755 /var/www/html/cacti
#yum install -y net-snmp-devel openssl-devel
#wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8c.tar.gz
#tar -xvf cacti-spine-0.8.8c.tar.gz
#cd cacti-spine-0.8.8c
#mkdir /usr/local/spine
#chmod +x /usr/local/spine
#./configure --prefix=/usr/local/spine
#make && make install
#wget http://docs.cacti.net/_media/plugin:monitor-v1.3-1.tgz
#mv plugin\:monitor-v1.3-1.tgz monitor-v1.3-1.tgz
#tar -xvf monitor-v1.3-1.tgz
#cp -R monitor /var/www/html/cacti/plugins/
#wget http://docs.cacti.net/_media/plugin:settings-v0.71-1.tgz
#mv plugin:settings-v0.71-1.tgz settings-v0.71-1.tgz
#tar –xvf settings-v0.71-1.tgz
#cp –R settings /var/www/html/cacti/plugins/
#wget http://docs.cacti.net/_media/plugin:thold-v0.5.0.tgz
#mv plugin: thold-v0.5.0.tgz thold-v0.5.0.tgz
#tar –xvf thold-v0.5.0.tgz
#cp –R thold /var/www/html/cacti/plugins/
#wget http://www.percona.com/downloads/percona-monitoring-plugins/1.1.4/percona-monitoring-plugins-1.1.4.tar.gz
#tar –xvf percona-monitoring-plugins-1.1.4.tar.gz
#cd percona-monitoring-plugins-1.1.4\cacti\scripts\
#cp * /var/www/html/cacti/scripts/
#mkdir /var/www/html/cacti/resource/percona
#cd percona-monitoring-plugins-1.1.4\cacti\
#cp –R * /var/www/html/cacti/resource/percona
#chmod –Rf 755 /var/www/html/cacti/resource/percona
#yum install net-snmp net-snmp-libs net-snmp-utils
#wget http://nginx.org/download/nginx-1.6.2.tar.gz
#cp *.pl /var/www/html/cacti/scripts/
#mkdir /usr/local/nginx/
#chmod +x /usr/local/nginx/
#./configure --prefix=/usr/local/nginx --with-http_stub_status_module
#make && make install
1.PHP配置文件修改
#vi /etc/php.ini
safe_mode=Off
data.timezone=”Asia/manila”
file_uploads=On
extension_dir="/usr/lib64/php/modules/"或者extension_dir=/etc/php.d
注:如果是php是4.3.6以上版本。请注释掉seesion.save_path=/tmp
2.Apache配置文件修改
#vi /etc/httpd/conf/httpd.conf
incldue conf.d/*.conf
#cp /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/cacti.conf
#vi /etc/httpd/conf.d/cacti.conf
#more /etc/httpd/conf.d/php.conf
3.snmp配置文件修改
#vi /etc/snmp/snmpd.conf
原:
view systemview included .1.3.6.1.2.1.1
改:
view systemview included .1.3.6.1.2.1
原:
com2sec notConfigUser default public
改:
com2sec notConfigUser 监控端IP public
原:
access notConfigGroup "" any noauth exact systemview none none
改:
access notConfigGroup "" any noauth exact all none none
将 #view all included .1 80 前面的 # 注释去掉
添加监控服务器ip
rocommunity serverIP
#service snmpd restart
#chkconfig snmpd on
4.Cacti配置文件修改
#useradd cactiuser
#chown -R cactiuser rra/ log/
mysqladmin -user=root create cacti
cd /var/www/html/cacti
mysql cacti<cacti.sql
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘somepassword‘;
mysql> flush privileges;
#vi /etc/crontab
*/1 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1
#vi /var/www/html/cacti/include/global.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "127.0.0.1";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
#chkconfig snmpd on
#chkconfig httpd on
#chkconfig mysqld on
#chkconfig crond on
#iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
#vi /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 - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
改:
# 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 - No SELinux policy is loaded.
SELINUX= disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
#SELINUXTYPE=targeted
默认用户名:admin 密码:admin
5.Cacti基础插件Spine配置文件修改
#cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
# vi /usr/local/spine/etc/spine.conf
DB_Host localhost
DB_Database cacti
DB_User cactiuser
DB_Pass 123456
DB_Port 3306
DB_PreG 0
在”Poller Type”下拉框设置中,选择”spine”
输入Spine可执行程序的完整路径,我的是/usr/local/spine/bin/spine,保存设置。
6.Cacti基础插件monitor、settings、thold配置文件修改
#mysql -uroot -p cacti </home/www/cacti/plugins/monitor/monitor.sql
#vi /var/www/html/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "somepassword";
/* load up old style plugins here */
$plugins = array();
$plugins[] = ‘thold‘;
$plugins[] = ‘monitor‘;
$plugins[] = ‘settings‘;
$plugins[] = ‘discovery‘;
/*
Edit this to point to the default URL of your Cacti install
ex: if your cacti install as at http://serverip/cacti/ this
would be set to /cacti/
*/
$url_path = "/cacti/";
/* Default session name - Session name must contain alpha characters */
#$cacti_session_name = "Cacti";
配置如下图所示:
7.监控nginx配置文件修改
#vi /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /data/web_server/index;
index index.html index.htm;
}
location /nginx_status {
# Turn on nginx stats
stub_status on;
# I do not need logs for stats
access_log off;
# Security: Only allow access from 192.168.1.100 IP #
#allow 192.168.1.100;
# Send rest of the world to /dev/null #
#deny all;
}
}
返回结果类似于:
Active connections: 1
server accepts handled requests
655 655 1985
Reading: 0 Writing: 1 Waiting: 0
8.监控redis配置文件修改
注:此文件在检出监控插件中安装
#vim /var/www/html/cacti/scripts/
$ssh_user = ‘root‘; # SSH username
$ssh_port = 22; # SSH port
$ssh_iden = ‘-i/root/.ssh/id_rsa‘; # SSH identity
##修改根据你的配置,你的ssh连接用户,还有认证私钥的位置
$redis_port = 6379; # Which port redis listens on
注: 因为cacti监控redis是需要登录到redis的服务端运行redis的状态获取命令,所以需要ssh连接登录。需要配置非交互式帐号密码登录。这里采用公私钥模式。
ssh-keygen ##如果是root用户,生成的默认目录为/root/.ssh下2个文件id_rsa(公钥) id_rsa.pub(私钥)
cd /root/.ssh/ && chmod 600 id_rsa* ##把这2个文件修改权限,为600
ssh-copy-id -i /root/.ssh/id_rsa root@192.168.200.1 #加被监控节点公私钥认证
http://www.percona.com/downloads/percona-monitoring-plugins/1.1.4/percona-monitoring-plugins-1.1.4.tar.gz
cacti_host_template_percona_redis_server_ht_0.8.6i-sver1.1.4.xml
让cacti所在机器能够访问MySQL服务器的状态信息,必须拥有”process”权限。如果要监控InnoDB状态,还必须有”SUPER”权限。
mysql> grant process,super on *.* to ‘cacti‘@‘%‘ identified by ‘cacti‘;
mysql> grant all privileges on cacti.* to cacti@"%" identified by "cacti";
vim /var/www/html/cacti/scripts/scriptsss_get_mysql_stats.php
http://www.percona.com/downloads/percona-monitoring-plugins/1.1.4/percona-monitoring-plugins-1.1.4.tar.gz
cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.1.4.xml
vim /var/www/html/cacti/scripts/get_php_fpm_status.php
<?php
#!/usr/bin/php -q
/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER[‘REQUEST_METHOD‘]) || isset($_SERVER[‘REMOTE_ADDR‘])) {
die("<br><strong>This script is only meant to run at the command line.</strong>");
}
$default[‘host‘] = ‘‘; # server host
$default[‘script‘] = ‘/status‘; # test script (absolute path starting at / - root directory -)
$default[‘port‘] = 80; # tcp port
$default[‘timeout‘] = 3; # timeout in seconds
$args = array();
@list(, $args[‘host‘], $args[‘script‘], $args[‘port‘], $args[‘timeout‘]) = $_SERVER["argv"];
foreach($args as $key => $value)
$args[$key] = ($value)? $value : $default[$key];
if (($args[‘host‘] == ‘‘) || ($args[‘port‘] == ‘‘)) {
print "Usage: get_php_fpm_status.php <host> [<test script>] [<port>] [<timeout seconds>]\n";
exit(-1);
}
#get resouce
$con = curl_init();
curl_setopt($con, CURLOPT_URL, ‘http://‘ . $args[‘host‘] . ‘:‘ . $args[‘port‘] . $args[‘script‘] );
curl_setopt ($con, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($con, CURLOPT_CONNECTTIMEOUT,10);
$content = curl_exec($con);
curl_close($con);
$result = preg_match("/accepted conn:\s+(\d+)\s*\n/i", $content, $matches);
$conn[‘accepted‘] = ($result)? $matches[1] : ‘n/a‘;
$result = preg_match("/idle processes:\s+(\d+)\s*\n/i", $content, $matches);
$conn[‘idle‘] = ($result)? $matches[1] : ‘n/a‘;
$result = preg_match("/active processes:\s+(\d+)\s*\n/i", $content, $matches);
$conn[‘active‘] = ($result)? $matches[1] : ‘n/a‘;
$result = preg_match("/total processes:\s+(\d+)\s*\n/i", $content, $matches);
$conn[‘total‘] = ($result)? $matches[1] : ‘n/a‘;
echo ‘accepted:‘ . $conn[‘accepted‘] . ‘ idle:‘ . $conn[‘idle‘] . ‘ active:‘. $conn[‘active‘] . ‘ total:‘ . $conn[‘total‘];
chmod 755 /var/www/html/cacti/scripts/get_php_fpm_status.php
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.bak
vim /etc/php-fpm.d/www.conf
原:
allow_url_fopen = Off
改:
allow_url_fopen = On
原:
#user_agent="PHP"
改:
user_agent="PHP"
Custom_PHP-FPM.xml
标签:
原文地址:http://www.cnblogs.com/snifferhu/p/4600408.html