Linux 之cacti 监控介绍
cacti (rrdtool是画图工具,)监控网设备占优势。nagios 直观一目了然,可以自已写脚本,但是不支持历史数据的查看。
zabbix,功能丰富。
安装 cacti服务端#楼主的系统是centenOS 6
首先现在如下rpm包,然后安装对应的rpm包epel源
centos5 32位epel源下载地址: www.lishiming.net/data/attachment/forum/epel-release-5-4_32.noarch.rpm
64位下载地址:www.lishiming.net/data/attachment/forum/epel-release-5-4_64.noarch.rpm
centos6
32位epel yum源下载地址: www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm
64位下载地址: www.lishiming.net/data/attachment/forum/epel-release-6-8_64.noarch.rpm
2. (lamp)然后分别安装httpd、php、mysql#搭建LAMP 的环境 (LAMP 环境搭建参见前面)
yum install -yhttpd php php-mysql mysql mysql-server mysql-devel php-gdlibjpeg libjpeg-devel libpng libpng-devel
3. 安装cactinet-snmprrdtool
yum install -y cactinet-snmpnet-snmp-utilsrrdtool
# yum install -y cactinet-snmpnet-snmp-utilsrrdtool
4. 启动服务:
/etc/init.d/mysqld start
/etc/init.d/httpdstart
/etc/init.d/snmpd start
# vim /etc/httpd/conf.d/cacti.conf #编辑配置文件。使apache能访问cacti web页面
把"Deny from all" 改为"Allow from all"。如果不改会访问403
# /etc/init.d/httpd restart#重启apache 服务
Stopping httpd:
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 10.72.4.39 for ServerName
# mysql -uroot-pzaq12wsx #进入数据库,LAMP
mysql> create database cacti;#创建数据库 cacti ;
mysql> show databases;
mysql> grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';
#设置数据库权限,用户名&密码 .cacti.* 表示所有的示,用户名和密码一样
生产环境中不建议这样设置密码。
导入sql文件(注意文件路径不要错了)
# mysql -uroot -pzaq12wsx cacti </usr/share/doc/cacti-0.8.8h/cacti.sql
# vim /usr/share/cacti/include/config.php #编辑cacti的配置文伯
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "127.0.0.1"; #localhost更改为 127.0.0.1
$database_username = "cacti"; #更改为cacti,前面设置的
$database_password = "cacti"; #更改为cacti
$database_port = "3306";
$database_ssl = false;
楼主localhost没有改出了个小插曲:
更改后出现cacti 的安装界面:
使用IE访问:10.72.4.39/cacti
第一步 :点击“NEXT”
第二步:选择全新安装
第三步:路径保持黙认,点击finish 完成。
第四步进入黙认登录页面:
输入黙认的帐户密码,会提示更改。admin:zaq12wsx
点击: graphs
执行poller.php, 生成图形, 加入计划任务
# /usr/bin/php /usr/share/cacti/poller.php
#/usr/bin/php /usr/share/cacti/poller.php添加cron任务
#执行poller.php 会有报错,因为我们没有设置“timezone”
PHP Warning:strtotime(): It is not safe to rely on the system's timezone settings.
# vim /etc/php.ini#设置 timezome = Asia/Chongqing
# /usr/bin/php /usr/share/cacti/poller.php#再次执行,就不会有警告
# crontab -e#加入任务计划。每5分钟执行一次
*/5 * * * */usr/bin/php /usr/share/cacti/poller.php
5分钟这后可以看到各种数据
-----------------------------------分割线-----------------------------------
安装客户端(增加一个linux服务器)
# yum install -y net-snmp #安装 net-snmp
# vim /etc/snmp/snmpd.conf #编辑snmpd.conf 配置文件
#syslocation Unknown (edit /etc/snmp/snmpd.conf)
#syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
更改以上为以下
syslocation OBird.LNMP #此处自定义
syscontact Root 123321@.1212.com#管理员邮箱
# service snmpd start#启动snmpd 服务
Starting snmpd:
在网页端设置添加客户端 ,参照以下步骤设置,最后点击右下角 "Create "
创建监测的数据:
添加另一台linux _LNMP 到localhost
页:
[1]