- 论坛徽章:
- 0
|
系统是freebsd
安装过程:
一、 所需软件
nagios-2.0rc2.tar
nagios-plugins-1.4.tar
imagepak-base.tar.gz
二、 安装
1、nagios安装
tar –xvzf nagios-2.0rc2.tar
mkdir /usr/local/nagios
pw useradd nagios –d /usr/local/nagios
pw addgroup root
chmod 755 /usr/local/nagios
cd nagios-2.0rc2
./configure --prefix=/usr/local/nagios --with-gd-lib=/usr/local/lib --with-gd-inc=/usr/local/include
make all
make install
make install-init ##This installs the init script in /usr/local/etc/rc.d
make install-commandmode
make install-config ##将初始的配置文件安装到/usr/local/nagios/etc
注:在makeinstall-init这一步的时候可能会进行不下去,这时只要加个root组即可。
pw addgroup root
2、nagios-plugins的安装
tar –xvzf nagios-plugins-1.4.tar
mkdir /usr/local/nagios-plugins
cd nagios-plugins-1.4
./configure --prefix=/usr/local/nagios-plugins
make all
make install
安装完成以后在/usr/local/nagios-plugins会产生一个libexec的目录,将该目录全部移动到/usr/local/nagios目录下
mv /usr/local/nagios-plugins/libexec /usr/local/nagios
3、imagepak-base的安装
tar –xvzf imagepak-base.tar.gz
解压以后是base目录
cp –R base /usr/local/nagios/share/images/logos
4、安装过程全部结束
这个配置没问题
一、配置apache
在apache的配置文件httpd.conf中追加
ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
<Directory "/usr/local/nagios/sbin/">
AllowOverride AuthConfig
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
Alias /nagios/ /usr/local/nagios/share/
<Directory "/usr/local/nagios/share">
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
二、设置访问权限
1、在/usr/local/nagios/share目录下
vi .htaccess
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/.htpasswd
require valid-user
2、在/usr/local/nagios/sbin目录下
vi .htpasswd
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/.htpasswd
require valid-user
3、/usr/local/apache/bin/htpasswd –c /usr/local/nagios/etc/.htpasswd nagios
这个apache目录根据安装目录的不同而不同,主要所以用.htpasswd这个命令生成用户名和密码
三、配置nagios
1、在/usr/local/nagios/etc下是nagios的配置模板文件.cfg-sample,把.cfg-sample文件全部拷贝成.cfg
例如:cp nagios.cfg-sample nagios.cfg
全部拷贝完成即可.
2、vi dependencies.cfg (在2.0没有生成这个文件,自己创建)
然后保存即可.(在1.2用一个空的文件代替原来的dependencies.cfg文件,否则会出错)
3、修改minimal.cfg,把里面所有定义command的全部注释掉
vi /etc/minimal.cfg
修改cgi.cfg
修改use_authentication=1为use_authentication=0,即不用验证.不然有一些页面不会显示。
4、然后检查配置文件是否出错
/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
出现Total Warnings: 0
Total Errors: 0
为正常
出错的话,就是.cfg文件有问题
5、启动后台进程
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
/usr/local/etc/rc.d/nagios start
6、http://10.4.8.81/nagios/index.html
(如果有些页面看不到的话.可以在cgi.cfg文件中
把带有authorized的选项前的#号去掉即可)
这些配置完以后,基本的nagios配置完成。
nagios能正常起动
关键问题:有错误,请帮指正
hosts.cfg 配置
define host{
name generic-host
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
register 0
}
# another host
define host{
use generic-host
host_name test0 ;被监控的主机名
alias Linux Server #test0
address 10.4.8.81
check_command check-host-alive
max_check_attempts 10
notification_interval 480
notification_period 24x7
notification_options d,u,r
}
hostgroups.cfg配置
define hostgroup{
hostgroup_name linux-admins
alias Linux Servers
#contact_groups linux-admins
members test0
}
contacts.cfg 配置
define contact{
contact_name nagios
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-email,notify-by-epager
host_notification_commands host-notify-by-email,host-notify-by-epager
email aa@163.com
}
contactgroups.cfg配置
define contactgroup{
contactgroup_name linux-admins
alias Linux Administrators
members nagios
}
cat services.cfg 配置
define service{
use generic-service ; Name of service template to use
host_name test0
service_description PING
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 5
retry_check_interval 1
contact_groups linux-admins
notification_interval 240
notification_period 24x7
notification_options c,r
check_command check_ping!100.0,20%!500.0,60%
}
nagios.cfg 配置
cfg_file=/usr/local/nagios/etc/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
主配置中以前是没有起用的,现在启用了,就改了这些
问题:重点啊,帮帮啊
test0# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios 2.0rc2
Copyright (c) 1999-2006 Ethan Galstad (http://www.nagios.org)
Last Modified: 01-10-2006
License: GPL
Reading configuration data...
Warning: Duplicate definition found for host 'generic-host' (config file '/usr/local/nagios/etc/hosts.cfg', starting on line 1)
Running pre-flight check on configuration data...
Checking services...
Checked 6 services.
Checking hosts...
Error: Host 'test0' has no default contact group(s) defined!
Checked 2 hosts.
Checking host groups...
Checked 2 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 2 contacts.
Checking contact groups...
Checked 2 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 22 commands.
Checking time periods...
Checked 1 time periods.
Checking extended host info definitions...
Checked 0 extended host info definitions.
Checking extended service info definitions...
Checked 0 extended service info definitions.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 0
Total Errors: 1
***> One or more problems was encountered while running the pre-flight check...
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
为什么???????????????????? |
|