免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2469 | 回复: 6
打印 上一主题 下一主题

nagios [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-09 22:58 |只看该作者 |倒序浏览
这个软件怎么样?

论坛徽章:
0
2 [报告]
发表于 2006-02-09 23:01 |只看该作者
系统是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.
为什么????????????????????

论坛徽章:
0
3 [报告]
发表于 2006-02-09 23:01 |只看该作者
请名位帮帮忙

论坛徽章:
0
4 [报告]
发表于 2006-02-10 19:46 |只看该作者

嘿嘿

学习下~~

论坛徽章:
0
5 [报告]
发表于 2006-02-11 16:32 |只看该作者
查一下minal.cfg中是不是也配制了'generic-host'

有的话,干掉就可以了.

论坛徽章:
0
6 [报告]
发表于 2006-02-12 18:21 |只看该作者
谢谢,以解决,

论坛徽章:
0
7 [报告]
发表于 2006-02-12 18:26 |只看该作者
怎么样把自己编写的shell运用到nagios里。
我的这个办法你们看一下行不?
# vi /usr/local/nagios/libexec/check_file_exist.sh
# chown nagios:nagios /usr/local/nagios/libexec/check_file_exist.sh
# chmod +x /usr/local/nagios/libexec/check_file_exist.sh
# vi /usr/local/nagios/etc/minimal.cfg
define command{
command_name check_file_exist
command_line $USER1$/check_file_exist.sh -F /tmp/nagios.chk
}
define service{
use generic-service
host_name localhost
service_description File check
is_volatile 0
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
check_command check_file_exist
}
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
无错误
# /etc/init.d/nagios restart
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP