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 ,查看如何使用這些監控腳本和程序。如果你自己寫的程序最好也放在這個目錄下。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章