码迷,mamicode.com
首页 > 其他好文 > 详细

Cacti 监控服务

时间:2017-03-13 22:18:31      阅读:521      评论:0      收藏:0      [点我收藏+]

标签:catic监控

一搭建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


[root@stu ~]# mysqladmin  -hlocalhost -uroot  

password "123"

[root@stu ~]# mysql -hlocalhost -uroot -p123
mysql>

yum  -y   install elinks

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

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

[root@stu ~]# 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  jim@"localhost"  

identified   by   "123";
mysql>quit

mysql   -hlocalhost   -ujim  -p123
mysql>quit;

创建存储配置信息的表
[root@stu cacti]# ls /var/www/html/cacti/*.sql
/var/www/html/cacti/cacti.sql
[root@stu 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

[root@stu ~]# 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
[root@stu ~]#

[root@stu ~]# /etc/init.d/snmpd status
snmpd 已停
[root@stu ~]# /etc/init.d/snmpd start
正在启动 snmpd:                                           [确定]
[root@stu ~]# 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         
[root@stu ~]#

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
[root@stu ~]# 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
[root@stu ~]#

[root@stu ~]# /etc/init.d/snmpd start
正在启动 snmpd:                                           [确定]
[root@stu ~]# 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         
[root@stu ~]#

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

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

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/

[root@13 ~]# ls  /var/www/html/cacti/plugins/
index.php  monitor  settings  thold
[root@13 ~]#

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

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


发邮件 :
发件人    root@localhost  
收件人    cactiuser@localhost
邮件服务器   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 监控服务

标签:catic监控

原文地址:http://12346621.blog.51cto.com/12336621/1906061

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!