nagios学习笔记(二)
生活随笔
收集整理的這篇文章主要介紹了
nagios学习笔记(二)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
二、監控linux系統
??? 通過上節的學習,我已經把nagios這個平臺建立起來了,這節將來實現對linux系統的監控。可以用NRPE插件來實現對linux的監控。插件的工作原理如下:
1.配置被監控的linux主機
1)安裝nagios-plugins
#useradd nagios
#tar zxvf nagios-plugins-1.4.14.tar.gz
#cd nagios-plugins-1.4.14
#./configure
#make
#make install
#chown nagios.nagios /usr/local/nagios/
#chown -R nagios.nagios /usr/local/nagios/libexec/
2)安裝nrpe
#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
#tar xzvf nrpe-2.12.tar.gz
#cd nrpe-2.12
#./configure
#make all
#make install-plugin
#make install-daemon
#make install-daemon-config3)配置nrpe
#vi????/usr/local/nagios/etc/nrpe.cfg修改allowed_hosts=127.0.0.1為
allowed_hosts=127.0.0.1,192.168.1.168? 192.168.1.168是我的nagios監控服務器的地址。
4)開啟nrpe daemon
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d注意:我在學習過程中,全部機器的iptables、SElinux都是關閉的。
5)檢測
netstat -lunt查看是否在監聽5566端口。如果是就證明已經成功啟動。
?/usr/local/nagios/libexec/check_nrpe -H localhost 查是否可以利用本地的nrpe插件來監聽本地的nrpe daemon檢測到的信息。
2.配置nagios監控服務器
1)配置命令定義配置文件
vi /usr/local/nagios/etc/objects/commands.cfg
# 'check-host-alive' command definition
define command{
command_name??? check-host-alive
???????command_line??? $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
??????? }
# 'check_nrpe ' command definition
define command{
command_name check_nrpe
?????? command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
???????}如果要實現更多的功能,可以在這里定要命令。比如:要定義發送郵件命令,發送手機短信等。
2)配置聯系人和聯系人組配置文件
vi /usr/local/nagios/etc/objects/contacts.cfg
define contact{
??????? contact_name??????????????????? nagiosadmin???????????? ; Short name of user
??????? use???????????????????????????? generic-contact???????? ; Inherit default values from generic-contact template (defined above)
??????? alias?????????????????????????? Nagios Admin??????????? ; Full name of user
??????? email?????????????????????????? nagios@localhost??????? ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
??????? }
define contactgroup{
??????? contactgroup_name?????? admins
??????? alias?????????????????? Nagios Administrators
??????? members???????????????? nagiosadmin
??????? }
在定義聯系人的時候注意這條語句:use generic-contact,這個是引用模板文件(/usr/local/nagios/etc/objects/templates.cfg)里的。在這個文件里可以增加多個聯系人和組。
3)配置監控時間配置文件
define timeperiod{
??????? timeperiod_name 24x7
??????? alias?????????? 24 Hours A Day, 7 Days A Week
??????? sunday????????? 00:00-24:00
??????? monday????????? 00:00-24:00
??????? tuesday???????? 00:00-24:00
??????? wednesday?????? 00:00-24:00
??????? thursday??????? 00:00-24:00
??????? friday????????? 00:00-24:00
??????? saturday??????? 00:00-24:00
??????? }
(待續)
??? 通過上節的學習,我已經把nagios這個平臺建立起來了,這節將來實現對linux系統的監控。可以用NRPE插件來實現對linux的監控。插件的工作原理如下:
1.配置被監控的linux主機
1)安裝nagios-plugins
#useradd nagios
#tar zxvf nagios-plugins-1.4.14.tar.gz
#cd nagios-plugins-1.4.14
#./configure
#make
#make install
#chown nagios.nagios /usr/local/nagios/
#chown -R nagios.nagios /usr/local/nagios/libexec/
2)安裝nrpe
#wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
#tar xzvf nrpe-2.12.tar.gz
#cd nrpe-2.12
#./configure
#make all
#make install-plugin
#make install-daemon
#make install-daemon-config3)配置nrpe
#vi????/usr/local/nagios/etc/nrpe.cfg修改allowed_hosts=127.0.0.1為
allowed_hosts=127.0.0.1,192.168.1.168? 192.168.1.168是我的nagios監控服務器的地址。
4)開啟nrpe daemon
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d注意:我在學習過程中,全部機器的iptables、SElinux都是關閉的。
5)檢測
netstat -lunt查看是否在監聽5566端口。如果是就證明已經成功啟動。
?/usr/local/nagios/libexec/check_nrpe -H localhost 查是否可以利用本地的nrpe插件來監聽本地的nrpe daemon檢測到的信息。
2.配置nagios監控服務器
1)配置命令定義配置文件
vi /usr/local/nagios/etc/objects/commands.cfg
# 'check-host-alive' command definition
define command{
command_name??? check-host-alive
???????command_line??? $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
??????? }
# 'check_nrpe ' command definition
define command{
command_name check_nrpe
?????? command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
???????}如果要實現更多的功能,可以在這里定要命令。比如:要定義發送郵件命令,發送手機短信等。
2)配置聯系人和聯系人組配置文件
vi /usr/local/nagios/etc/objects/contacts.cfg
define contact{
??????? contact_name??????????????????? nagiosadmin???????????? ; Short name of user
??????? use???????????????????????????? generic-contact???????? ; Inherit default values from generic-contact template (defined above)
??????? alias?????????????????????????? Nagios Admin??????????? ; Full name of user
??????? email?????????????????????????? nagios@localhost??????? ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
??????? }
define contactgroup{
??????? contactgroup_name?????? admins
??????? alias?????????????????? Nagios Administrators
??????? members???????????????? nagiosadmin
??????? }
在定義聯系人的時候注意這條語句:use generic-contact,這個是引用模板文件(/usr/local/nagios/etc/objects/templates.cfg)里的。在這個文件里可以增加多個聯系人和組。
3)配置監控時間配置文件
define timeperiod{
??????? timeperiod_name 24x7
??????? alias?????????? 24 Hours A Day, 7 Days A Week
??????? sunday????????? 00:00-24:00
??????? monday????????? 00:00-24:00
??????? tuesday???????? 00:00-24:00
??????? wednesday?????? 00:00-24:00
??????? thursday??????? 00:00-24:00
??????? friday????????? 00:00-24:00
??????? saturday??????? 00:00-24:00
??????? }
(待續)
轉載于:https://blog.51cto.com/bjrefine/285304
總結
以上是生活随笔為你收集整理的nagios学习笔记(二)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JS 对select动态添加option
- 下一篇: Lotus Notes 和 Crysta