Cacti 监控服务

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cacti 监控服务相关的知识,希望对你有一定的参考价值。

一搭建Cacti监控服务器(105)
1.1  部署服务运行环境(LAMP)
yum   -y   install    httpd    php   php-mysql  mysql-server

  mysql

/etc/init.d/httpd   start  ;chkconfig  httpd  on
/etc/init.d/mysqld   start  ;chkconfig  mysqld  on


[[email protected] ~]# mysqladmin  -hlocalhost -uroot  

password "123"

[[email protected] ~]# mysql -hlocalhost -uroot -p123
mysql>

yum  -y   install elinks

[[email protected] ~]# cat  /var/www/html/test.php
<?php
  echo  "hello  a";
?>
[[email protected] ~]# elinks  --dump  http://localhost/test.php
   hello a
[[email protected] ~]#

[[email protected] ~]# cat /var/www/html/linkdb.php
<?php
$linkdb=mysql_connect("localhost","root","123");
if($linkdb){
    echo "link ok";
}else{
    echo "link no";
}
?>
[[email protected] ~]#

[[email protected] ~]# elinks  --dump  

http://localhost/linkdb.php
   link  ok

1.2  安装cacti软件
181  tar  -zxvf   cacti-0.8.7g.tar.gz
184  mv  cacti-0.8.7g /var/www/html/cacti
185  chown -R  apache:apache /var/www/html/cacti

修改cacti服务的主文件文件,指定存放配置信息的数据库
vim  /var/www/html/cacti/include/config.php
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "jim";
$database_password = "123";
$database_port = "3306";
:wq

mysql  -uroot  -p123
mysql> create  database  cactidb;
mysql>  grant  all  on  cactidb.*  to  [email protected]"localhost"  

identified   by   "123";
mysql>quit

mysql   -hlocalhost   -ujim  -p123
mysql>quit;

创建存储配置信息的表
[[email protected] cacti]# ls /var/www/html/cacti/*.sql
/var/www/html/cacti/cacti.sql
[[email protected] cacti]#

mysql   -hlocalhost   -ujim  -p123  cactidb  <   

/var/www/html/cacti/cacti.sql


访问web页面安装cacti
ping   172.40.50.105
http://172.40.50.105/cacti

+++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++
1.2 监控远端服务器( 103)  
1.2.1 在服务器103上运行snmpd服务
yum  -y  install net-snmp

[[email protected] ~]# sed -n  ‘41p;62p;85p‘

/etc/snmp/snmpd.conf
com2sec notConfigUser  172.40.50.105       public
access  notConfigGroup ""      any       noauth    exact  all

none none
view all    included  .1                               80
[[email protected] ~]#

[[email protected] ~]# /etc/init.d/snmpd status
snmpd 已停
[[email protected] ~]# /etc/init.d/snmpd start
正在启动 snmpd:                                           [确定]
[[email protected] ~]# netstat -untlap  | grep snmpd
tcp        0      0 127.0.0.1:199               0.0.0.0:*                   

LISTEN      12339/snmpd         
udp        0      0 0.0.0.0:161                 0.0.0.0:*                      

         12339/snmpd         
[[email protected] ~]#

1.2.2 在监控服务器上监控103
http://172.40.50.105/cacti   (使用管理登录管理页面)
1 添加要监控的主机
2 选择监控模板
3 选择监控资源
4 给监控的资源创建图片
5 给监控的主机创建图像树
6 把创建的图片添加的图像树里
7 收集监控数据
8 查看监控信息
++++++++++++++++++++++++++++
1.3 监控本机
1.3.1  运行snmpd 服务
rpm  -q    net-snmp

vim /etc/snmp/snmpd.conf
[[email protected] ~]# sed -n  ‘41p;62p;85p‘

/etc/snmp/snmpd.conf
com2sec notConfigUser  localhost    public
access  notConfigGroup ""      any       noauth    exact  all

none none
view all    included  .1                               80
[[email protected] ~]#

