自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

nagios監(jiān)控網(wǎng)絡(luò)服務(wù)器和網(wǎng)絡(luò)服務(wù)配置篇

安全 網(wǎng)站安全
nagios是一個(gè)完全GPL協(xié)議的開源軟件包,包含有nagios主程序和它的各個(gè)插件,配置非常靈活,可以監(jiān)視的項(xiàng)目很多,可以自定義shell腳本進(jìn)行監(jiān)控服務(wù),非常適合大型網(wǎng)絡(luò)。下面讓我們來看一下nagios的配置過程,看實(shí)現(xiàn)監(jiān)控網(wǎng)絡(luò)服務(wù)器和網(wǎng)絡(luò)服務(wù)是怎么實(shí)現(xiàn)的。

nagios配置

1:配置web接口

假設(shè)你已經(jīng)運(yùn)行了apache,如果沒有,請(qǐng)參考:

http://localhost/upload/blog.php?do-showone-tid-18.html

vi /usr/local/apache2/conf/httpd.conf

添加如下內(nèi)容:

  1. ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin   
  2.  
  3. <Directory "/usr/local/nagios/sbin">   
  4.   Options ExecCGI   
  5.   AllowOverride None   
  6.   Order allow,deny   
  7.   Allow from all   
  8.   AuthName "Nagios Access"   
  9.   AuthType Basic   
  10.   AuthUserFile /usr/local/nagios/etc/htpasswd.users   
  11.   Require valid-user   
  12. </Directory>   
  13.  
  14. Alias /nagios /usr/local/nagios/share   
  15.  
  16. <Directory "/usr/local/nagios/share">   
  17.   Options None   
  18.   AllowOverride None   
  19.   Order allow,deny   
  20.   Allow from all   
  21.   AuthName "Nagios Access"   
  22.   AuthType Basic   
  23.   AuthUserFile /usr/local/nagios/etc/htpasswd.users   
  24.   Require valid-user   
  25. </Directory>  

修改完畢,保存文件,并重啟apache:

/usr/local/apahce2/bin/apachectl restart

2:配置apache的BASIC認(rèn)證:

生成認(rèn)證密碼:

/usr/local/apache2/bin/htpasswd –c /usr/local/nagios/etc/htpasswd.users nagios nagios 

apache接口配置完成。

開始配置nagios:

cd /usr/local/nagios/etc/

在/usr/local/nagios/etc下是nagios的配置模板文件-sample,把.cfg-sample文件全部拷貝成.cfg 

例如:cp nagios.cfg-sample nagios.cfg 

全部拷貝完成即可.

vi minimal.cfg

注釋所有command:

注釋的方法是在每一個(gè)定義語句前面添加”#“

修改cgi.cfg

修改use_authentication=1為use_authentication=0,即不用驗(yàn)證.不然有一些頁面不會(huì)顯示。

現(xiàn)在檢查配置文件是否有語法錯(cuò)誤:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

如果正確,會(huì)顯示以下結(jié)果:

Total Warnings: 0

Total Errors:   0

否則,需要根據(jù)提示進(jìn)行修改配置文件。配置文件等會(huì)再弄?,F(xiàn)在啟動(dòng)nagios

/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg

為了使nagios異常中斷,我們使用daemontools啟動(dòng):

安裝daemontool:

  1. mkdir -p /package   
  2. chmod 1755 /package   
  3. cd /package   
  4. fetch http://cr.yp.to/daemontools/daemontools-0.76.tar.gz   
  5. cd admin/daemontools-0.76/   
  6. package/install  

檢查svscan進(jìn)程是否啟動(dòng):

  1. ps aux | grep svscan   
  2. root       376 0.0 0.0 1636   0 con- IW   -       0:00.00 /bin/sh /command/svscanboot   
  3. root       411 0.0 0.0 1224   208 con- S   8Jul06   0:42.50 svscan /service  

