联系客服:400-805-1963

centos6 64bit nagios的安装
更新:HHH   时间:2023-1-7


参照netseek的pdf,centos6 64bit

  1. nagios 安装步骤 
  2. 1在做安装之前确认要对该机器拥有root 权限。 
  3. 确认你安装好的linux 系统上已经安装如下软件包再继续。 
  4. Apache 
  5. GCC 编译器 
  6. GD库与开发库 
  7. yum -y install httpd gcc glibc glibc-common gd gd-devel 
  8.   
  9. 2  
  10. 建立nagios 账号 
  11. /usr/sbin/useradd nagios  && passwd nagios  
  12. 创建一个用户组名为nagcmd用于从Web 接口执行外部命令 
  13. 用户都加到这个组中 
  14. /usr/sbin/groupadd  nagcmd 
  15. /usr/sbin/usermod ‐ G nagcmd nagios 
  16. /usr/sbin/usermod ‐ G nagcmd apache 
  17.  
  18. 3 
  19. 下载nagios 和插件程序包 
  20. 下载Nagios 和Nagios 插件的软件包( 访问http://www.nagios.org/download/站点以获得最 
  21. 新版本) 
  22. cd  /usr/local/src  
  23. wget  http://nchc.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz 
  24. wget  http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz  
  25.  
  26. 4 
  27. 编译与安装nagios  
  28. cd  /usr/local/src  
  29. tar zxvf  nagios-3.0.6.tar.gz 
  30. cd  nagios-3.0.6 
  31. ./configure --with-command-group=nagcmd  --prefix=/usr/local/nagios  
  32. make all  
  33. make install  
  34. make install-init  
  35. make install-config  
  36. make install-commandmode  
  37.  
  38. 验证程序是否被正确安装。切换目录到安装路径(这里是/usr/local/nagios),看是否存在  
  39. etc、bin、 sbin、 share、 var 这五个目录,如果存在则可以表明程序被正确的安装到系 
  40. 统了。后表是五个目录功能的简要说明:  
  41.  
  42. 5 
  43. 编译并安装nagios 插件 nagios-plugins  
  44. cd  /usr/local/src  
  45. tar zxvf  nagios-plugins-1.4.13.tar.gz  
  46. cd  nagios-plugins-1.4.13  
  47. ./configure --with-nagios-user=nagios --with-nagios-group=nagios  --prefix=/usr/local/nagios  
  48.  
  49. make && make install  
  50.  验证: 
  51. ls  /usr/local/nagios/libexec 
  52. 会显示安装的插件文件,即所有的插件都安装在 libexec 这个目录下 
  53.  
  54. 6配置WEB 接口 
  55. 方法一:直接在安装nagios 时 make install ‐ webconf 
  56. 创建一个nagiosadmin的用户用于Nagios 的WEB 接口登录。记下你所设置的登录口 
  57. 令,一会儿你会用到它。 
  58. htpasswd ‐ c /usr/local/nagios/etc/htpasswd.users nagiosadmin 
  59. 重启Apache服务以使设置生效。 
  60. service  httpdrestart  
  61. 方法二:在httpd.conf最后添加如下内容: 
  62. #for nagios 
  63. ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin  
  64. <Directory "/usr/local/nagios/sbin">  
  65.     Options ExecCGI  
  66.     AllowOverride None  
  67.     Order allow,deny  
  68.     Allow from all  
  69.     AuthName "Nagios Access"  
  70.     AuthType Basic  
  71.     AuthUserFile /usr/local/nagios/etc/htpasswd  
  72.     Require valid-user  
  73. </Directory>  
  74.   
  75. Alias /nagios /usr/local/nagios/share 
  76.  
  77. <Directory "/usr/local/nagios/share">  
  78.     Options None  
  79.     AllowOverride None  
  80.     Order allow,deny  
  81.     Allow from all  
  82.     AuthName "Nagios Access"  
  83.     AuthType Basic  
  84.     AuthUserFile /usr/local/nagios/etc/htpasswd  
  85.     Require valid-user  
  86. </Directory>  
  87.  
  88. htpasswd ‐ c /usr/local/nagios/etc/htpasswd  test  
  89. New  password: (输入123456)  
  90. Re‐ type  new  password: (再输入一次密码) 
  91. Adding  password  for user  test  
  92. 查看认证文件的内容 
  93. less  /usr/local/nagios/etc/htpasswd  
  94. test:OmWGEsBnoGpIc 前半部分是用户名test, 后面是加密后的密码 
  95.  
  96. 本例添加的是 test  用户名,需要改 cgi.cfg  配置文件,允许test 用户 
  97. vi /usr/local/nagios/etc/cgi.cfg 
  98.     authorized_for_system_information=test   
  99.     authorized_for_configuration_information=test 
  100.     authorized_for_system_commands=test   
  101.     authorized_for_all_services=test  
  102.     authorized_for_all_hosts=nagiosadmin,test   
  103.     authorized_for_all_ service_commands=test   
  104.     authorized_for_all_host_commands=test   
  105.  
  106. 7 
  107. 启动nagios  
  108. 把Nagios 加入到服务列表中以使之在系统启动时自动启动 
  109. chkconfig ‐‐ add  nagios  
  110. chkconfig  nagios  on 
  111. 验证Nagios 的样例配置文件 
  112. /usr/local/nagios/bin/nagios ‐ v /usr/local/nagios/etc/nagios.cfg  
  113. 有可能 
  114. Nagios 3.0.6 
  115. Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org) 
  116. Last Modified: 12-01-2008 
  117. License: GPL 
  118. Error: Cannot open main configuration file '/usr/local/‐' for reading! 然后赋予权限也不行 直接重启nagios服务 启动即可 
  119. Nagios 3.0.6 starting... (PID=2821) 
  120. Local time is Thu Feb 16 14:24:25 CST 2012 
  121. Bailing out due to one or more errors encountered in the configuration files. Run Nagios from the command line with the -v option to verify your config before restarting. (PID=2821) 
  122.  
  123. 如果没有报错,可以启动Nagios 服务 
  124. service  nagios  start  
  125. service  httpd   start 
  126. 8 setenforce 0(执行这个命令就可了) 
  127.  
  128. 令SELinux处于容许模式 
  129. setenforce 0  
  130. 如果要永久性更变它,需要更改/etc/selinux/config 里的设置并重启系统。 
  131. 不关闭SELinux或是永久性变更它的方法是让 CGI 模块在SELinux下指定强制目标模式: 
  132. chcon‐ R‐ t httpd_sys_content_t /usr/local/nagios/sbin/ 
  133. chcon‐ R‐ t httpd_sys_content_t /usr/local/nagios/share/  
  134.  
  135. 9 
  136. 测试 
  137. 登录 http://localhost/nagios/  输入用户名test和密码123456就可以正常登录了 
  138.  
  139. 十 如何配置监控远程主机 
  140. 1 在被监控主机上 
  141. 增加用户 
  142. useradd nagios 
  143. 设置密码 
  144. passwd nagios 
  145. 安装nagios插件 
  146. wget  http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz 
  147. tar zxvf nagios-plugins-1.4.13.tar.gz  
  148. cd nagios-plugins-1.4.13 
  149. ./configure  
  150. make 
  151. make install 
  152. chown nagios.nagios /usr/local/nagios/ 
  153. chown  -R  nagios.nagios /usr/local/nagios/libexec/ 
  154.  
  155.  
  156. 2 nagios 安装nrpe的时候步骤(监控与被监控都要安装) 
  157. tar -zxvf  nrpe-2.8.1.tar.gz  
  158. cd  nrpe-2.8.1 
  159. ./configure  
  160. make all  
  161. make install-plugin 
  162. make install-daemon 
  163. make install-daemon-config 
  164.  
  165. 3 vim /usr/local/nagios/etc/nrpe.cfg 
  166. #allowed_hosts=127.0.0.1 
  167. allowed_hosts=127.0.0.1,192.168.1.130(192.168.1.130监控端的地址) 
  168.  
  169. 改/etc/hosts.allow增加监控机ip 
  170.  
  171. echo 'nrpe:192.168.1.130' >> /etc/hosts.allow  
  172. 4启动服务 
  173. /usr/local/nagios/bin/nrpe -c  /usr/local/nagios/etc/nrpe.cfg -d 
  174. 测试nrpe服务是否正常 
  175. /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1(用127.0.0.1测试 不要用localhost测试) 
  176. NRPE v2.8.1 
  177.  
  178. 5在监控端(192.168.1.130)测试 看到如下结果说明成功 
  179. /etc/init.d/iptables stop(或者添加允许从被监控端收集信息) 
  180. /usr/local/nagios/libexec/check_nrpe -H 192.168.1.129 
  181. NRPE v2.8.1 
  182.  
  183.  
  184. 然后在监控端 
  185. 1 vim /usr/local/nagios/etc/objects/129.cfg  内容如下 
  186. define host{ 
  187.  
  188. use            linux-server 
  189.  
  190. host_name    129 
  191.  
  192. alias        129 
  193.  
  194. address      192.168.1.129 
  195.  
  196. } 
  197.  
  198. define service{ 
  199.  
  200. use generic-service 
  201.  
  202. host_name 129 
  203.  
  204. service_description load 
  205.  
  206. check_command check_nrpe!check_load 
  207. #使用自定参数 
  208. #check_command check_nrpe!check_load!6.0,5.0,4.0!15.0,8.0,6.0 
  209. } 
  210.  
  211. vim /usr/local/nagios/etc/nagios.cfg 添加如下内容 
  212. # Definitions for monitoring 192.168.1.129 
  213. cfg_file=/usr/local/nagios/etc/objects/129.cfg       
  214.  
  215.  
  216. vim /usr/local/nagios/etc/objects/commands.cfg 
  217. # 'check_nrpe ' command definition 
  218. define command{ 
  219.  
  220. command_name check_nrpe 
  221.  
  222. command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ 
  223.  
  224. } 
  225.  
  226. 监控机nagios重启 
  227. service nagios reload 
  228. 输入http://192.168.1.130/nagios 就可看到129已经添加成功 
  229.  
  230.  
  231.  
  232. nagios监控swap 
  233. 在被监控机的/usr/local/nagios/etc/nrpe.cfg 
  234. vim /usr/local/nagios/etc/nrpe.cfg添加 
  235. command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10% 
  236. nrpe服务重启 
  237. [root@localhost libexec]# ps -ef | grep nrpe                  
  238. nagios    2332     1  0 14:24 ?        00:00:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 
  239. root      2373 28887  0 14:25 pts/0    00:00:00 grep nrpe 
  240. kill -9 2332 
  241. /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 
  242.  
  243. 监控端 
  244. /usr/local/nagios/etc/objects/commands.cfg添加 
  245. # check_swap command definition 
  246. define command{ 
  247.         command_name    check_swap 
  248.         command_line    $USER1$/check_swap -w $ARG1$ -c $ARG2$ 
  249.         } 
  250.  
  251.  
  252.  
  253. 在下面的文件中 
  254. vim /usr/local/nagios/etc/objects/129.cfg添加  
  255. define service{ 
  256. use generic-service 
  257. host_name 129 
  258. service_description swap 
  259. check_command check_nrpe!check_swap 
  260. } 
  261.  
  262.  
  263. 重启nagios服务和http服务               
  264. service nagios restart 
  265. service httpd restart              
  266.  
  267. nagios监控磁盘 
  268.  
  269. 在被监控机的/usr/local/nagios/etc/nrpe.cfg 
  270. vim /usr/local/nagios/etc/nrpe.cfg添加 
  271. command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p / 
  272. nrpe服务重启 
  273. [root@localhost libexec]# ps -ef | grep nrpe                  
  274. nagios    2332     1  0 14:24 ?        00:00:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 
  275. root      2373 28887  0 14:25 pts/0    00:00:00 grep nrpe 
  276. kill -9 2332 
  277. /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 
  278.  
  279. 监控端 
  280. /usr/local/nagios/etc/objects/commands.cfg添加 
  281. define command{ 
  282.         command_name    check_disk 
  283.         command_line    $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ 
  284.         } 
  285.  
  286.  
  287.  
  288.  
  289. 在下面的文件中 
  290. vim /usr/local/nagios/etc/objects/129.cfg添加  
  291.  
  292. define service{ 
  293. use generic-service 
  294. host_name 129 
  295. service_description disk 
  296. check_command check_nrpe!check_disk 
  297. } 
  298.  
  299. 重启nagios服务和http服务               
  300. service nagios restart 
  301. service httpd restart              
  302.  
  303. nagios监控内存 
  304. 监控内存脚本如下 
  305. ###################################### 
  306. #!/bin/bash 
  307. # check memory script  
  308.  
  309. TOTAL=`free -m | head -2 |tail -1 |gawk '{print $2}'` 
  310. USED=`free -m | head -2 |tail -1 |gawk '{print $3}'` 
  311. FREE=`free -m | head -2 |tail -1 |gawk '{print $4}'` 
  312. # to calculate free percent 
  313. # use the expression free * 100 / total 
  314. FREETMP=`expr $FREE \* 100` 
  315. PERCENT=`expr $FREETMP / $TOTAL` 
  316. echo "$TOTAL MB Total Memory" 
  317. echo "$USED MB Used Memory" 
  318. echo "$FREE MB ($PERCENT%) Free Memory" 
  319. exit 0 
  320. ###################################### 
  321.  
  322. 在被监控机的/usr/local/nagios/etc/nrpe.cfg 
  323. vim /usr/local/nagios/etc/nrpe.cfg添加 
  324. command[check_mem]=/usr/local/nagios/libexec/check_mem -w 150 -c 200 
  325. 把监控脚本check_mnem放到/usr/local/nagios/libexec/ 并赋予执行权限 
  326. chmod +x /usr/local/nagios/libexec/check_mem 
  327. chown nagios.nagios /usr/local/nagios/libexec/check_mem 
  328.  
  329. nrpe服务重启 
  330. [root@localhost libexec]# ps -ef | grep nrpe                  
  331. nagios    2332     1  0 14:24 ?        00:00:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 
  332. root      2373 28887  0 14:25 pts/0    00:00:00 grep nrpe 
  333. kill -9 2332 
  334. /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 
  335.  
  336. 监控端 
  337. /usr/local/nagios/etc/objects/commands.cfg添加 
  338. define command{ 
  339.        command_name    check_mem 
  340.         command_line    $USER1$/check_mem -w $ARG1$ -c $ARG2$ 
  341.         } 
  342.  
  343.  
  344.  
  345.  
  346. 在下面的文件中 
  347. vim /usr/local/nagios/etc/objects/129.cfg添加  
  348.  
  349. define service{ 
  350.  
  351. use generic-service 
  352.  
  353. host_name 129 
  354.  
  355. service_description memory 
  356.  
  357. check_command check_nrpe!check_mem 
  358. } 
  359.  
  360. 重启nagios服务和http服务               
  361. service nagios restart 
  362. service httpd restart        
  363.  
  364.        
  365.  
  366. nagios监控http存活状态 
  367. 被监控机不需要任何操作(因为check_http不需要通过nrpe来监控) 
  368.  
  369.  
  370. 监控端 
  371. /usr/local/nagios/etc/objects/commands.cfg已经存在check_http命令 故也不需要操作 
  372.  
  373.  
  374.  
  375.  
  376. 在下面的文件中 
  377. vim /usr/local/nagios/etc/objects/129.cfg添加  
  378.  
  379. define service{ 
  380.  
  381. use generic-service 
  382.  
  383. host_name 129 
  384.  
  385. service_description http 
  386.  
  387. check_command check_http(这一行要注意 不是check_nrpe!check_http这种形式) 
  388. } 
  389.  
  390. 重启nagios服务和http服务               
  391. service nagios restart 
  392. service httpd restart              
  393.  
  394.  
  395. 错误解决方法 因为http是采用yum安装的 网站文件路径默认是/var/www/html 
  396. 执行下面命令检测时 
  397. /usr/local/nagios/libexec/check_http -I 192.168.1.129 
  398. 报错如下 
  399. HTTP WARNING: HTTP/1.1 403 Forbidden 
  400. 原因这是因为/var/www/html 下面没有文件所致 
  401. cd /var/www/html 
  402. echo 123 >index.html 
  403. 然后过一会 nagios检测就ok了 
  404.  
  405. nagios监控mysql存活状态 
  406. 被监控机登录数据库授权 
  407.  
  408. mysql> grant all privileges on *.* to xxxxx@192.168.1.130 identified by '123456'; 
  409. Query OK, 0 rows affected (0.09 sec) 
  410.  
  411. mysql> flush privileges; 
  412. Query OK, 0 rows affected (0.08 sec) 
  413.  
  414. 监控端 
  415. /usr/local/nagios/etc/objects/commands.cfg添加如下内容 
  416.  
  417. # check_mysql command definition 
  418. define command{ 
  419.         command_name    check_mysql 
  420.         command_line    $USER1$/check_mysql -H $HOSTADDRESS$  -P $ARG1$ - 
  421. u $ARG2$  -p $ARG3$  (liuyu那个pdf有问题) 
  422.         } 
  423.  
  424.  
  425.  
  426. 在下面的文件中 
  427. vim /usr/local/nagios/etc/objects/129.cfg添加  
  428.  
  429. define service{ 
  430.  
  431. use generic-service 
  432.  
  433. host_name 129 
  434.  
  435. service_description mysql 
  436.  
  437. check_command check_mysql!192.168.1.129!3306!xxxx!123456(这一行liuyu文档上是对的  这一行要注意 不是check_nrpe!check_http这种形式) 
  438.  
  439. notifications_enabled  0 
  440.  
  441.  
  442. } 
  443. 重启nagios服务和http服务               
  444. service nagios restart 
  445. service httpd restart              
  446.  
  447.  
  448. nagios监控tomcat存活状态 
  449. 被监控机不需要任何操作(因为check_tcp!8080不需要通过nrpe来监控) 
  450.  
  451.  
  452. 监控端 
  453. /usr/local/nagios/etc/objects/commands.cfg已经存在check_tcp命令 故也不需要操作 
  454.  
  455.  
  456.  
  457.  
  458. 在下面的文件中 
  459. vim /usr/local/nagios/etc/objects/hong221.cfg添加  
  460. define service{ 
  461.  
  462. use generic-service 
  463.  
  464. host_name hong221 
  465.  
  466. service_description tomcat 
  467.  
  468. check_command check_tcp!8080!xxxxx
  469.  
  470. } 
  471.  
  472. 收到检测 执行下面命令  
  473. [root@nagios objects]# /usr/local/nagios/libexec/check_tcp -H xxxxx -p 8080 
  474. TCP OK - 0.141 second response time on port 8080|time=0.141140s;;;0.000000;10.000000 
  475.  
  476. 重启nagios服务和http服务               
  477. service nagios restart 
  478. service httpd restart              
  479.  
  480. 然后在监控端就可以看到监控页面了 
  481.  
  482. nagios配置139邮箱报警 
  483. 关于mail发送邮件139邮箱收不到的解决办法 
  484. tail -f /var/log/maillog 日志报错如下 
  485. Feb 21 17:20:49 localhost postfix/qmgr[2072]: A296612227F: from=<root@localhost.localdomain>, size=700, nrcpt=1 (queue active) 
  486. Feb 21 17:20:49 localhost sendmail[2275]: q1L9KmDa002275: to=xxxxx@139.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:0 
  487. 0, mailer=relay, pri=30221, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as A296612227F) 
  488. Feb 21 17:20:49 localhost postfix/smtpd[2276]: disconnect from localhost.localdomain[127.0.0.1] 
  489. Feb 21 17:20:50 localhost postfix/smtp[2280]: A296612227F: to=<xxxxx@139.com>, relay=mx1.mail.139.com[221.176.9.178]:25, delay 
  490. =0.53, delays=0.05/0.01/0.24/0.23, dsn=5.0.0, status=bounced (host mx1.mail.139.com[221.176.9.178] said: 550 985a4f43618db72-3c5de Mail rejected (in reply to end of DATA command)) 
  491. Feb 21 17:20:50 localhost postfix/cleanup[2279]: 43FB812227E: message-id=<20120221092050.43FB812227E@localhost.localdomain> 
  492. Feb 21 17:20:50 localhost postfix/qmgr[2072]: 43FB812227E: from=<>, size=2697, nrcpt=1 (queue active) 
  493. Feb 21 17:20:50 localhost postfix/bounce[2281]: A296612227F: sender non-delivery notification: 43FB812227E 
  494. Feb 21 17:20:50 localhost postfix/qmgr[2072]: A296612227F: removed 
  495.  
  496. 经指点是由于hostname(localhost.localdomain)的问题 可能会被139邮箱当做垃圾邮件 
  497. [root@nagios objects]# cat /etc/sysconfig/network 
  498. NETWORKING=yes 
  499. #HOSTNAME=localhost.localdomain 
  500. HOSTNAME=nagios.localdomain 
  501.  
  502. [root@nagios objects]# cat /etc/hosts 
  503. 192.168.1.130   nagios.localdomain      nagios  # Added by NetworkManager 
  504. 127.0.0.1       localhost.localdomain   localhost 
  505. ::1     nagios.localdomain      nagios  localhost6.localdomain6 localhost6 
  506.  
  507. 故随便改了一个名字 然后重启服务器发现可以使用了 139邮箱也能收到邮件了 
  508.  
  509.  
  510.  
  511. 关于服务报警nagios方面的配置 
  512. 监控机上 
  513. vim /usr/local/nagios/etc/objects/contacts.cfg  
  514. define contact{ 
  515.         contact_name                    nagiosadmin             ; Short name of user 
  516.         use                             generic-contact         ; Inherit default values from generic-contact template (defined abov 
  517. e) 
  518.         alias                           Nagios Admin            ; Full name of user 
  519.         service_notification_period     24x7 
  520.         host_notification_period        24x7 
  521.         service_notification_options    w,u,c,r 
  522.         host_notification_options       d,u,r 
  523.         service_notification_commands   notify-service-by-email 
  524.         host_notification_commands      notify-host-by-email 
  525.         email                          xxxxx@139.com(写上你要发送到的邮箱里面 139邮箱运维必备)     ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** 
  526.         } 
  527.          
  528. define contactgroup{ 
  529.         contactgroup_name       admins 
  530.         alias                   Nagios Administrators 
  531.         members                 nagiosadmin 
  532.         } 
  533.          
  534. 然后重启nagios服务即可 
  535. service nagios restart 
  536. 注意在主机配置文件中 有下面语句的服务出了问题才会报警 
  537. notifications_enabled           1  (1是报警 0为不报警) 
  538.  
  539.  
  540.  
  541.  
  542. 注意申请139邮箱的时候短信要选长格式的  
  543. 邮件到达通知 要改成24小时的 
  544.  
  545.  
  546. vim templates.cfg 
  547. define service{ 
  548.         name                            generic-service         ; The 'name' of this service template 
  549.         active_checks_enabled           1                       ; Active service checks are enabled 
  550.         passive_checks_enabled          1                       ; Passive service checks are enabled/accepted 
  551.         parallelize_check               1                       ; Active service checks should be parallelized (disabling this can l 
  552. ead to major performance problems) 
  553.         obsess_over_service             1                       ; We should obsess over this service (if necessary) 
  554.         check_freshness                 0                       ; Default is to NOT check service 'freshness' 
  555.         notifications_enabled           1                       ; Service notifications are enabled 
  556.         event_handler_enabled           1                       ; Service event handler is enabled 
  557.         flap_detection_enabled          1                       ; Flap detection is enabled 
  558.         failure_prediction_enabled      1                       ; Failure prediction is enabled 
  559.         process_perf_data               1                       ; Process performance data 
  560.         retain_status_information       1                       ; Retain status information across program restarts 
  561.         retain_nonstatus_information    1                       ; Retain non-status information across program restarts 
  562.         is_volatile                     0                       ; The service is not volatile 
  563.         check_period                    24x7                    ; The service can be checked at any time of the day 
  564.         max_check_attempts              3                       ; Re-check the service up to 3 times in order to determine its final 
  565.  (hard) state 
  566.         normal_check_interval           10                      ; Check the service every 10 minutes under normal conditions 
  567.         retry_check_interval            2                       ; Re-check the service every two minutes until a hard state can be d 
  568. etermined 
  569.         contact_groups                  admins                  ; Notifications get sent out to everyone in the 'admins' group 
  570.         notification_options            w,u,c,r                 ; Send notifications about warning, unknown, critical, and recovery  
  571. events 
  572.         notification_interval           10  (这个就是间隔多少时间发一次报警信息)                    ; Re-notify about service problems every hour 
  573.         notification_period             24x7                    ; Notifications can be sent out at any time 
  574.          register                        0                      ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEM 
  575. PLATE! 
  576.         } 
  577.  
  578.  
  579.  
  580.          
  581. nagios相关错误解决方法 
  582.  
  583. 错误解决方法 
  584. 一  当新增加一台监控主机(举例为129的load)监控项 
  585. 点击Scheduling Queue--129load时 Status Information :这一项提示为CHECK_NRPE: Socket timeout after 10 seconds 
  586. 检查 
  587.  
  588. 1 首先在监控主机上 执行 
  589. /usr/local/nagios/libexec/check_nrpe -H 192.168.1.129  
  590. 看能不能得到NRPE的版本号 
  591. 然后查看iptables是否有相关限制 
  592.  
  593. 2 查看文件权限 
  594. cd /usr/local/nagios/etc/objects 
  595. [root@localhost objects]# ll 
  596. total 52 
  597. -rw-r--r-- 1 root   root     314 Feb 16 15:58 129.cfg 
  598. -rwxrwxrwx 1 nagios nagios  7856 Feb 16 16:06 commands.cfg 
  599. -rwxrwxrwx 1 nagios nagios  2166 Feb 16 13:58 contacts.cfg 
  600. -rwxrwxrwx 1 nagios nagios  5403 Feb 16 13:58 localhost.cfg 
  601. -rwxrwxrwx 1 nagios nagios  3124 Feb 16 13:58 printer.cfg 
  602. -rwxrwxrwx 1 nagios nagios  3293 Feb 16 13:58 switch.cfg 
  603. -rwxrwxrwx 1 nagios nagios 10812 Feb 16 13:58 templates.cfg 
  604. -rwxrwxrwx 1 nagios nagios  3209 Feb 16 13:58 timeperiods.cfg 
  605. -rwxrwxrwx 1 nagios nagios  4007 Feb 16 13:58 windows.cfg 
  606.  
  607. 看看新增加的这个监控主机文件权限是不是nagios用户可读可写 不可以的话参照其他文件修改如下 
  608. [root@localhost objects]# ll 
  609. total 52 
  610. -rwxrwxrwx 1 nagios nagios   314 Feb 16 15:58 129.cfg 
  611. -rwxrwxrwx 1 nagios nagios  7856 Feb 16 16:06 commands.cfg 
  612. -rwxrwxrwx 1 nagios nagios  2166 Feb 16 13:58 contacts.cfg 
  613. -rwxrwxrwx 1 nagios nagios  5403 Feb 16 13:58 localhost.cfg 
  614. -rwxrwxrwx 1 nagios nagios  3124 Feb 16 13:58 printer.cfg 
  615. -rwxrwxrwx 1 nagios nagios  3293 Feb 16 13:58 switch.cfg 
  616. -rwxrwxrwx 1 nagios nagios 10812 Feb 16 13:58 templates.cfg 
  617. -rwxrwxrwx 1 nagios nagios  3209 Feb 16 13:58 timeperiods.cfg 
  618. -rwxrwxrwx 1 nagios nagios  4007 Feb 16 13:58 windows.cfg 

 

返回移动开发教程...