nagios3.2 安装笔记
安装前的准备工作nagios-3.2.0.tar.gznagios-cn-3.2.0.tar.bz2nagios-plugins-1.4.14.tar.gz
apachephp
1. 为nagios服务建立用户及用户组,这里建立一个nagcmd的用户组,把nagios用户和Web执行用户都加入到这个组里:
useradd -m nagios && passwd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
2.编译安装
apache编译安装
cd /home/src/http
tar zxvf httpd-2.2.11.tar.gz
mv httpd-2.2.11 http
cd http
./configure --prefix=/usr/local/apache2 --enable-so --with-mpm=worker --enable-cache--enable-mem-cache --enable-disk-cache- -enable-proxy-balancer--enable-proxy-ajp--enable-proxy-http --enable-proxy-ftp --enable-proxy-connect--enable-proxy --enable-ssl --enable-static-htpasswd --enable-charset-lite --enable-rewrite --enable-vhost-alias(可灵活选择,如无必要,模块使用越少则越安全,当然不包括安全模块等特殊模块。)
make&&make install
/usr/local/apache2/bin/apachectl -t start #启动apache
打开页测试ip:80显示it works表示成功。
##php5.3
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --with-gd=/usr/local/gd2 --with-libdir=lib64--enable-track-vars --with-xml --with-mysql --with-zlib-dir=/usr/local
出错时Unable to find libgd.(a|so) anywhere under /usr/local/gd2
#cp /usr/local/gd2/lib/* /usr/local/gd2/
1./configure --prefix=/usr/ local /apache2/htdocs/nagios --with-nagios-user=www --with-nagios-group=www --with- command-user=www --with- command -group=www --with-gd-lib=/usr/local /gd2/lib --with-gd-inc=/usr/ local /gd2/include --with-init- dir =/etc/init.d --with-httpd-conf=/usr/ local/apache2/conf/extra
yum install gb gb-devel httpd php
tar zxvf nagios-3.2.0.tar.gz
./configure --prefix=/usr/local/nagios
make all
make install
安装主程序.CGI和HTML文件
make install-init
在/etc/rc.d/init.d目录下建立nagios的启动脚本
make install-commandmode
配置目录权限
make install-config
安装nagios的配置文件模板,默认路径是/usr/local/nagios/etc
tar jxvf nagios-plugins-1.4.14.tar.gz
插件版本号与主版本号关联不大
./configure --prefix=/usr/local/nagios
make && make install
安装完成后在/usr/local/nagios/libexec目录下,生成很多可执行文件
tar zxcf nagios-cn-3.2.0.tar.gz
下载地址:http://sourceforge.net/projects/nagios-cn/files/
./configure--prefix=/usr/local/nagios
默认路径即为/usr/local/nagios所以这里可以不用添加
make all && make install
nagios 3.1.X以后版本需有PHP支持
3.配置apache和php
httpd.conf
----------------
修改
User apache
Group apache
Directoryindex index.php
AddType application/x-httpd-php .php
增加
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
Alias /nagios /usr/local/nagios/share
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
copy时应注意:
空格字符必须时英文半角
否则启动时启动时会报如下错误
Invalid command '\xe3\x80\x80\xe3\x80\x80', perhaps mis-spelled or defined by a module not included in the server configuration
4.对web目录作认证
htpasswd -c /usr/local/nagios/etc/htpasswd admin
5.启动apache
apachectl start
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
NRPE的部署
NagisoCore----plugin----Nrpe----|-----(SSL)------|----plugin(Ntclient++)---Nrpe
NRPE的安装
1.新建用户
useradd -s /usr/sbin/nolgin nagios
2.安装plugin
./configure --prefix=/usr/local/nagios&&make && make install
3.安装NRPE
./confugure --prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
4.配置NRPE
vim/usr/local/nagios/etc/nrpe.cfg
修改
server_address=127.0.0.1,192.168.10.99(本地)
allowed_address=127.0.0.1,192.168.10.234(远程)
5.启动守护进程
/usr/local/nagios/bin/nrpe -c /usr/loacl/nagios/etc/nrpe.cfg -d
可以将以上命令加入到rc.local开机自动启动
6.检查
netstat -antl |grep 5666
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
页:
[1]