ok,啟動(dòng)正常了。

  1. cd /service   
  2. mkdir nagios   
  3. chmod 1755 nagios   
  4. touch ./run   
  5. chmod 755 ./run   
  6. vi run   
  7. PATH=/usr/local/bin:/usr/bin:/bin   
  8. export PATH   
  9.  
  10. exec env - PATH=$PATH \   
  11. /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg   
  12.  
  13. mkdir log   
  14. cd log   
  15. touch ./run   
  16. chmod 755 ./run   
  17. vi ./run   
  18. #!/bin/sh   
  19. exec setuidgid logadmin multilog t s1000000 n100 ./main   
  20.  
  21. mkdir main   
  22. chmod 777 main   
  23. chown nagios.nagios main   
  24. touch status   
  25. chown nagios.nagios status   
  26.  
  27. svc -u /service/nagios/   
  28. svstat /service/nagios/   
  29. root@## ps auxww | grep nagios   
  30. root     23276 0.0 0.1 1176   488 ?? I   5:00PM   0:01.71 supervise nagios   
  31. nagios   34251 0.0 0.3 2316 1552 ?? S   6:06PM   0:00.10 /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg   
  32. root@##   

ok,現(xiàn)在把nagios服務(wù)做成自動(dòng)啟動(dòng)的服務(wù)了。通過svc命令可以啟動(dòng)或者停止服務(wù)。

  1. ---------------------------------------------------------------------------------   
  2. svc opts services   
  3. opts is a series of getopt-style options. services consists of any number of arguments, each argument naming a directory used by supervise.    
  4.  
  5. -u: Up. If the service is not running, start it. If the service stops, restart it.    
  6. -d: Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.    
  7. -o: Once. If the service is not running, start it. Do not restart it if it stops.    
  8. -p: Pause. Send the service a STOP signal.    
  9. -c: Continue. Send the service a CONT signal.    
  10. -h: Hangup. Send the service a HUP signal.    
  11. -a: Alarm. Send the service an ALRM signal.    
  12. -i: Interrupt. Send the service an INT signal.    
  13. -t: Terminate. Send the service a TERM signal.    
  14. -k: Kill. Send the service a KILL signal.    
  15. -x: Exit. supervise will exit as soon as the service is down. If you use this option on a stable system, you're doing something wrong; supervise is designed to run forever.   
  16. ---------------------------------------------------------------------------------  

比如:

停止nagios--svc -d /service/nagios/

重啟nagios--svc -t /service/nagios/

啟動(dòng)nagios--svc -u /service/nagios/

當(dāng)然,你也可以使用inited的方式進(jìn)行:

/usr/local/etc/rc.d/nagios start/stop

好了,反正daemontools很強(qiáng)大,現(xiàn)在打開網(wǎng)頁:http://localhost/nagios/,一定會(huì)讓你大吃一驚,呵呵,我的服務(wù)器和服務(wù)狀態(tài)都清楚的看到了?,F(xiàn)在我們的nagios中只有一個(gè),那就是它自己,localhost,呵呵,等會(huì)我們添加別的主機(jī)和主機(jī)服務(wù)。

#p#

nagios的廬山真面目

1)為主機(jī)添加一個(gè)服務(wù)

為localhost主機(jī)添加qmail服務(wù)的監(jiān)控,方法如下:

  1. vi minimal.cfg   
  2. define service{   
  3.     use                   generic-service       ; Name of service template to use   
  4.     host_name               localhost   
  5.     service_description         qmail_smtp   
  6.     is_volatile               0   
  7.     check_period             24x7   
  8.     max_check_attempts         1   
  9.     normal_check_interval       1   
  10.     retry_check_interval         1   
  11.     contact_groups             admins   
  12.     notification_options         w,u,c,r                
  13.     notification_interval       960   
  14.     notification_period         24x7   
  15.     check_command             check_smtp!20%!10%!/   
  16.     }  