[[email protected] ~]# /etc/init.d/snmpd start
正在启动 snmpd:                                           [确定]
[[email protected] ~]# netstat -untlap  | grep snmpd
tcp        0      0 127.0.0.1:199               0.0.0.0:*                   

LISTEN      12339/snmpd         
udp        0      0 0.0.0.0:161                 0.0.0.0:*                      

         12339/snmpd         
[[email protected] ~]#

1.3.2 在监控服务器上监控自己
http://172.40.50.105/cacti   (使用管理登录管理页面)
1 添加要监控的主机
2 选择监控模板
3 选择监控资源
4 给监控的资源创建图片
5 给监控的主机创建图像树
6 把创建的图片添加的图像树里
7 收集监控数据
vim /etc/php.ini
946  date.timezone = Asia/Chongqing
:wq
php  /var/www/html/cacti/poller.php

ls   /var/www/html/cacti/rra/*.rra

[[email protected] ~]# crontab  -l
*/3  * * *  *   php  /var/www/html/cacti/poller.php
[[email protected] ~]# /etc/init.d/crond status
crond (pid  1803) 正在运行...
[[email protected] ~]#

8 查看监控信息
http://172.40.50.105/cacti   (使用管理登录管理页面)

+++++++++++++++++++++++++++++++++++
三、配置Cacti监控报警(通过插件实现的)
3.1  让cacti支持插件功能
    2  tar -zxvf cacti-plugin-0.8.7g-PA-v2.9.tar.gz
    6  mv cacti-plugin-arch/   /var/www/html/cacti/
    7  cd /var/www/html/cacti/
 
    9  which patch
   10  yum -y  install patch
   11  which patch
 
   14  patch  -N -p1 < cacti-plugin-arch/cacti-plugin-

0.8.7g-PA-v2.9.diff

   16  ls  plugins
          index.php

   17  vim /var/www/html/cacti/include/config.php
          $url_path = "/cacti/";
          :wq

   18  cd /var/www/html/cacti/cacti-plugin-arch/
 
   21  mysql -uroot -p123 cactidb < pa.sql
 
   登录管理页面启用插件功能


3.2  安装插件并激活插件
 tar -zxvf monitor-v1.3-1.tgz
  tar  -zxvf settings-v0.71-1.tgz
 tar  -zxvf thold-v0.4.9-3.tgz
 
  mv settings  /var/www/html/cacti/plugins/
  mv thold  /var/www/html/cacti/plugins/
   mv monitor  /var/www/html/cacti/plugins/

[[email protected] ~]# ls  /var/www/html/cacti/plugins/
index.php  monitor  settings  thold
[[email protected] ~]#

3.3  配置插件实现监控报警功能(发邮件)
对登录的用户数做监控报警  

邮件用户列表   sendmail
设置对监控的资源做监控报警
指定邮件服务器


发邮件 :
发件人    [email protected]  
收件人    [email protected]
邮件服务器   localhost
++++++++++++++++++++++++++++++++





++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error

You have created a new database, but have not yet imported the ‘cacti.sql‘ file. At the command line, execute the following to continue:


mysql -u jim -p cactidb < cacti.sql

This error may also be generated if the cacti database user does not have correct permissions on the cacti database. Please ensure that the cacti database user has the ability to SELECT, INSERT, DELETE, UPDATE, CREATE, ALTER, DROP, INDEX on the cacti database.
+++++++++++++++++++++++++++++++++++++++++++
FATAL: Cannot connect to MySQL server on ‘localhost‘.
Please make sure you have specified a valid MySQL
database name in ‘include/config.php‘

本文出自 “12336621” 博客,请务必保留此出处http://12346621.blog.51cto.com/12336621/1906061

以上是关于Cacti 监控服务的主要内容,如果未能解决你的问题,请参考以下文章

监控三剑客之Cacti监控服务器

服务器监控cacti

部署监控三剑客 Cacti 服务器监控

服务器监控系统cacti

Linux 搭建Cacti 监控服务器

服务器监控cacti