为cacti用户写一个crontab,使他没五分钟收集一次主机信息
- # su - cacti
- $ crontab -e
- */5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1
安装cacti加速器:cacti-spine:
- # yum install automake libtool
- # tar zxf cacti-spine-0.8.7h.tar.gz
- # cd cacti-spine-0.8.7h
- # aclocal
- # libtoolize --force
- # autoheader
- # autoconf
- # automake
- # ./configure
- # make
- # make install
- # cd /usr/local/spine/etc/
- # mv spine.conf.dist spine.conf
- # vim spine.conf
- DB_Host localhost
- DB_Database cacti
- DB_User cacti
- DB_Pass cacti
- DB_Port 3306
- DB_PreG 0
打开http://192.168.0.100/cacti
在console-settings-paths-alternate poller path 写上 /usr/local/spine/bin/spine
再将console-settings-poller-poller type改为spine
注意如果文字是乱码的话需要安装中文支持
安装cacti插件管理器:
cacti可以通过安装插件大大丰富它的功能,插件安装叶非常简便,只要安装好插件管理器以后将要安装的插件文件夹放在/var/www/html/cacti/plugins中就可以在网页里进行安装。下面时安装插件管理器的方法:
- # tar zxf cacti-plugin-0.8.7h-PA-v3.0.tar.gz
- # cd cacti-plugin-arch/
- # mysql -ucacti -pcacti cacti < pa.sql
- # cp cacti-plugin-0.8.7h-PA-v3.0.diff /var/www/html/cacti/
- # cd /var/www/html/cacti/
- # patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff
打开http://192.168.0.100/cacti
在console-utilities-user management-admin-realm permissions勾选plugin management
安装三款插件:
- tar zxf settings-0.5.tar.gz -C /usr/local/apache/htdocs/cacti/plugins
- tar zxf monitor-0.8.2.tar.gz -C /usr/local/apache/htdocs/cacti/plugins
- tar zxf thold-0.4.2.tar.gz -C /usr/local/apache/htdocs/cacti/plugins
打开http://192.168.0.100/cacti,进入插件管理器可直接进行安装,并可在settings中进行设置。
一些cacti简单的介绍:
Cacti 其实是一套 php 程序,一个 rrdtool 工具。它运用 snmpget 采集数据,使用 rrdtool 绘图。界面非常漂亮,它提供了强大的数据管理和用户管理功能,一张图是属于一个 host 的,每一个 host 又可以挂载到一个树状的结构上。用户的管理上,作为一个开源软件,它做到为指定一个用户能查看的“树”、host、甚至每一张图,还可以与 LDAP 结合进行用户的验证。 Cacti 还提供自己增加模板的功能,让你添加自己的 snmp_query和 script 。功能相当强大!
cacti 是用 php 语言实现的一个软件,它的主要功能是用 snmp 服务获取数据, snmp 需要的变量数据是通过读取 mysql 数据库得到,然后用 rrdtool 储存和更新数据,当用户需要查看数据的时候用 rrdtool 生成图表呈现给用户。rrdtool 对数据的更新和存储就是对 rrd 文件的处理,rrd 文件是大小固定的档案文件,它能够存储的数据笔数在创建时就已经定义。1. Snmp 用来收集数据;2. Rrdtool 用来存储数据和生成图表;3. Mysql 用来配合 PHP 程序存储一些变量数据并对变量数据进行调用。
- # yum install httpd gcc make gd-devel perl-ExtUtils-Embed #安装编译所需要的软件包
- # useradd nagios #运行nagios服务的用户
- # usermod -G nagios apache #将apache用户加入到nagios组中,因为nagios程序通过apache发布与修改,而httpd程序的执行用户是apache,所以需要让apache有权限修改查看nagios文件
- # tar jxf nagios-cn-3.2.3.tar.bz2
- # cd nagios-cn-3.2.3
- # ./configure --enable-embedded-perl
- # make
- # make all
- # make install
- # make install-init
- # make install-commandmode
- # make install-config
- # make install-webconf
安装nagios插件:
- # yum install mysql-devel openssl-devel -y #安装编译所需的安装包
- # tar zxf nagios-plugins-1.4.15.tar.gz
- # cd nagios-plugins-1.4.15
- # ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-libtap --enable-perl-modules
- # make
- # make install
#nagios 配置
- # vi /usr/local/nagios/etc/nagios.cfg #nagios 配置
- cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
- #新建 hosts.cfg 文件,存放主机与主机组定义
- cfg_file=/usr/local/nagios/etc/objects/services.cfg #新建 services.cfg 文件,存放服务与服务组定义
- #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg #注释 localhost.cfg 文件
