成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

用Nagios來監控網絡服務器-nagios配置

運維 系統運維
什么是nagios?如何用Nagios來監控網絡服務器?nagios怎樣安裝?nagios怎樣配置?Nagios是一個用來監控主機、服務和網絡的開放源碼軟件,很多大的公司或組織都在使用它。本文講述的是用Nagios來監控網絡服務器,nagios配置

  現在開始配置:

  1:配置web接口

  假設你已經運行了apache,如果沒有,請參考:apache的安裝

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

  添加如下內容:

  1.   ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin  
  2.  
  3.     
  4.  
  5.   Options Execcgi  
  6.  
  7.   AllowOverride None  
  8.  
  9.   Order allow,deny  
  10.  
  11.   Allow from all  
  12.  
  13.   AuthName "Nagios Access"  
  14.  
  15.   AuthType Basic  
  16.  
  17.   AuthUserFile /usr/local/nagios/etc/htpasswd.users  
  18.  
  19.   Require valid-user  
  20.  
  21.     
  22.  
  23.   Alias /nagios /usr/local/nagios/share  
  24.  
  25.     
  26.  
  27.   Options None  
  28.  
  29.   AllowOverride None  
  30.  
  31.   Order allow,deny  
  32.  
  33.   Allow from all  
  34.  
  35.   AuthName "Nagios Access"  
  36.  
  37.   AuthType Basic  
  38.  
  39.   AuthUserFile /usr/local/nagios/etc/htpasswd.users  
  40.  
  41.   Require valid-user  
  42.  

  

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

  1.   /usr/local/apahce2/bin/apachectl restart  
  2.  

  2:配置apache的BASIC認證:

  生成認證密碼:

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

  apache接口配置完成。

#p#

  開始配置nagios:

  1.   cd /usr/local/nagios/etc/  
  2.  

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

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

  全部拷貝完成即可.

  1.   vi minimal.cfg  
  2.  

  注釋所有command:

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

  修改cgi.cfg

  修改use_authentication=1為use_authentication=0,即不用驗證.不然有一些頁面不會顯示。

  現在檢查配置文件是否有語法錯誤:

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

  如果正確,會顯示以下結果:

  1.   Total Warnings: 0  
  2.  
  3.   Total Errors: 0  
  4.  

  否則,需要根據提示進行修改配置文件。

  配置文件等會再弄。現在啟動nagios

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

  為了使nagios異常中斷,我們使用daemontools啟動:

#p#

  安裝daemontool:

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

  檢查svscan進程是否啟動:

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

  ok,啟動正常了。

  1.   cd /service  
  2.  
  3.   mkdir nagios  
  4.  
  5.   chmod 1755 nagios  
  6.  
  7.   touch ./run  
  8.  
  9.   chmod 755 ./run  
  10.  
  11.   vi run  
  12.  
  13.   PATH=/usr/local/bin:/usr/bin:/bin  
  14.  
  15.   export PATH  
  16.  
  17.   exec env - PATH=$PATH \  
  18.  
  19.   /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg  
  20.  
  21.   mkdir log  
  22.  
  23.   cd log  
  24.  
  25.   touch ./run  
  26.  
  27.   chmod 755 ./run  
  28.  
  29.   vi ./run  
  30.  
  31.   #!/bin/sh  
  32.  
  33.   exec setuidgid logadmin multilog t s1000000 n100 ./main  
  34.  
  35.   mkdir main  
  36.  
  37.   chmod 777 main  
  38.  
  39.   chown nagios.nagios main  
  40.  
  41.   touch status  
  42.  
  43.   chown nagios.nagios status  
  44.  
  45.   svc -u /service/nagios/  
  46.  
  47.   svstat /service/nagios/  
  48.  
  49.   root@## ps auxww | grep nagios  
  50.  
  51.   root 23276 0.0 0.1 1176 488 ?? I 5:00PM 0:01.71 supervise nagios  
  52.  
  53.   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  
  54.  
  55.   root@##  
  56.  

  ok,現在把nagios服務做成自動啟動的服務了。

  通過svc命令可以啟動或者停止服務。

  ---------------------------------------------------------------------------------

  1.   svc opts services  
  2.  
  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.  
  7.   -d: Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.  
  8.  
  9.   -o: Once. If the service is not running, start it. Do not restart it if it stops.  
  10.  
  11.   -p: Pause. Send the service a STOP signal.  
  12.  
  13.   -c: Continue. Send the service a CONT signal.  
  14.  
  15.   -h: Hangup. Send the service a HUP signal.  
  16.  
  17.   -a: Alarm. Send the service an ALRM signal.  
  18.  
  19.   -i: Interrupt. Send the service an INT signal.  
  20.  
  21.   -t: Terminate. Send the service a TERM signal.  
  22.  
  23.   -k: Kill. Send the service a KILL signal.  
  24.  
  25.   -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.  
  26.  

  ---------------------------------------------------------------------------------

  比如:

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

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

  啟動nagios--svc -u /service/nagios/

  當然,你也可以使用inited的方式進行:

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

  好了,反正daemontools很強大,以后慢慢熟悉,轉入正題。

  現在打開網頁:http://localhost/nagios/

  一定會讓你大吃一驚,呵呵,我的服務器和服務狀態都清楚的看到了。

  現在我們的nagios中只有一個,那就是它自己,localhost,呵呵,等會我們添加別的主機和主機服務,ok,我們認識一下nagios的廬山真面目:

