1、构建Cacti服务器管理监测系统Cacti(愿意仙人掌,也是次软件的名称)实在大型网络常见的性能监测软件,可提供对CPU负载、内存占用、运行进程数、磁盘空间、网卡流量等各种数据进行监测。Cacti本身只是基于PHP语言编写的一套管理套件,需要使用NetSNMP工具采集监测数据,并结合RRDtool(轮询数据库工具)记录数据及绘制图片,并通过web页面的形式展现给管理员用户。原理图;软件获取: Cacti下载 官方站点: RRDTool Round Robin Database Tool,轮询数据库工具 官方站点:http:/oss.oetiker.ch/rrdtool需求:Redhat 5.4
2、或者CentOS5.5系统,采用文本安装模式最小化安装,构建YUM。实现步骤: 一配置被监测端(snmpd) 在被检测的linux主机中,安装好netsnmp软件包,并配置启动snmpd服务,以便允许Cacti系统采集数据。1 安装netsnmp软件包netsnmp软件需要用到lm_sensors提供的硬件监测模块,安装时直接使用系统光盘中的rpm包文件,依次安装lm_sensors、netsnmp。(被监测的服务器需要安装snmpd服务,在监测服务器上还需要安装net-snmp-utils-5.3.2.2-7.el5.i386.rpm)rootwww # mount /dev/cdrom /
3、media/mnt/rootwww # cd /media/mnt/Server/rootwww Server# rpm -ivh lm_sensors-2.10.7-4.el5.i386.rpmrootwww Server# rpm -ivh net-snmp-5.3.2.2-7.el5.i386.rpmrootwww Server# rpm -ivh net-snmp-utils-5.3.2.2-7.el5.i386.rpm2 配置及启动snmpd服务修改/etc/snmp/snmpd.conf文件修改内容:把com2sec notConfigUser default publicacce
4、ss notConfigGroup any noauth exact systemview none none#view all included .1 80修改为com2sec notConfigUser 192.168.1.111 publicaccess notConfigGroup any noauth exact all none noneview all included .1 803 启动snmpd服务并设置开机启动rootwww # service snmpd startrootwww # chkconfig -level 35 snmpd on二配置监测服务端(Cacti)C
5、acti监测服务端需要有Apache、Mysql、PHP网站平台的支持,且需要预先安装有gd、zlib等软件包。1 安装LAMP平台、启动服务并设置开机启动rootwww # yum install httpd* -yrootwww # yum install mysql* -yrootwww # yum install php* -yrootwww # service httpd startrootwww # service mysqld startrootwww # chkconfig -level 35 httpd onrootwww # chkconfig -level 35 mysq
6、ld on2 安装rrdtool软件包rrdtool需要的软件包libart_lgpl-2.3.17-4.i386libpng-1.2.10-7.1.el5_3.2.i386 freetype-2.2.1-21.el5_3.i386 需预先安装rootwww # tar zxf rrdtool-1.2.27.tar.gzrootwww # cd rrdtool-1.2.27rootwww rrdtool-1.2.27# ./configure -prefix=/usr/localrootwww rrdtool-1.2.27# makerootwww rrdtool-1.2.27# make i
7、nstall3 安装配置Cacti服务器套件安装Cacti文件包,解压至WEB服务器的网页目录,并添加用于读写监测数据的用户rootwww # cd /var/www/html/rootwww html# tar zxf cacti-0.8.7b-cn-utf8.tar.gzrootwww html# mv cacti-0.8.7b-cn-utf8 cactirootwww html# useradd cactiuserrootwww html# chown -R cactiuser:cactiuser cacti/rra/ cacti/log/设置监测数据库。建立保存监测数据的数据库、表,设
8、置好授权访问数据库的用户和密码rootwww html# service mysqld startrootwww html# mysql -u root -pmysql create database cactidb default character set utf8;mysql grant all on cactidb.* to cactiuserlocalhost identified by 123;mysql exitrootwww html# mysql -u cactiuser -p cactidb cacti/cacti.sql /导入数据表4 安装PA、Thold、Monito
9、r插件扩展rootwww # cd /var/www/html/cactirootwww cacti# tar zxf cacti-plugin-arch.tar.gzrootwww cacti# mysql -u cactiuser -p cactidb PA-utf.diffrootwww cacti# patch -p1 -N PA-utf.diffrootwww cacti# cd pluginsrootwww plugins# tar zxf settings-0.5.tar.gzrootwww plugins# tar zxf monitor-0.8.2.tar.gzrootwww
10、 plugins# tar zxf thold-0.3.9.tar.gzrootwww plugins# mysql -u cactiuser -p cactidb thold/thold.sqlrootwww plugins# mysql -u cactiuser -p cactidb monitor/monitor.sql5调整Cacti配置文件rootwww cacti# vi include/config.php6 调整httpd设置rootwww # vi /etc/httpd/conf/httpd.conf修改http.conf文件,以便支持自动查找索引页index.php,并将u
11、tf8作为默认的中文页面字符集。Listen 192.168.1.111:80DocumentRoot /var/www/html/cacti Options NoneAllowOverride None Order allow,deny Allow from allDirectoryIndex index.phpAddDefaultCharset UTF-87 重启httpd服务,并查看其端口rootwww # service httpd restartrootwww # service mysqld restartrootwww # netstat -anpt | grep :808 添加
12、任务计划cactiuserwww $ php /var/www/html/cacti/poller.phpcactiuserwww $ crontab e内容如下;*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php &/dev/nullcactiuserwww $ exitrootwww # service crond startrootwww # chkconfig -level 2345 crond on9 通过web页面初始化安装cacti使用web浏览器访问Cacti服务器,第一次访问Cacti界面时,会自动跳转到Cacti的初始化安装向导界面。如图,点击下一步即可为了在监测图像中正常现实中文,还需要设置RRDtool所使用的中文字体路径,此版本的路径应为“/usr/share/fonts/zh_TW/TrueType/bsmi00lp.ttf”,点击右下方的保存即可。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1