可以直接拷貝原有的進(jìn)行修改,我這個(gè)就是拷貝的原有的check_local_disk進(jìn)行的。修改host_name,service_description,check_command等

  1. define service{   
  2.     use                   generic-service       ; Name of service template to use   
  3.     host_name               localhost   
  4.     service_description         qmail_pop3   
  5.     is_volatile               0   
  6.     check_period             24x7   
  7.     max_check_attempts         1   
  8.     normal_check_interval       1   
  9.     retry_check_interval         1   
  10.     contact_groups             admins   
  11.     notification_options         w,u,c,r                
  12.     notification_interval       960   
  13.     notification_period         24x7   
  14.     check_command             check_pop!20%!10%!/   
  15.     }  

照貓畫虎的進(jìn)行修改,然后去修改:

  1. vi checkcommands.cfg   
  2. #'check_qmail' command definition   
  3. define command{   
  4.     command_name   check_qmail   
  5.     command_line   $USER1$/check_smtp -H 127.0.0.1   
  6.     }   
  7. define command{   
  8.     command_name   check_pop3    
  9.     command_line   $USER1$/check_pop -H 127.0.0.1        
  10.     }  

保存,然后檢查配置文件:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

如果沒有錯(cuò)誤會(huì)顯示:

Total Warnings: 0

Total Errors:   0

如果有錯(cuò)誤,請(qǐng)根據(jù)提示進(jìn)行錯(cuò)誤的修正。

重啟nagios

svc -d /service/nagios/ && svc -u /service/nagios/

通過web頁面檢查nagios的結(jié)果:

http://10.5.1.153/nagios/

點(diǎn)擊“Service Detail”

#p#

2)添加主機(jī)并添加服務(wù)

我們會(huì)監(jiān)控這臺(tái)主機(jī)的負(fù)載、磁盤等一些沒有通過端口方式啟動(dòng)的服務(wù)器狀態(tài),以及它的服務(wù),比如:apache、mysql、qmail和ntp等等吧。那么沒有端口的nagios直接能監(jiān)控到嗎?答案是不行。所以我們必須在兩臺(tái)主機(jī)上安裝nrpe,nrpe可以啟動(dòng)5666端口,把檢測(cè)的信息源源不斷的傳給監(jiān)控中心的主機(jī)。

ok,我們把a(bǔ)pache、mysql、qmail和ntp先加上,這回我們把監(jiān)控的主機(jī)和服務(wù)新建一個(gè)文件:

  1. cd /usr/local/nagios/etc/   
  2. touch 10_5_1_156.cfg   
  3. vi nagios.cfg   
  4. cfg_file=/usr/local/nagios/etc/10_5_1_156.cfg   
  5.  
  6. vi 10_5_1_156.cfg  

定義一個(gè)主機(jī):

  1. define host{   
  2.     use               generic-host         ; Name of host template to use   
  3.     host_name           test_nrpe   
  4.     alias             client      
  5.     address           10.5.1.156   
  6.     check_command       check-host-alive   
  7.     max_check_attempts     1    
  8.     check_period         24x7   
  9.     notification_interval   120   
  10.     notification_period   24x7   
  11.     notification_options   d,r   
  12.     contact_groups admins   
  13.     }  

