nagios的安装

(1)
[size=x-large]将Nagios监控服务器的运行用户和组设置为nagios,并且将nagios的主程序目录设置为nagios,保证系统的安全。[/size]
[code="shell"]
# useradd -s /sbin/nologin nagios
# vi /etc/passwd
# mkdir /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/
[/code]

(2)
[size=x-large]开启系统sendmail服务。[/size]

(3)
[size=x-large]编译安装。[/size]
[code="shell"]
tar -zxvf nagios-3.3.0.tar.gz
cd nagios-3.3.0
./configure --prefix =/usr/local/nagios

*** Configuration summary for nagios 3.3.1 07-25-2011 ***:

General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/nagios/
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu

Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute


make all

*** Compile finished ***

If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):

make install
- This installs the main program, CGIs, and HTML files

make install-init
- This installs the init script in /etc/rc.d/init.d

make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file

make install-config
- This installs *SAMPLE* config files in /usr/local/nagios//etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!

make install-webconf
- This installs the Apache config file for the Nagios
web interface

make install-exfoliation
- This installs the Exfoliation theme for the Nagios
web interface

make install-classicui
- This installs the classic theme for the Nagios
web interface


# make install


# make install-init
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios


# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios//var/rw
chmod g+s /usr/local/nagios//var/rw

#make install-commandmode命令用来配置目录权限


# make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios//etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios//etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios//etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios//etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios//etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios//etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios//etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios//etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios//etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios//etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios//etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios//etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios//etc/objects/switch.cfg

#make install-config命令用来安装Nagios示例配置文件,这里的安装路径是/usr/local/nagios/etc


#设置开机自动启动,之前已经在/etc/rc.d/init.d目录下建立了nagios启动脚本,现在只需要用\chkconfig --add filename自动注册开机启动和关机关闭。实质就是在rc0.d-rc6.d目录下生成一些文件连接,这些连接连接到/etc/rc.d/init.d目录下指定文件的shell脚本。


# chkconfig --list nagios
nagios 服务支持 chkconfig,但它在任何级别中都没有被引用(运行“chkconfig --add nagios”)
# chkconfig --add nagios
# chkconfig --level 35 nagios on
# chkconfig --list nagios
nagios 0:关闭 1:关闭 2:关闭 3:启用 4:启用 5:启用 6:关闭


[/code]


(4)[size=x-large]安装Nagios插件.[/size]
Nagios提供的各种监控功能基本是通过插件来完成,而Nagios核心只提供了很少的监控功能,因而安装插件是必须的。插件版本和Nagios版本关联不大。

下载nagios-plugin,并编译安装。

插件安装路径最好和Nagios安装路径一直,这样安装完插件会在Nagios主程序目录下生成很多可执行文件,这些就是Nagios所需要的插件。


(5)[size=x-large]安装配置Apache[/size]

(5).1.安装apache,php。
php安装结果如下:


Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar - installed: 1.3.7
[PEAR] Console_Getopt - installed: 1.3.0
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util - installed: 1.2.1
[PEAR] PEAR - installed: 1.9.2
Wrote PEAR system config file at: /usr/local/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/home/Gogo_yueyue/下载/php-5.3.6/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/





(5).2.配置apache.


[code="shell"]

# vi /usr/local/apache2/conf/httpd.conf

修改Apache进程的启动用户

User nagios

Group nagios


然后修改
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
DirectoryIndex index.php
</IfModule>

增加如下内容

AddType application/x-httpd-php .php .phtml


为了安全其间,一般情况下要让nagios的web监控界面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf文件最后添加如下信息:
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/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
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/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
</Directory>
[/code]

(5).3创建Apache目录验证文件
在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:
[code="shell"]

# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd Gogo_yueyue
New password:
Re-type new password:
Adding password for user Gogo_yueyue


[/code]

这样就在/usr/local/nagios/etc目录下创建了一个htpasswd验证文件,当通过[size=x-large][color=red]http://ip/nagios/[/color][/size]访问时就需要输入用户名和密码了。
最后,启动服务:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值