#p#

  配置nagios:

  1)為主機添加服務

  2)添加主機并添加服務

  3)停止一個服務

  4)刪除一臺主機和服務

  5)查看所有主機的故障

  6)查看一臺特定的主機狀態

  7)改變報警的時間間隔

  8)改變發現故障的重試次數

  9)如何在nagios中使用外部命令

  1)為主機添加一個服務

  為localhost主機添加qmail服務的監控,方法如下:

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

  可以直接拷貝原有的進行修改,我這個就是拷貝的原有的check_local_disk進行的。

  修改host_name,service_description,check_command等

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

  照貓畫虎的進行修改,然后去修改:

  1.   vi checkcommands.cfg  
  2.  
  3.   #'check_qmail' command definition  
  4.  
  5.   define command{  
  6.  
  7.   command_name check_qmail  
  8.  
  9.   command_line $USER1$/check_smtp -H 127.0.0.1  
  10.  
  11.   }  
  12.  
  13.   define command{  
  14.  
  15.   command_name check_pop3  
  16.  
  17.   command_line $USER1$/check_pop -H 127.0.0.1  
  18.  
  19.   }  
  20.  

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

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

  如果沒有錯誤會顯示:

  1.   Total Warnings: 0  
  2.  
  3.   Total Errors: 0  
  4.  

  如果有錯誤,請根據提示進行錯誤的修正。

  重啟nagios

  1.   svc -d /service/nagios/ && svc -u /service/nagios/  
  2.  

  通過web頁面檢查nagios的結果:

  http://10.5.1.153/nagios/

  點擊“Service Detail”

  會出現:

  2)添加主機并添加服務

  我們會監控這臺主機的負載、磁盤等一些沒有通過端口方式啟動的服務器狀態,以及它的服務,比如:apache、mysql、qmail和ntp等等吧。那么沒有端口的nagios直接能監控到嗎?答案是不行。所以我們必須在兩臺主機上安裝nrpe,nrpe可以啟動5666端口,把檢測的信息源源不斷的傳給監控中心的主機。

  ok,我們把apache、mysql、qmail和ntp先加上,這回我們把監控的主機和服務新建一個文件:

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

  定義一個主機:

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

  定義主機需要檢查的服務:

  1.   define service{  
  2.  
  3.   use generic-service ; Name of service template to use  
  4.  
  5.   host_name test_nrpe  
  6.  
  7.   service_description PING  
  8.  
  9.   is_volatile 0  
  10.  
  11.   check_period 24x7  
  12.  
  13.   max_check_attempts 1  
  14.  
  15.   normal_check_interval 1  
  16.  
  17.   retry_check_interval 1  
  18.  
  19.   contact_groups admins  
  20.  
  21.   notification_options w,u,c,r  
  22.  
  23.   notification_interval 960  
  24.  
  25.   notification_period 24x7  
  26.  
  27.   check_command check_ping!100.0,20%!500.0,60%  
  28.  
  29.   }  
  30.  
  31.   define service{  
  32.  
  33.   use generic-service ; Name of service template to use  
  34.  
  35.   host_name test_nrpe  
  36.  
  37.   service_description apache  
  38.  
  39.   is_volatile 0  
  40.  
  41.   check_period 24x7  
  42.  
  43.   max_check_attempts 1  
  44.  
  45.   normal_check_interval 1  
  46.  
  47.   retry_check_interval 1  
  48.  
  49.   contact_groups admins  
  50.  
  51.   notification_options w,u,c,r  
  52.  
  53.   notification_interval 960  
  54.  
  55.   notification_period 24x7  
  56.  
  57.   check_command check_http!100.0,20%!500.0,60%  
  58.  
  59.   }  
  60.  
  61.   define service{  
  62.  
  63.   use generic-service ; Name of service template to use  
  64.  
  65.   host_name test_nrpe  
  66.  
  67.   service_description mysql  
  68.  
  69.   is_volatile 0  
  70.  
  71.   check_period 24x7  
  72.  
  73.   max_check_attempts 1  
  74.  
  75.   normal_check_interval 1  
  76.  
  77.   retry_check_interval 1  
  78.  
  79.   contact_groups admins  
  80.  
  81.   notification_options w,u,c,r  
  82.  
  83.   notification_interval 960  
  84.  
  85.   notification_period 24x7  
  86.  
  87.   check_command check_mysql!100.0,20%!500.0,60%  
  88.  
  89.   }  
  90.  
  91.   define service{  
  92.  
  93.   use generic-service ; Name of service template to use  
  94.  
  95.   host_name test_nrpe  
  96.  
  97.   service_description ntp  
  98.  
  99.   is_volatile 0  
  100.  
  101.   check_period 24x7  
  102.  
  103.   max_check_attempts 1  
  104.  
  105.   normal_check_interval 1  
  106.  
  107.   retry_check_interval 1  
  108.  
  109.   contact_groups admins  
  110.  
  111.   notification_options w,u,c,r  
  112.  
  113.   notification_interval 960  
  114.  
  115.   notification_period 24x7  
  116.  
  117.   check_command check_ntp!100.0,20%!500.0,60%  
  118.  
  119.   }  
  120.  
  121.   define service{  
  122.  
  123.   use generic-service ; Name of service template to use  
  124.  
  125.   host_name test_nrpe  
  126.  
  127.   service_description qmail_smtp  
  128.  
  129.   is_volatile 0  
  130.  
  131.   check_period 24x7  
  132.  
  133.   max_check_attempts 1  
  134.  
  135.   normal_check_interval 1  
  136.  
  137.   retry_check_interval 1  
  138.  
  139.   contact_groups admins  
  140.  
  141.   notification_options w,u,c,r  
  142.  
  143.   notification_interval 960  
  144.  
  145.   notification_period 24x7  
  146.  
  147.   check_command check_smtp!100.0,20%!500.0,60%  
  148.  
  149.   }  
  150.  
  151.   define service{  
  152.  
  153.   use generic-service ; Name of service template to use  
  154.  
  155.   host_name test_nrpe  
  156.  
  157.   service_description qmail_pop3  
  158.  
  159.   is_volatile 0  
  160.  
  161.   check_period 24x7  
  162.  
  163.   max_check_attempts 1  
  164.  
  165.   normal_check_interval 1  
  166.  
  167.   retry_check_interval 1  
  168.  
  169.   contact_groups admins  
  170.  
  171.   notification_options w,u,c,r  
  172.  
  173.   notification_interval 960  
  174.  
  175.   notification_period 24x7  
  176.  
  177.   check_command check_pop!100.0,20%!500.0,60%  
  178.  
  179.   }  
  180.  

  現在我們象上次一樣把服務也定義完了。