定義主機(jī)需要檢查的服務(wù):

  1. define service{   
  2.     use                   generic-service       ; Name of service template to use   
  3.     host_name               test_nrpe   
  4.     service_description         PING   
  5.     is_volatile               0   
  6.     check_period             24x7   
  7.     max_check_attempts         1   
  8.     normal_check_interval       1   
  9.     retry_check_interval         1   
  10.     contact_groups             admins   
  11.     notification_options         w,u,c,r   
  12.     notification_interval       960   
  13.     notification_period         24x7   
  14.     check_command             check_ping!100.0,20%!500.0,60%   
  15.     }   
  16.  
  17. define service{   
  18.     use                   generic-service       ; Name of service template to use   
  19.     host_name               test_nrpe   
  20.     service_description         apache   
  21.     is_volatile               0   
  22.     check_period             24x7   
  23.     max_check_attempts         1   
  24.     normal_check_interval       1   
  25.     retry_check_interval         1   
  26.     contact_groups             admins   
  27.     notification_options         w,u,c,r   
  28.     notification_interval       960   
  29.     notification_period         24x7   
  30.     check_command             check_http!100.0,20%!500.0,60%   
  31.     }   
  32.  
  33. define service{   
  34.     use                   generic-service       ; Name of service template to use   
  35.     host_name               test_nrpe   
  36.     service_description         mysql   
  37.     is_volatile               0   
  38.     check_period             24x7   
  39.     max_check_attempts         1   
  40.     normal_check_interval       1   
  41.     retry_check_interval         1   
  42.     contact_groups             admins   
  43.     notification_options         w,u,c,r   
  44.     notification_interval       960   
  45.     notification_period         24x7   
  46.     check_command             check_mysql!100.0,20%!500.0,60%   
  47.     }   
  48.  
  49. define service{   
  50.     use                   generic-service       ; Name of service template to use   
  51.     host_name               test_nrpe   
  52.     service_description         ntp    
  53.     is_volatile               0   
  54.     check_period             24x7   
  55.     max_check_attempts         1   
  56.     normal_check_interval       1   
  57.     retry_check_interval         1   
  58.     contact_groups             admins   
  59.     notification_options         w,u,c,r   
  60.     notification_interval       960   
  61.     notification_period         24x7   
  62.     check_command             check_ntp!100.0,20%!500.0,60%   
  63.     }   
  64.  
  65. define service{   
  66.     use                   generic-service       ; Name of service template to use   
  67.     host_name               test_nrpe   
  68.     service_description         qmail_smtp      
  69.     is_volatile               0   
  70.     check_period             24x7   
  71.     max_check_attempts         1   
  72.     normal_check_interval       1   
  73.     retry_check_interval         1   
  74.     contact_groups             admins   
  75.     notification_options         w,u,c,r   
  76.     notification_interval       960   
  77.     notification_period         24x7   
  78.     check_command             check_smtp!100.0,20%!500.0,60%    
  79.     }   
  80.  
  81. define service{   
  82.     use                   generic-service       ; Name of service template to use   
  83.     host_name               test_nrpe   
  84.     service_description         qmail_pop3      
  85.     is_volatile               0   
  86.     check_period             24x7   
  87.     max_check_attempts         1   
  88.     normal_check_interval       1   
  89.     retry_check_interval         1   
  90.     contact_groups             admins   
  91.     notification_options         w,u,c,r   
  92.     notification_interval       960   
  93.     notification_period         24x7   
  94.     check_command             check_pop!100.0,20%!500.0,60%    
  95.     } 

nagios配置中,服務(wù)就定義完了。此時(shí)是不是多了一個(gè)主機(jī)和它下面的服務(wù)呢?那是肯定的。如果這個(gè)過程中出現(xiàn)添加主機(jī)和服務(wù)可能出現(xiàn)的問題該怎么解決?請(qǐng)閱讀:概念篇、安裝篇故障解決篇

 

責(zé)任編輯:佚名 來源: ChinaUnix
相關(guān)推薦

2011-08-22 11:00:10

nagios

2011-08-22 11:00:14

nagios

2011-08-22 10:30:29

nagios

2011-03-22 15:17:14

Nagios安裝

2011-03-22 15:17:13

Nagios監(jiān)控

2011-03-22 15:17:14

Nagios安裝

2011-07-14 14:17:33

網(wǎng)絡(luò)服務(wù)器配置DNS服務(wù)器

2011-07-14 14:45:01

網(wǎng)絡(luò)服務(wù)器配置DHCP服務(wù)器

2011-07-14 15:28:11

服務(wù)器

2014-06-26 14:10:44

2011-03-21 11:21:04

LinuxNagios

2010-03-24 11:39:01

2011-07-14 14:58:19

網(wǎng)絡(luò)服務(wù)器配置服務(wù)器

2011-02-22 11:23:48

vsFTPDLinux服務(wù)器

2011-02-22 11:23:48

vsFTPDLinux服務(wù)器

2011-09-05 09:23:50

2011-07-14 14:01:29

網(wǎng)絡(luò)服務(wù)器配置服務(wù)器

2011-07-14 13:13:44

網(wǎng)絡(luò)服務(wù)器配置

2011-08-01 11:10:21

2011-03-22 13:50:53

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)