正在加载...

nagios安装

[ 2008/12/23 22:58 | by selboo ]

nagios是目前非常流行的系统,服务器监控免费软件,很多大的国内站点像搜狐,网易都在使用nagios进行服务器监控。
nagios的有点在于他本身只是一个框架,对于nagios扩展监控模块,以及报警模块非常方便,能很方便的加入自己编写的服务监控,以及手机短信,邮件,gtalk ,msn报警等等。
以下是nagios在linux REDHAT AS4U4 下的安装和简单的配置过程:
下载软件:
wget http://surfnet.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.3.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.12.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagiosmib-1.0.0.tar.gz
添加用户:

useradd -m nagios
passwd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd daemon

编译安装nagios
tar -xvzf nagios-3.0.3.tar.gz
cd nagios-3.0.3
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
设置apache服务器访问密码:
cd /usr/local/nagios/etc/
/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
cd /usr/local/apache/conf/
vi httpd-vhosts.conf
配置apache的cgi ,具体配置如下:
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user

Alias /nagios /usr/local/nagios/share

Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user

重启apache
/usr/local/apache/bin/apachectl configtest
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start
安装nagios插件
tar -xvzf nagios-plugins-1.4.12.tar.gz
cd nagios-plugins-1.4.12
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
chkconfig --add nagios
chkconfig nagios on
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start
现在你可以通过浏览器访问监控的界面了,http://www.example.com/nagios
现在你仅仅能看到对于本机的监控,接下来我们添加一个http服务的监控
cd /usr/local/nagios/
vi nagios.cfg
添加一行:
cfg_file=/usr/local/nagios/etc/objects/wwws.cfg
编写配置wwws.cfg
touch objects/hosts.cfg objects/wwws.cfg
vi objects/wwws.cfg
具体内容如下:
define host{                                          
        use             generic-host                  
        host_name               maycode              
        alias           www.maycode.com              
        address         10.11.24.42                  
        hostgroups              webhosts              
        max_check_attempts 10                        
}                                                    
                                                      
define hostgroup{                                    
        hostgroup_name  webhosts                      
        alias           web service hosts            
        members         maycode                      
}                                                    
                                                      
define service{                                      
        use             generic-service              
        host_name               maycode              
        service_description     HTTP                  
        check_command   check_http! -H www.maycode.com
}
请根据具体情况修改为你要监控的主机以及域名,现在来看看你的配置文件是否正确:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果争取,请重启nagios服务器
service nagios start
接下来请去浏览器看看吧,如果在host部分看到pending别奇怪啊,我们只设置了监控www服务器,如果你需要监控alive ,请参考localhost.cfg配置文件。
在libexec目录下,所有的监控脚本和应用都在,你可以用 prog -h ,查看如何使用这些监控脚本和程序。如果你自己写的程序最好也放在这个目录下。
Tags: ,
,
发表评论
表情
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]