Nagios监控软件源码安装

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

http://pan.baidu.com/s/1jG5jZL0


添加用户:

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

编译安装nagios
tar -xvzf nagios-cn-3.2.3.tar.bz2

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
<Directory “/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
</Directory>
Alias /nagios /usr/local/nagios/share
<Directory “/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
</Directory>
重启apache
/usr/local/apache/bin/apachectl configtest
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl start
安装nagios插件
tar -xvzf nagios-plugins-2.0.1.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 ,查看如何使用这些监控脚本和程序。如果你自己写的程序最好也放在这个目录下。


本文出自 “7924127” 博客,请务必保留此出处http://7934127.blog.51cto.com/7924127/1583141

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。