Nagios监控软件源码安装
nagios是目前非常流行的系統(tǒng),服務(wù)器監(jiān)控免費軟件,很多大的國內(nèi)站點像搜狐,網(wǎng)易都在使用nagios進(jìn)行服務(wù)器監(jiān)控。
nagios的有點在于他本身只是一個框架,對于nagios擴展監(jiān)控模塊,以及報警模塊非常方便,能很方便的加入自己編寫的服務(wù)監(jiān)控,以及手機短信,郵件,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
設(shè)置apache服務(wù)器訪問密碼:
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
現(xiàn)在你可以通過瀏覽器訪問監(jiān)控的界面了,http://www.example.com/nagios
現(xiàn)在你僅僅能看到對于本機的監(jiān)控,接下來我們添加一個http服務(wù)的監(jiān)控
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
具體內(nèi)容如下:
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
}
請根據(jù)具體情況修改為你要監(jiān)控的主機以及域名,現(xiàn)在來看看你的配置文件是否正確:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果爭取,請重啟nagios服務(wù)器
service nagios start
接下來請去瀏覽器看看吧,如果在host部分看到pending別奇怪啊,我們只設(shè)置了監(jiān)控www服務(wù)器,如果你需要監(jiān)控alive ,請參考localhost.cfg配置文件。
在libexec目錄下,所有的監(jiān)控腳本和應(yīng)用都在,你可以用 prog -h ,查看如何使用這些監(jiān)控腳本和程序。如果你自己寫的程序最好也放在這個目錄下。
轉(zhuǎn)載于:https://blog.51cto.com/xiufm/1613991
總結(jié)
以上是生活随笔為你收集整理的Nagios监控软件源码安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: raspberry pi pico|在r
- 下一篇: 虚拟机与Framework及高阶技术面试