sdfouhdso888 发表于 2019-1-10 11:54:17

cacti + nagios + pnp +npc

  Centos6.2
  
一、安装环境LAMP
  #yum -y install gcc* glibc* gd* php* mysql* http*
  #yum -y install httpdmysql-server mysql-devel perl-DBI perl-DBD-MySQL php php-devel php-mysql php-snmp php-pdophp-gd lm_sensors net-snmp net-snmp-libs net-snmp-utils net-snmp-devel
  

  # chkconfig mysqld on
  # chkconfig httpd on
  # chkconfig snmpd on
  # service mysqld start
  # service httpd start
  # service snmpd start
  

  #vim /var/www/html/index.php
  
  访问http://localhost/index.php
http://blog.运维网.com/attachment/201311/175746459.png
  

  # mysqladmin -u root password '123'
  报错处理: # exportPATH=$PATH:/usr/local/mysql/bin
  

  # mysql -u root -p
  输入密码
  mysql>create database cacti default character set utf8;
  Query OK, 1 row affected (0.00 sec)
  

  mysql>grant all on cacti.* to cacti@localhost identified by '123';
  Query OK, 0 rows affected (0.01 sec)
  

  mysql>flush privileges;
  Query OK, 0 rows affected (0.00 sec)
  

  mysql> \q
  

  二、安装cacti


  安装rrdtool需要的软件包

  # yum -y install cairo-devel libxml2-devel pango pango-devel
  

  安装rrdtool
  # tar zxvf rrdtool-1.4.4.tar.gz
  # cd rrdtool-1.4.4
  # ./configure --prefix=/usr/local/rrdtool && make && make install
  # ln -s /usr/local/rrdtool/bin/* /usr/local/bin/    #此步非常重要
  

  安装cacti-0.8.7.e中文版
  #wget http://blogimg.chinaunix.net/blog/upfile2/090815172648.gz
  # tar zxvf 090815172648.gz -C /var/www/html
  # cd /var/www/html
  # mv cacti-0.8.7e-cn-utf8/ cacti
  # mysql -ucacti -p cacti < cacti/cacti.sql/导入数据库
  Enter password:
  

  创建cacti用户
  # useradd -s /sbin/nologin cacti
  # chown -R cacti:cacti /var/www/html/cacti/
  # chmod -R 777 /var/www/html/cacti/
  

  修改cacti配置文件,连接数据库
  # vim /var/www/html/cacti/include/config.php
  $database_username = "cacti";
  $database_password = "123";
  

  添加计划任务
  # crontab -e
  */5 * * * * /usr/bin/php/var/www/html/cacti/poller.php >/dev/null 2>&1
  # service crond restart
  

  三、被监控端配置


  安装snmp服务
#yum -y install lm_sensors net-snmp


  修改配置文件如下:(这里我省略掉了#行和空行)
  只改了下面三行,(下面的地址是cacti服务器地址,由于是本机测试,所以是127.0.0.1)
  #vim /etc/snmp/snmpd.conf
  41 com2sec notConfigUser 127.0.0.1 public
  62 access notConfigGroup "" any noauth exact all none none
  85 view all included .1 80    将前面#号去掉
  

  重启服务
  # service httpd restart
  # service mysqld restart
  # service snmpd restart
  
检测在服务器上,有信息返回说名正常:
  #snmpwalk -c public -v 2c localhost
  # snmpwalk -v 1 -c public localhostIP-MIB::ipAdEntIfIndex
  

  浏览器输入http://192.168.163.143/cacti/install初始化cacti,最后如下:
  如果打开网页,页面出现空白,那么说明数据库没有导入进去,重新导入数据库后重启httpd服务即可
  RRDTOOLS版本,默认为1.0.x,改为1.3.x就行了
http://blog.运维网.com/attachment/201311/175805565.png
  如果打开未看到生成图像,请手动执行下面命令
  #/usr/bin/php/var/www/cacti/poller.php &>/dev/null手动生成图像
http://blog.运维网.com/attachment/201311/175817302.png
  

  字体在图形中显示不正常的解决方法
  下载并安装中文字体,我用的是微米黑字体
  wget http://sourceforge.net/projects/wqy/files/wqy-microhei/0.2.0-beta/wqy-microhei-0.2.0-beta.tar.gz
  #tar zxvf wqy-microhei-0.2.0-beta.tar.gz
# cd wqy-microhei
# cp wqy-microhei.ttc /usr/share/fonts/wqy-microhei.ttc
  
安装完成后注意在"设置"中更改下面两个必改项.
常规->RRDTool应用程序版本改为1.3.x,默认为1.0.x.不改可能图像不能正常显示出来.
路径->RRDTool默认字体路径改为上面安装的文件路径,如/usr/share/fonts/wqy-microhei.ttc
  

  安装插件cacti-plugin
  #wget http://blogimg.chinaunix.net/blog/upfile2/090818213852.gz
  # mv 090818213852.gz cacti-plugin-0.8.7d-PA-v2.4-cn-utf8.diff.gz
  # gunzip cacti-plugin-0.8.7d-PA-v2.4-cn-utf8.diff.gz
  # mv cacti-plugin-0.8.7d-PA-v2.4-cn-utf8.diff /var/www/html/cacti/
  # cd /var/www/html/cacti/
  # patch -p1 -N
页: [1]
查看完整版本: cacti + nagios + pnp +npc