环境是cenos5.1+最小化安装+development tools
开始配置。。
vi /etc/yum.repos.d/Dag.repo###定义第三方源
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
http://rh
http://wftp.tu
http://archive.cs.uu.nl/mirror/dag.wieers/redhat/el$releasever/en/$basearch/dag
http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el$releasever/en/$basearch/dag
http://rpmfind.net/linux/dag/redhat/el$releasever/en/$basearch/dag
http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag
http://mirrors.ircam.fr/pub/dag/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1
protect=0
gpgcheck=1
gpgkey=http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
##################################################
vi utterramblings.repo ###定义php独立源
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
#########################################################################
一次性安装所需软件
yum -y install httpd mysql-server rrdtool mysql-devel php-devel net-snmp php php-mysql php-gd php-pdo
或者也可以直接安装centos官方推荐软件库:
下载rpm包
wget
安装DAG的PGP Key
rpm --import
验证下载包的完整性
rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm
安装包
rpm -ivh rpmforge-release-0.3.6-1.el5.rf.*.rpm
参考网址:
http://doc.linuxpk.com/58083.html
安装php-json
wget
tar xvjf php-json-ext-1.2.0.tar.bz2
cd php-json-ext-1.2.0
###初始化PHP环境
phpize
./configure
make&&make install#####
(如果提示没有这个命令则首先要
yum -y install php-devel
如果还不行,说明你的编译工具有问题,安装一下就可以了
yum -y install autoconf
yum -y install automake
yum -y install libtool
)
查看有没有安装成功
find / -name '*json.so'
./usr/lib/php/modules/json.so
说明已经有了
vi /etc/php.ini
添加 include ('/etc/php.d/json.ini')
vi /etc/php.d/json.ini
内容如下:
extension=json.so
apachectl graceful
到此所需要的软件都安装完毕
开始配置cacti
修改cacti访问权限
vi /etc/httpd/conf.d/cacti.conf
如下:
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
order deny,allow
#deny from all
#allow from 127.0.0.1
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
建立cacti数据库和授权
mysqladmin create cacti
mysql>grant all privileges on cacti.* to
mysql>flush privileges;
mysql>exit;
导入数据:
cd /var/www/cacti
mysql -ucacti -p cacti<cacti.sql
更改配置:
vi /var/www/cacti/include/config.php
$database_username = "cacti";
$database_password = "cacti";
vi /var/www/cacti/include/globle.php
$database_username = "cacti";
$database_password = "cacti";
制定任务计划:
crontab -e -u cacti
*/5 * * * * php -f /var/www/cacti/poller.php >/dev/null 2>&1
重新启动apache
service httpd restart
访问
下载cacti插件管理器
wget
unzip cacti-plugin-0.8.7d-PA-v2.4.zip
cd files-0.8.7d
cp -rf * /var/www/cacti/
导入数据:
cd ..
mysql -ucacti -pcacti cacti<pa.sql####也可以使用root
更改访问路径:
vi /var/www/cacti/include/globle.php
$config['url_path'] = '/cacti/';
配置nagios
我这里面没有更进一步配置nagios,npc安装完后nagios会自动启动本机的一些监控项目,如果想要监控其他的主机,则需要单独配置nagios,npc会予以展示
更改apache访问权限使nagios可以正常使用
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
安装ndoutils
wget
tar zxvf ndoutils-1.4b7.tar.gz
cd ndoutils-1.4b7
./configure --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
make clean
make
复制文件
cd src
cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/bin/
cd ../config
cp ndo2db.cfg ndomod.cfg /etc/nagios/
配置文件
vi /etc/nagios/ndo2db.cfg
socket_name=/var/nagios/ndo.sock
db_name=cacti
db_prefix=npc_
db_user=cacti
db_pass=cacti
debug_level=1
debug_file=/var/nagios/ndo2db.debug
vi /etc/nagios/ndomod.cfg
output=/var/nagios/ndo.sock
buffer_file=/var/nagios/ndomod.tmp
vi /etc/nagios/nagios.cfg ##确认以下五项的值正确
check_external_commands=1
command_check_interval = -1
event_broker_options = -1
broker_module = /usr/bin/ndomod-3x.o config_file=/etc/nagios/ndomod.cfg
process_performance_data=1
安装npc
wget
tar zxvf npc-2.0.0b.166.tar.gz
cd npc
拷贝内容到cacti plugins文件夹
cp npc /var/www/cacti/plugins/
添加插件识别
vi /var/www/cacti/include/globle.php
$plugins[] = 'npc';
到此 所有需要安装的东西完毕
使用npc
进入你的cacti主页面
在'User Management'中选择'admin',在下边'Realm Permissions'中钩选'Plugin Management'。这时右侧会出现'Plugin Management'连接,进去后在'uninstalled'中安装npc,然后在'intalled'中enable npc,然后在回去admin的'Realm Permissions'中会出现'use npc',把它选中。
接着在右侧栏目中选择settings,点选npc的标签
钩选Remote Commands
Nagios Command File Path: /var/nagios/rw/nagios.cmd
Nagios URL:
save一下
1.npc页面空白或者提示无法访问npc.php
确认安装并配置php-jsion正确
2.cacti无图或者没有数据
这个问题很多
参考
mysql -uroot mysql
| user() |
+--------+
| root@ |
+--------+
则需更改root登陆主机,参考如下命令:
mysql>GRANT ALL PRIVILEGES ON *.* TO root@"%";
mysql> FLUSH PRIVILEGES ;