【編輯推薦】

使用Nagios的建議技巧

使用Nagios實現網絡監控

Cents下Nagios的安裝-Apache服務的安裝

責任編輯:zhaolei 來源: hackervip
相關推薦

2011-03-22 15:17:13

Nagios監控

2011-03-22 15:17:14

Nagios安裝

2011-08-22 11:00:17

nagios

2011-08-22 11:00:14

nagios

2011-08-22 11:00:10

nagios

2011-08-22 10:30:29

nagios

2011-03-21 11:21:04

LinuxNagios

2011-03-25 14:40:33

Nagios監控

2011-03-22 09:03:47

Nagios配置

2011-03-23 15:13:08

Nagios監控Oracle

2014-06-26 14:10:44

2011-07-14 14:45:01

網絡服務器配置DHCP服務器

2011-07-14 15:28:11

服務器

2011-07-14 14:17:33

網絡服務器配置DNS服務器

2011-03-23 10:17:26

2011-07-14 14:58:19

網絡服務器配置服務器

2010-03-24 11:39:01

2011-03-21 14:53:27

Nagios監控Linux

2011-04-06 14:24:21

Nagios監控Linux

2011-07-14 13:13:44

網絡服務器配置
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 亚洲人精品| 国产成人免费视频 | 91精品国产麻豆 | 中文在线一区二区 | 欧美13videosex性极品 | 天天爽一爽 | 日韩精品在线免费 | 福利一区在线观看 | 国产精品国色综合久久 | 精品国产乱码久久久久久1区2区 | 欧美天堂在线观看 | 久久毛片 | 久久婷婷色 | 久久久久网站 | 中文字幕91av| 精品一区二区三区在线观看 | 久久手机在线视频 | 国产成人精品一区二区三 | 国产精品a久久久久 | 国产精品视频一区二区三区 | 精品国产18久久久久久二百 | 久久乐国产精品 | 亚洲免费精品 | 99国产精品久久久久老师 | 日韩综合在线 | 久草福利 | 成人在线国产 | 久久精品这里 | 日本高清精品 | 天天干免费视频 | 在线毛片网 | 麻豆精品国产91久久久久久 | 国产精品久久久久久久久久久久久 | 婷婷色成人 | 一区二区日韩 | 一区二区三区日韩精品 | 日日操天天射 | 午夜影视在线观看 | 欧美最猛黑人xxxⅹ 粉嫩一区二区三区四区公司1 | 精品成人在线视频 | 中文字幕亚洲一区 |