服务器维护,服务器代维,安全设置,漏洞扫描,入侵检测服务

运维之家

 找回密码
 注册
搜索
查看: 3716|回复: 0

linux+lighttpd+nagios安装配置V1.0,nagios+web

[复制链接]
dirtysea 发表于 2010-11-22 16:25:08 | 显示全部楼层 |阅读模式




linux+lighttpd+nagios安装配置V1.0,nagios+web

通过nagiosQL管理nagios非常方便,简单

1.环境:
ubuntu         9.04 x86_64
nagios        3.2.1
nagios-plugins    1.4.14
lighttpd    1.4.19

2.下载地址
http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz
http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

web admins
http://downloads.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.0.3/nagiosql303.zip?use_mirror=nchc

3.安装依赖包
apt-get install  build-essential lighttpd php5-cgi php5-cli php5-curl php5-gd php5-mysql php-html-template-it unzip

4.添加相关用户
useradd nagiospasswd nagiosusermod -G nagios nagiosgroupadd nagcmdusermod -G nagcmd nagiosusermod -G nagcmd www-data


5.编译安装Nagios

tar xvzf nagios-3.2.1.tar.gz
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
cp sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf


6.编译安装Nagios插件

tar xvzf nagios-plugins-1.4.14.tar.gz
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install


7.验证Nagios配置文件,启动

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start


8.lighttpd配置

生成auth key
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin  #回车后输入2次密码
启用php fastcgi

lighty-enable-mod fastcgi
修改Lighttpd主配置文件,添加nagios支持

vi /etc/lighttpd/lighttpd.conf
server.modules              = (
            "mod_access",
            "mod_alias",
            "mod_cgi",
            "mod_setenv",
            "mod_auth",
            "mod_compress"
)
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi" )
alias.url += (

        "/nagios/cgi-bin" => "/usr/local/nagios/sbin",
        "/nagios"       =>      "/usr/local/nagios/share/"
        )
$HTTP["url"] =~ "^/nagios/cgi-bin" {

        cgi.assign = ( "" => "" )
}
$HTTP["url"] =~ "^/nagios" {

        auth.backend = "htpasswd"
        auth.backend.htpasswd.userfile = "/usr/local/nagios/etc/htpasswd.users"
        auth.require = ( "" => (
                "method" => "basic",
                "realm" => "nagios",
                "require" => "user=nagiosadmin"
                )
        )
        setenv.add-environment = ( "REMOTE_USER" => "user" )
}


9.安装配置nagiosql

unzip nagiosql303.zip
mv nagiosql3 /www/web/nagadmin
chown -R www-data:www-data /www/web/nagadmin/
cd /www/web/nagadmin/install
touch ENABLE_INSTALLER
http://gaojinbo.com/nagadmin  安装sample数据
lighttpd.conf

alias添加一行,修改为:
alias.url += (
        "/nagios/cgi-bin" => "/usr/local/nagios/sbin",
        "/nagios"       =>      "/usr/local/nagios/share/",
        "/nagadmin"             =>      "/www/web/nagadmin"
        )


10.通过web访问配置nagios

http://gaojinbo.com/nagadmin
建立文件夹

mkdir -p /etc/nagiosql/backup/hosts
mkdir -p /etc/nagiosql/backup/services
mkdir -p /etc/nagiosql/hosts
mkdir -p /etc/nagiosql/services
mkdir /etc/nagios
mkdir /etc/nagios/import
touch /etc/nagios/nagios.cfg
touch /etc/nagios/cgi.cfg
Permissions权限设置

chgrp www-data /etc/nagios
chgrp www-data /etc/nagios/nagios.cfg
chgrp www-data /etc/nagios/cgi.cfg
chmod 775 /etc/nagios
chmod 664 /etc/nagios/nagios.cfg
chmod 664 /etc/nagios/cgi.cfg
chgrp www-data /usr/local/nagios/etc/nagios.cfg
chgrp www-data /usr/local/nagios/etc/cgi.cfg
chmod 664 /usr/local/nagios/etc/nagios.cfg
chmod 664 /usr/local/nagios/etc/cgi.cfg
chmod 6755 /etc/nagiosql
chown www-data.nagios /etc/nagiosql
chmod 6755 /etc/nagiosql/hosts
chown www-data.nagios /etc/nagiosql/hosts
chmod 6755 /etc/nagiosql/services
chown www-data.nagios /etc/nagiosql/services   
chmod 6755 /etc/nagiosql/backup
chown www-data.nagios /etc/nagiosql/backup
chmod 6755 /etc/nagiosql/backup/hosts
chown www-data.nagios /etc/nagiosql/backup/hosts
chmod 6755 /etc/nagiosql/backup/services
chown www-data.nagios /etc/nagiosql/backup/services
chmod 644 /etc/nagiosql/*.cfg
chown www-data.nagios /etc/nagiosql/*.cfg
chmod 644 /etc/nagiosql/hosts/*.cfg
chown www-data.nagios /etc/nagiosql/hosts/*.cfg   
chmod 644 /etc/nagiosql/services/*.cfg
chown www-data.nagios /etc/nagiosql/services/*.cfg   
修改/usr/local/nagios/etc/nagios.cfg

注释掉所有cfg_file,cfg_dir开始的行,添加以内容到文件最后
#change for hugwww

   cfg_file=/etc/nagiosql/contacttemplates.cfg
   cfg_file=/etc/nagiosql/contactgroups.cfg
   cfg_file=/etc/nagiosql/contacts.cfg
   cfg_file=/etc/nagiosql/timeperiods.cfg
   cfg_file=/etc/nagiosql/commands.cfg
   cfg_file=/etc/nagiosql/hostgroups.cfg

   cfg_file=/etc/nagiosql/servicegroups.cfg
   cfg_dir=/etc/nagiosql/hosts

   cfg_dir=/etc/nagiosql/services
   cfg_file=/etc/nagiosql/hosttemplates.cfg

   cfg_file=/etc/nagiosql/servicetemplates.cfg
   cfg_file=/etc/nagiosql/servicedependencies.cfg
   cfg_file=/etc/nagiosql/serviceescalations.cfg
   cfg_file=/etc/nagiosql/hostdependencies.cfg
   cfg_file=/etc/nagiosql/hostescalations.cfg
   cfg_file=/etc/nagiosql/hostextinfo.cfg
   cfg_file=/etc/nagiosql/serviceextinfo.cfg
Administration -> Domains -> 修改

Nagios base directory* /usr/local/nagios/etc/

完成!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|手机版|Archiver|运维之家

GMT+8, 2021-12-7 05:22 , Processed in 0.042984 second(s), 14 queries .

Powered by Dirtysea

© 2008-2020 Dirtysea.com.

快速回复 返回顶部 返回列表