centos6 64bit nagios的安装

发布时间:2020-06-20 11:48:05 作者:liveforlinux
来源:网络 阅读:1386

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

 

推荐阅读:
  1. CentOS6安装
  2. centos6安装yapi

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

职场 休闲 centos

上一篇:抽象类和模板模式

下一篇:C++重载&指针&引用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》