现在开源界用得比较多的两款监控软件就是NAGIOS/CACTI,下面笔者全面讲解二者的安装与整合,其实网上这类文件也比较多,但是都比较零散,对于新手来说搭建起来很容易出问题,本人发一篇完全适合新手的教程!关于二者的差别,废话不多说!!
系统初使化软件库安装:
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
-----------------------------------------------第一部分:nagios------------------------------------------
所有软件包都放在:/usr/local/src 或其它位置! (养成好的习惯!!)
一、安装Nagios必须的基本组件的运行依赖于httpd、mysql、gd以及编译用到的gcc
yum -y install httpd gcc glibc glibc-common *gd* php php-mysql mysql mysql-server mysql-devel openssl-devel
二、创建运行nagios的用户和组
groupadd nagcmd
useradd -M nagios
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
usermod -G nagios apache
三、安装nagios
cd /usr/local/src
tar zxvf nagios-3.3.1.tar.gz
cd nagios
mkdir /usr/local/nagios
chown -R nagios:nagios /usr/local/nagios
./configure --prefix=/usr/local/nagios
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
创建认证用户:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
PS: 此处用户名尽量使用默认nagiosadmin,否则就需要修改cgi.cfg文件中所有关于认证选项的用户.
启动apache
service httpd restart
这里你可以修改下apache配置文件的ServerName ,不然每次启动都非常慢!!!这个可以改成你的IP!
四、安装nagios-pugins插件
安装nagios常规插件
cd ..
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/usr/local/nagios
make;make install
安装nagios-snmp-plugins插件
wget http://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz
安装这个插件要装几个perl模块:
Crypt::DES
Digest::MD5
Digest::SHA1
Digest::HMAC
Net::SNMP
到www.cpan.org上下载!!
下面安装这几个模块(最后安装Net::SNMP这个模块):
tar zxvf Crypt-DES-2.05.tar.gz
cd Crypt-DES-2.05
perl Makefile.PL
make;make install
cd ..
gunzip Digest-HMAC-1.03.tar.gz
tar xvf Digest-HMAC-1.03.tar
cd Digest-HMAC-1.03
perl Makefile.PL
make;make install
cd ..
tar zxvf Digest-MD5-2.51.tar.gz
cd Digest-MD5-2.51
perl Makefile.PL
make ;make install
cd ..
tar zxvf Digest-SHA1-2.13.tar.gz
cd Digest-SHA1-2.13
perl Makefile.PL
make;make install
cd ..
gunzip Net-SNMP-v6.0.1.tar.gz
tar xvf Net-SNMP-v6.0.1.tar
cd Net-SNMP-v6.0.1
perl Makefile.PL
make;make install
现在开始安装nagios-snmp-plugins插件:
tar zxvf nagios-snmp-plugins.1.1.1.tgz
cd nagios_plugins
./install.sh
运行后一路回车!!!!!!!!!!!!!!!
PS: 我们也不必去cpan.org下载包下来进行安装,这里最简单的方法就是在shell命令行输入:perl -MCPAN -e shell
进入如 cpan> install nagios-snmp-plugins 来进行安装!不过有时这样不一定能安装的上!最好两种方法结合起来用最好!
安装nagios中文插件(这个插件最好与nagios版本相同,我发现不同也没多大关系):
cd /usr/local/src
tar jxvf nagios-cn-3.2.3.tar.bz2
cd nagios-cn-3.2.2
./configure
make all;make install
把nagios加入到系统服务:
chkconfig --add nagios
chkconfig nagios on
指定nagios指令的path
vi /etc/profile
大文件最后加入:
export PATH=$PATH:/usr/local/nagios/bin
再用 source /etc/profile 直接生效!
检查配置文件:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
PS: 检查配置文件只要配置文件中没有error配置就正常,有警告没关系!
chkconfig httpd on
chkconfig mysqld on
启动apache: service httpd start
启动mysqld: service mysqld start
启动nagios: service nagios start
五、nagios性能分析图表_PNP插件
yum install perl-Time-HiRes
先安装rrdtool
32位系统
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.5.1-1.el5.rf.i386.rpm
yum -y install rrdtool
64位系统
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
yum -y install rrdtool
1.安装PNP
tar zxvf pnp4nagios-0.6.16.tar.gz
cd pnp4nagios-0.6.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/bin/rrdtool
make all
make install
make install-webconf
make install-config
make install-init
2.配置PNP
cd /usr/local/pnp4nagios/etc
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv rra.cfg-sample rra.cfg
cd pages
mv web_traffic.cfg-sample web_traffic.cfg
cd ../check_commands
mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
mv check_nrpe.cfg-sample check_nrpe.cfg
mv check_nwstat.cfg-sample check_nwstat.cfg
service npcd start
3.修改 nagios 的配置文件,打开performance_data
cd /usr/local/nagios/etc
vi nagios.cfg
process_performance_data=1 //把0变成1,启动nagios的数据输出功能,这样nagios将收集的数据写入到某个文件当中,以备提取!
host_perfdata_command=process-host-perfdata //启用主机的数据输出功能
service_perfdata_command=process-service-perfdata //启用服务的数据输出功能
4.修改 commands.cfg
cd /usr/local/nagios/etc/objects
vim commands.cfg
把默认的process-host-perfdata和process-service-perfdata 删除掉或注释掉,添加如下内容:
# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
5.添加模板
vim templates.cfg
在配置文件最后添加
define host {
name hosts-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&
register 0
}
define service {
name services-pnp
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
register 0
}
6.最后在各服务器的hosts和services处添加hosts-pnp、services-pnp
如:
define host{
use linux-server,hosts-pnp
host_name andy.com
alias andy_web.com
address 192.168.1.101
}
define service{
use local-service,services-pnp
host_name andy.com
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
7.重启nagios
/etc/init.d/nagios restart
六、Nconf的安装与配置(可选性安装,我这里只是介绍下安装与配置过程 )
1.nconf的准备工作
mysql -uroot -p
mysql> create database nconf;
mysql> grant all privileges on nconf.* to nconf@"%" identified by 'nconf';
mysql> flush privileges;
mysql> quit
2.安装nconf
下载: http://sourceforge.net/projects/nconf/files/nconf/
tar nconf-1.3.0-0.tgz
mv nconf /usr/local
chown -R apache:apache /usr/local/nconf
3.在apache添加nconf目录虚拟主机
vi /etc/httpd/conf.d/nconf.conf
加入如下内容:
DocumentRoot /usr/local
ServerName 192.168.1.151
重启apache
service httpd restart
4.进入Web页面在按照安装提示一步步安装---比较简单!!
5.使用上面建立的数据库和用户(nconf)成功连接mysql数据库,之后一切保持默认,直到下面认证设置时选择"ture",再设置nconf管理员密码,默认登录用户为admin!
6.安装完成之后,提示删除安装时的初始化文件
cd /usr/local/nconf
rm -rf INSTALL INSTALL.php UPDATE UPDATE.php
ln -s /usr/local/nagios/bin/nagios bin/nagios
chmod +x /usr/local/nconf/bin/generate_config.pl
chown -R apache.apache bin
chmod +x /usr/local/nagios/bin/nagios
chmod +x /usr/local/nconf/ADD-ONS/deploy_local.sh
7.重新刷新页面,输入admin/您设置的密码,进入nconf页面
8.点击Generate Nagios config尝试生成配置文件,以测试是否与nagios成功关联
deploy_local.sh是nconf自带配置文件导入脚本
/usr/local/nconf/ADD-ONS/deploy_local.sh
手动执行此脚本,将在/usr/local/nagios/etc下生成两目录Default_collector与global
修改nagios主配置文件
vim /usr/local/nagios/etc/nagios.cfg
# 将其中cfg_file=*******字段全部注释 ,并加入
cfg_dir=/usr/local/nagios/etc/Default_collector
cfg_dir=/usr/local/nagios/etc/global
service nagios reload
# 重载nagios配置文件使之生效
------------------------------------------------第二部分:nagios配置文件分配问题---------------------------------------
配置文件的规划--有两种常规方案
方案一:根据主机服务分开,主机一个独立配置文件,服务一个对应配置文件
系统文件统一放在objects目录下:
commands.cfg localhost.cfg timeperiods.cfg contacts.cfg templates.cfg
主机目录:建立hosts目录存放主机
服务目录:建立services目录存放服务
命令目录:建立commands目录存放命令
在nagios.cfg配置文件中修改相应地方如下:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_dir=/usr/local/nagios/etc/services
cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/commands
方案二:每个服务器独立配置文件
系统文件统一放在objects目录下:
commands.cfg localhost.cfg timeperiods.cfg contacts.cfg templates.cfg
第个被监控服务器独立一个配置文件:
如:192.168.1.100.cfg
在配置文件中修改相应地方如下:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/linux_srv/192.168.1.100.cfg
...
...
...
cfg_file=/usr/local/nagios/etc/linux_srv/192.168.1.110.cfg
根据情况自己做选择!!
一、配置监控Linux主机实例
1.安装nagios-plugins插件
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/usr/local/nagios
make;make install
2.监控linux时是通过nrpe来建立连接,所以要在服务端和客户端先安装上pcre
服务端的安装:
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz/download tar zxf nrpe-2.13.tar.gz cd nrpe-2.13 ./configure:make all:make install-plugin
测试插件与客户端是否正常通信
/usr/local/nagios/libexec/check_nrpe -H 192.168.8.30
NRPE v2.13
说明之间是连通的!!
定义check_nrpe监控命令
vi /usr/local/nagios/etc/objects/commands.cfg
添加如下内容:
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
客户端的安装:
tar zxvf nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
修改nrpe配置文件
vi /usr/local/nagios/etc/nrpe.cfg
找到下面两处并修改成如下样子:
server_address=192.168.8.30 //这是客户端本身自己IP地址,这里一定要写真实IP
allowed_hosts=192.168.8.130,127.0.0.1 //192.168.8.130是我的nagios监控机
启动nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
netstat -tunpl |grep 5566
lsof -i:5666
----------------------------------第三部分:cacti部分-----------------------------------------------------------
一、cacti服务器配置部分
++++++++++++++++++++++++++++++++++++++++++++++++++
cacti安装与配置
1.cacti绘图要用到rrdtool这个工具
可以用源码安装,也可用yum来安装。。
rrdtool前面在安装nagios--pnp时已经装了,这里只说下
这里介绍用yum来安装:
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum -y install rrdtool
2.安装依赖包
在主监控机上安装apache+php+gd的web环境,为了方便就用yum安装了!
yum -y install php php-devel php-mysql php-snmp mysql mysql-server net-snmp net-snmp-libs net-snmp-utils php-pdo perl-DBD-MySQL
由于本机上同时装了nagios,所以这里php与mysql相关的软件包就不用装了!
yum -y install php-devel php-snmp net-snmp net-snmp-libs net-snmp-utils
3.配置snmp
vi /etc/snmp/snmp.conf
#将下边这行中的default 改为127.0.0.1
com2sec notConfigUser defaultpublic
com2sec notConfigUser 127.0.0.1 public
#将下边这行中的systemview 改为all
access notConfigGroup "" any noauth exact systemview none none
access notConfigGroup "" any noauth exact all none none
#将下边这行的注释“#”号去掉
#view all included .1 80
启动snmpd服务
service snmpd start
4.安装cacti
cd /usr/local/src/cacti
wget http://www.cacti.net/downloads/cacti-0.8.7h.tar.gz
tar zxvf cacti-0.8.7h.tar.gz
mv cacti-0.8.7h /usr/local/cacti
5.在数据库中建库、授权、导入数据库结构
先启动mysql服务
service mysqld start
#注意导入cacti.sql时该文件的路径
mysql
mysql> create database cacti;
mysql> grant all privileges on cacti.* to cacti@localhost identified by 'cacti'with grant option;
mysql> grant all privileges on cacti.* to [email protected] identified by 'cacti'with grant option;
mysql> use cacti;
mysql> source /usr/local/cacti/cacti.sql;
配置cacti以连接数据库
vi /usr/local/cacti/include/config.php
改成如下:
*/
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
/* Default session name - Session name must contain alpha characters */
#$cacti_session_name = "Cacti";
保存退出!!
同时也修改下 /usr/local/cacti/include/global.php 按以上形式修改.
6.在apache中配置cacti的虚拟主机配置文件
vi /etc/http/conf.d/cacti.conf
加入如下内容:
Alias /cacti "/usr/local/cacti"
"/usr/local//cacti "> Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
重新启动apache
service httpd restart
7.浏览器进行cacti初使配置
用浏览器打开 http://IP/cacti #这里IP是cacti服务器的IP
这个很简单。。就不用说了!
8.先手工生成图表
php /usr/local/cacti/poller.php
创建任务计划
crontab -e
*/1 * * * * php /usr/local/cacti/poller.php > /dev/null 2>&1
确保 /usr/local/cacti/rra/目录存在
过几分种后,我们打开cacti web监控页面,点击graphs ,就可以查看到cacti 监控本机的图表~~~
二、cacti常用插件安装
cacti-plugin、npc、monitor、setting、thold、weathermap等。。。。
1.先安装cacti扩展模块
cd /usr/local/src/cacti
wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz
tar xvf cacti-plugin-0.8.7h-PA-v3.0.tar.gz
alias cp=cp
cp -R cacti-plugin-arch/* /usr/local/cacti/
cd /usr/local/cacti/
mysql -ucacti -pcacti cacti < pa.sql
patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff
PS:为cacti配置文件打补丁的时候有可能它将 include/config.php.dist给打补丁了!!
vi /usr/local/cacti/include/config.php
加入此条语句:$url_path = "/cacti/"
......
#$cacti_session_name = "Cacti";
$url_path = "/cacti/";
.......
打开插件管理功能:
打开“Console----> User Management----> admin”然后在“Realm Permissions”选
项卡中勾选“Plugin Management”,然后点击Save 进行保存!
此时我们会在控制台---> Configuration 选项卡下多了一个Plugin Management 选项卡,到此cacti 架构扩展完成!!
2.settings 安装
可以到此站点下载:http://docs.cacti.net/plugin:settings
tar zxvf settings-v0.71-1.tgz
mv settings /usr/local/cacti/plugins/
回到web控制台:点击Console---> Plugin Management,我们看到多了一个settings 插件,然后点击蓝色向下箭头,再点击向右蓝色箭头启用!!
再点击 Console ---> Settings 后我们会发现多了一个Mail/DNS 选项卡!
在 cacti 配置文件中添加settings 插件:
vi /usr/local/cacti/include/config.php
$plugins[] = 'settings';
3.Monitor 安装
下载:http://docs.cacti.net/plugin:monitor
tar zxvf monitor-v1.3-1.tgz
mv monitor /usr/local/cacti/plugins/
cd /usr/local/cacti/plugins/monitor/
mysql -ucacti -pcacti cacti < monitor.sql
修改 cacti 配置文件,添加monitor 插件
vi /usr/local/cacti/include/config.php
加入如下内容:
$plugins[] = 'monitor';
启用方法同其它插件方法一样!!!!!!!!!!!!!!!!!
4.thold 安装
下载:http://docs.cacti.net/plugin:thold
tar zxvf thold-v0\[1\].4.9-3.tgz
mv thold /usr/local/cacti/plugins/
启用方法同其它插件方法一样!!!!!!!!!!!!!!!!!
回到控制台,我们会发现多了一个“thold”选项
打开“Console --->Settings”,发现多了一个“thresholds”选项卡
5.Weathermap 安装
下载:wget http://www.network-weathermap.com/files/php-weathermap-0.97a.zip
unzip php-weathermap-0.97a.zip
mv weathermap /usr/local/cacti/plugins/
chmod -R 777 /usr/local/cacti/plugins/weathermap
启用方法同其它插件方法一样!!!!!!!!!!!!!!!!!
回到控制台,我们会发现多了一个“weathermap”选项!
到此为止,几个常用插件安装完成!!!!!!!!!!!!!!
PS:其它大部分插件可以到这个网站下载:http://docs.cacti.net/plugins
----------------------------------第四部分:整合nagios与cacti---------------------------------------------------
整合cacti和nagios是利用了cacti的一个插件nagios for cacti,它的原理是将nagios的数据通过ndo2db导入到mysql数据库(cacti的库中),然后cacti读取数据库信息将nagios的结果展示出来。
1.首先需要安装ndoutils以将nagios的数据能导入到mysql数据库中
yum -y install mysql-devel
下载并安装ndoutils
wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz/download
tar zxvf ndoutils-1.4b9.tar.gz
cd ndoutils-1.4b9
./configure --prefix=/usr/local/nagios LDFLAGS=-L/usr/lib64 --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib64/mysql --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
make
2.建立配置文件
cp src/{ndomod-3x.o,ndo2db-3x,file2sock,log2ndo} /usr/local/nagios/bin
cd db
./installdb -ucacti -pcacti -d cacti
cd ..
cp config/{ndo2db.cfg-sample,ndomod.cfg-sample} /usr/local/nagios/etc
mv /usr/local/nagios/etc/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
mv /usr/local/nagios/etc/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
chmod 644 /usr/local/nagios/etc/ndo*
chown nagios:nagios /usr/local/nagios/etc/*
chown nagios:nagios /usr/local/nagios/bin/*
3.修改nagios.cfg配置文件以适应当前环境
vi /usr/local/nagios/etc/nagios.cfg
在文件中添加如下内容:
broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg
4.修改ndo2db.cfg以适应当前环境
vi /usr/local/nagios/etc/ndo2db.cfg
把与下面相关的参数修改成如下形式(有此不用改):
socket_type=tcp
db_servertype=mysql
db_host=localhost
db_port=3306
db_name=cacti
db_prefix=nagios_
db_user=cacti
db_pass=cacti
5.修改ndomod.cfg以适应当前环境
vi /usr/local/nagios/etc/ndomod.cfg
把与下面相关的参数修改成如下形式:
output_type=tcpsocket
output=127.0.0.1
6.让ndo2db开机启动
方法一:
加入到开机启动配置文件:
echo 'rm -f /usr/local/nagios/var/ndo.sock' >> /etc/rc.local
echo '/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg' >> /etc/rc.local
方法二:
cd /usr/local/src/ndoutils-1.4b9
cp ./daemon-init /etc/init.d/ndo2db
vi /etc/init.d/ndo2db
把Ndo2dbBin=/usr/local/nagios/bin/ndo2db改成
Ndo2dbBin=/usr/local/nagios/bin/ndo2db-3x
chmod +x /etc/init.d/ndo2db
service ndo2db start
启动时出现如下错误:
Starting ndo2db:Support for the specified database server is either not yet supported, or was not found on your system.
done.
这个是由于没有安装mysql-devel这个包造成的@!@@@@
解决办法:
yum -y install mysql-devel
./configure --prefix=/usr/local/nagios LDFLAGS=-L/usr/lib64 --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib64/mysql --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
make
alias cp=cp
cp src/{ndomod-3x.o,ndo2db-3x,file2sock,log2ndo} /usr/local/nagios/bin
alias cp="cp -i'
7..npc安装
tar zxvf npc-2.0.4.tar.gz
mv npc /usr/local/cacti/plugins/
修改 cacti 配置文件,添加npc 插件
vi /usr/local/cacti/include/config.php
加入:
$plugins[] = 'npc';
启用方法同其它插件方法一样!!!!!!!!!!!!!!!!!
回到控制台,我们会发现多了一个“npc”选项
安装 npc支持:json
wget http://pecl.php.net/get/json-1.2.1.tgz
tar zxvf json-1.2.1.tgz
cd json-1.2.1
phpize
./configure ;make ;make install
查看是否安装成功:
root@nagios_cacti json-1.2.1]# ll /usr/lib64/php/modules
总计 840
-rwxr-xr-x 1 root root 32344 2010-01-14 dbase.so
-rwxr-xr-x 1 root root 337768 2010-01-14 gd.so
-rwxr-xr-x 1 root root 92798 03-14 06:05 json.so
-rwxr-xr-x 1 root root 119568 2010-01-14 mysqli.so
-rwxr-xr-x 1 root root 53008 2010-01-14 mysql.so
-rwxr-xr-x 1 root root 28264 2010-01-14 pdo_mysql.so
-rwxr-xr-x 1 root root 92464 2010-01-14 pdo.so
-rwxr-xr-x 1 root root 24200 2010-01-14 pdo_sqlite.so
-rwxr-xr-x 1 root root 15416 2009-09-04 phpcups.so
-rwxr-xr-x 1 root root 28568 2010-01-14 snmp.so
修改php.ini文件添加对json的支持
vi /etc/php.ini
添加如下内容:
extension=json.so
重新启动apache
service httpd restart
查看是否加载了这个模块:
php -m |grep json
接着在右侧栏目中选择settings,点选npc的标签
钩选Remote Commands
Nagios Command File Path: /usr/local/nagios/var/rw/nagios.cmd
<这个文件启动nagios后会产生,根据实际的位置写>
Nagios URL: http://IP/nagios/ (这里ip为nagios服务器IP)
保存就可以了。
------------------------------------------------------------------------------------------
附:linux客户端通用配置
在被监控的linux主机上安装net-snmp
yum -y install net-snmp
vi /etc/snmp/snmpd.conf
将下边这行中的default 改为192.168.1.151 (cacti服务器的IP地址)
com2sec notConfigUser default public
com2secnotConfigUser 172.28.12.36 public
将下边这行中的systemview改为all
access notConfigGroup "" any noauth exact systemview none none
access notConfigGroup "" any noauth exact all none none
将下边这行的注释“#”号去掉
#view all included .1 80
启动snmp
service snmpd start
这配置全是通用的,大家可以慢慢去尝试造!