Cacti和Nagios整合

        Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。用来监控网络流量、cpu使用率、内存使用率、硬盘使用率等。可以直观的监控各种数据流量,可以安装扩展插件,同时支持短信邮件告警等功能。

        Nagios是一个监视系统运行状态和网络信息的监视系统。Nagios能监视所指定的本地或远程主机以及服务,提供异常通知功能,同时还可以安装各种模块插件,自定义监控脚本等。

        两者区别:Cacti偏重于网络流量,系统负载方面的监控。而 Nagios偏重于系统服务方面的监控,你可以在被监控的机器上写自己的程序(shell,c 或 perl都可以) 。Nagios则通过这些脚本来对服务进行监控。Nagios可以和短信发送机配合用来监控规模较大的网站。


  • 安装扩展yum源

1
2
3
4
5
6
7
[root@www ~] # rpm -ivh http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm
Retrieving http: //mirrors .yun-idc.com /epel/6/i386/epel-release-6-8 .noarch.rpm
warning:  /var/tmp/rpm-tmp .1jSHmn: Header V3 RSA /SHA256  Signature, key ID 0608b895: NOKEY
Preparing...                 ########################################### [100%]
    1:epel-release            ########################################### [100%]
[root@www ~] # ls /etc/yum.repos.d/epel*
/etc/yum .repos.d /epel .repo   /etc/yum .repos.d /epel-testing .repo

##########CACTI#########


一、安装LAMP环境

1
[root@www ~] # yum -y install httpd php php-mysql mysql mysql-server mysql-devel php-gd libjpeg libjpeg-devel libpng libpng-devel


二、安装net-snmp、php-snmp、net-snmp-utils

1
[root@www ~] # yum -y install net-snmp net-snmp-utils net-snmp-libs php-snmp


三、安装rrdtool图形整合工具

1
2
3
4
5
6
7
8
9
10
11
[root@www ~] # yum -y install rrdtool
[root@www ~] # rrdtool 
RRDtool 1.3.8  Copyright 1997-2009 by Tobias Oetiker <tobi@oetiker.ch>
                Compiled Apr  3 2014 13:07:03
Usage: rrdtool [options]  command  command_options
Valid commands: create, update, updatev, graph, graphv,  dump, restore,
last, lastupdate, first, info, fetch, tune,
resize, xport
RRDtool is distributed under the Terms of the GNU General
Public License Version 2. (www.gnu.org /copyleft/gpl .html)
For  more  information  read  the RRD manpages

四、安装cacti主程序

  • 下载cacti-0.8.8f.tar.gz

[root@www ~]# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz

  • 安装cacti,解压放到网站目录下

[root@www ~]# tar zxf cacti-0.8.8f.tar.gz 

[root@www ~]# mv cacti-0.8.8f /var/www/html/cacti/

[root@www ~]# chown -R root. /var/www/html/cacti/

  • 初始化数据库

[root@www ~]# /etc/init.d/mysqld start

1
2
3
4
5
6
7
[root@www ~] # mysql_secure_installation 
Enter current password  for  root (enter  for  none):
Set root password? [Y /n ] y
Remove anonymous  users ? [Y /n ] y
Disallow root login remotely? [Y /n ] y
Remove  test  database and access to it? [Y /n ] y
Reload privilege tables now? [Y /n ] y
  • 创建cacti数据库

1
[root@www ~] # mysql -uroot -p -e "create database cacti"
  • 授权cacti数据库用户

1
2
[root@www ~] # mysql -uroot -p -e "grant all on cacti.* to 'cacti'@'localhost' identified by 'cactipass';"
[root@www ~] # mysql -uroot -p -e "flush privileges;"
  • 导入数据库文件

1
[root@www ~] # mysql -uroot -p cacti < /var/www/html/cacti/cacti.sql
  • 修改cacti的配置文件config.php

1
2
3
4
5
6
7
8
[root@www ~] # vim /var/www/html/cacti/include/config.php
$database_type =  "mysql" ;
$database_default =  "cacti" ;
$database_hostname =  "localhost" ;
$database_username =  "cacti" ;
$database_password =  "cactipass" ;
$database_port =  "3306" ;
$database_ssl =  false ;
  • 调整系统时区及时间

1
2
3
[root@www ~] # yum -y install ntp
[root@www ~] # ntpdate ntpdate time.nist.gov  ##同步时间
[root@www ~] # cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  ##替换系统时区
  • 配置php.ini文件的时区为Asia/Shanghai

1
2
[root@www ~] # vim /etc/php.ini 
date .timezone =  'Asia/Shanghai'
  • 添加抓图计划任务

1
2
3
[root@www ~] # /usr/bin/php /var/www/html/cacti/poller.php
[root@www ~] # crontab -e
* /5  * * * *   /usr/bin/php  /var/www/html/cacti/poller .php


五、Web界面安装和配置cacti

  • http://192.168.1.21/cacti

wKiom1aUq0TRxWOkAAE56zohYII386.jpg

  • New install

wKiom1aUq36imdirAACUNWmLo9o225.jpg

  • Finish

wKioL1aUrCTjCkGrAAFZ3fjQkTk780.jpg

  • 转到登录页面,默认登录名和密码都是admin,输入会提示修改密码,Save后显示cacti主页面

wKioL1aUrS7xPPI9AAC6TvcNpsA864.jpg

  • 点击graphs查看生成的图形数据

wKioL1aUrx6BxJQYAAEpKw1V8uo713.jpg



本文转自 HMLinux 51CTO博客,原文链接:http://blog.51cto.com/7424593/1734183

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值