Nagios服务器端安装部署详解(1)


下载地址如下: http://sourceforge.net/projects/nagios/files/

具体详细下载地址:http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.6.tar.gz

1 开始下载:
 wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.6/nagios-4.0.6.tar.gz/download?use_mirror=jaist
如下图所示,下载free版本的。


安装前准备工作,安装一些lib包

[root@cache-2 root]# yum -y install httpd gcc glibc glibc-common

# yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel


2 进行selinux设置,或者关闭selinux

 查看SELinux状态:

 (1)/usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态

         SELinux status:                 enabled

 (2)getenforce                 ##也可以用这个命令检查

 关闭SELinux

 (3)临时关闭(不用重启机器):

         setenforce 0                  ##设置SELinux 成为permissive模式

                              ##setenforce 1 设置SELinux 成为enforcing模式

 (4)修改配置文件需要重启机器:

         修改/etc/selinux/config 文件

         SELINUX=enforcing改为SELINUX=disabled

         重启机器即可


3 开始准备nagios安装环境

  (1) 添加nagios运行所需要的用户和组:

  groupadd nagcmd

         useradd -m nagios

         usermod -a -G nagcmd nagios

        

apache加入到nagcmd组,以便于在通过web Interface操作nagios时能够具有足够的权限:

# usermod -a -G nagcmd apache


4 编译安装准备

./configure --with-command-group=nagios --prefix=/opt/app/nagios --enable-embedded-perl --with-httpd-conf=/usr/local/apache2/conf

点击(此处)折叠或打开

  1. 2 tar -xvf nagios-4.0.6.tar.gz
  2. cd /root/nagios-4.0.6
  3. [root@cache-2 nagios-4.0.6]# ./configure --with-command-group=nagios --prefix=/opt/app/nagios --enable-embedded-perl --with-httpd-conf=/usr/local/apache2/conf
  4. checking for a BSD-compatible install... /usr/bin/install -c
  5. checking build system type... x86_64-unknown-linux-gnu
  6. checking host system type... x86_64-unknown-linux-gnu
  7. checking for gcc... gcc
  8. checking for C compiler default output file name... a.out
  9. checking whether the C compiler works... yes
  10. checking whether we are cross compiling... no
  11. checking for suffix of executables...
  12. checking for suffix of object files... o
  13. checking whether we are using the GNU C compiler... yes
  14. checking whether gcc accepts -g... yes
  15. checking for gcc option to accept ISO C89... none needed
  16. checking whether make sets $(MAKE)... yes
  17. checking for strip... /usr/bin/strip
  18. checking how to run the C preprocessor... gcc -E
  19. checking for grep that handles long lines and -e... /bin/grep
  20. checking for egrep... /bin/grep -E
  21. checking for ANSI C header files... yes
  22. checking whether time.h and sys/time.h may both be included... yes
  23. checking for sys/wait.h that is POSIX.1 compatible... yes
  24. checking for sys/types.h... yes
  25. checking for sys/stat.h... yes
  26. checking for stdlib.h... yes
  27. checking for string.h... yes
  28. checking for memory.h... yes
  29. checking for strings.h... yes
  30. checking for inttypes.h... yes
  31. checking for stdint.h... yes
  32. checking for unistd.h... yes
  33. checking arpa/inet.h usability... yes
  34. checking arpa/inet.h presence... yes
  35. checking for arpa/inet.h... yes
  36. checking ctype.h usability... yes
  37. checking ctype.h presence... yes
  38. checking for ctype.h... yes
  39. checking dirent.h usability... yes
  40. checking dirent.h presence... yes
  41. checking for dirent.h... yes
  42. checking errno.h usability... yes
  43. checking errno.h presence... yes
  44. checking for errno.h... yes
  45. checking fcntl.h usability... yes
  46. checking fcntl.h presence... yes
  47. checking for fcntl.h... yes
  48. checking getopt.h usability... yes
  49. checking getopt.h presence... yes
  50. checking for getopt.h... yes
  51. checking grp.h usability... yes
  52. checking grp.h presence... yes
  53. checking for grp.h... yes
  54. checking libgen.h usability... yes
  55. checking libgen.h presence... yes
  56. checking for libgen.h... yes
  57. checking limits.h usability... yes
  58. checking limits.h presence... yes
  59. checking for limits.h... yes
  60. checking math.h usability... yes
  61. checking math.h presence... yes
  62. checking for math.h... yes
  63. checking netdb.h usability... yes
  64. checking netdb.h presence... yes
  65. checking for netdb.h... yes
  66. checking netinet/in.h usability... yes
  67. checking netinet/in.h presence... yes
  68. checking for netinet/in.h... yes
  69. checking pwd.h usability... yes
  70. checking pwd.h presence... yes
  71. checking for pwd.h... yes
  72. checking regex.h usability... yes
  73. checking regex.h presence... yes
  74. checking for regex.h... yes
  75. checking signal.h usability... yes
  76. checking signal.h presence... yes
  77. checking for signal.h... yes
  78. checking socket.h usability... no
  79. checking socket.h presence... no
  80. checking for socket.h... no
  81. checking stdarg.h usability... yes
  82. checking stdarg.h presence... yes
  83. checking for stdarg.h... yes
  84. checking for string.h... (cached) yes
  85. checking for strings.h... (cached) yes
  86. checking sys/mman.h usability... yes
  87. checking sys/mman.h presence... yes
  88. checking for sys/mman.h... yes
  89. checking for sys/types.h... (cached) yes
  90. checking sys/time.h usability... yes
  91. checking sys/time.h presence... yes
  92. checking for sys/time.h... yes
  93. checking sys/resource.h usability... yes
  94. checking sys/resource.h presence... yes
  95. checking for sys/resource.h... yes
  96. checking for sys/wait.h... (cached) yes
  97. checking sys/socket.h usability... yes
  98. checking sys/socket.h presence... yes
  99. checking for sys/socket.h... yes
  100. checking for sys/stat.h... (cached) yes
  101. checking sys/timeb.h usability... yes
  102. checking sys/timeb.h presence... yes
  103. checking for sys/timeb.h... yes
  104. checking sys/un.h usability... yes
  105. checking sys/un.h presence... yes
  106. checking for sys/un.h... yes
  107. checking sys/ipc.h usability... yes
  108. checking sys/ipc.h presence... yes
  109. checking for sys/ipc.h... yes
  110. checking sys/msg.h usability... yes
  111. checking sys/msg.h presence... yes
  112. checking for sys/msg.h... yes
  113. checking sys/poll.h usability... yes
  114. checking sys/poll.h presence... yes
  115. checking for sys/poll.h... yes
  116. checking syslog.h usability... yes
  117. checking syslog.h presence... yes
  118. checking for syslog.h... yes
  119. checking uio.h usability... no
  120. checking uio.h presence... no
  121. checking for uio.h... no
  122. checking for unistd.h... (cached) yes
  123. checking locale.h usability... yes
  124. checking locale.h presence... yes
  125. checking for locale.h... yes
  126. checking wchar.h usability... yes
  127. checking wchar.h presence... yes
  128. checking for wchar.h... yes
  129. checking for an ANSI C-conforming const... yes
  130. checking whether struct tm is in sys/time.h or time.h... time.h
  131. checking for struct tm.tm_zone... yes
  132. checking for mode_t... yes
  133. checking for pid_t... yes
  134. checking for size_t... yes
  135. checking return type of signal handlers... void
  136. checking for uid_t in sys/types.h... yes
  137. checking type of array argument to getgroups... gid_t
  138. checking for va_copy... yes
  139. checking for vsnprintf... yes
  140. checking for snprintf... yes
  141. checking for asprintf... yes
  142. checking for vasprintf... yes
  143. checking for C99 vsnprintf... yes
  144. checking for library containing getservbyname... none required
  145. checking for library containing connect... none required
  146. checking for initgroups... yes
  147. checking for setenv... yes
  148. checking for strdup... yes
  149. checking for strstr... yes
  150. checking for strtoul... yes
  151. checking for unsetenv... yes
  152. checking for type of socket size... size_t
  153. checking for library containing nanosleep... none required
  154. checking for mail... /bin/mail
  155. checking for glibc at least version 2.4... yes
  156. checking sys/epoll.h usability... yes
  157. checking sys/epoll.h presence... yes
  158. checking for sys/epoll.h... yes
  159. checking sys/select.h usability... yes
  160. checking sys/select.h presence... yes
  161. checking for sys/select.h... yes
  162. checking for main in -liconv... no
  163. checking for gdImagePng in -lgd (order 1)... no
  164. checking for gdImagePng in -lgd (order 2)... no
  165. checking for gdImagePng in -lgd (order 3)... no
  166. checking for gdImagePng in -lgd (order 4)... no
  167.  
  168.  
  169. *** GD, PNG, and/or JPEG libraries could not be located... *********
  170.  
  171. Boutell\



5 开始make安装
5.1 make all
[root@cache-2 nagios-4.0.6]#  make all

点击(此处)折叠或打开

  1. [root@cache-2 nagios-4.0.6]# make all
  2. cd ./base && make
  3. make[1]: Entering directory `/root/nagios-4.0.6/base\'
  4. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nagios.o nagios.c
  5. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o broker.o broker.c
  6. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nebmods.o nebmods.c
  7. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o ../common/shared.o ../common/shared.c
  8. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nerd.o nerd.c
  9. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o query-handler.o query-handler.c
  10. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o workers.o workers.c
  11. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o checks.o checks.c
  12. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o config.o config.c
  13. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o commands.o commands.c
  14. commands.c: 在函数‘process_passive_service_check’中:
  15. commands.c:2247: 警告:赋值丢弃了指针目标类型的限定
  16. commands.c: 在函数‘process_passive_host_check’中:
  17. commands.c:2339: 警告:赋值丢弃了指针目标类型的限定
  18. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o events.o events.c
  19. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o flapping.o flapping.c
  20. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o logging.o logging.c
  21. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o macros-base.o ../common/macros.c
  22. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o netutils.o netutils.c
  23. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o notifications.o notifications.c
  24. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o sehandlers.o sehandlers.c
  25. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o utils.o utils.c
  26. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o retention-base.o sretention.c
  27. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xretention-base.o ../xdata/xrddefault.c
  28. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o comments-base.o ../common/comments.c
  29. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xcomments-base.o ../xdata/xcddefault.c
  30. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o objects-base.o ../common/objects.c
  31. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xobjects-base.o ../xdata/xodtemplate.c
  32. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o statusdata-base.o ../common/statusdata.c
  33. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xstatusdata-base.o ../xdata/xsddefault.c
  34. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o perfdata-base.o perfdata.c
  35. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xperfdata-base.o ../xdata/xpddefault.c
  36. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o downtime-base.o ../common/downtime.c
  37. make -C ../lib
  38. make[2]: Entering directory `/root/nagios-4.0.6/lib\'
  39. gcc -g -O2 -DHAVE_CONFIG_H -c squeue.c -o squeue.o
  40. gcc -g -O2 -DHAVE_CONFIG_H -c kvvec.c -o kvvec.o
  41. gcc -g -O2 -DHAVE_CONFIG_H -c iocache.c -o iocache.o
  42. gcc -g -O2 -DHAVE_CONFIG_H -c iobroker.c -o iobroker.o
  43. gcc -g -O2 -DHAVE_CONFIG_H -c bitmap.c -o bitmap.o
  44. gcc -g -O2 -DHAVE_CONFIG_H -c dkhash.c -o dkhash.o
  45. gcc -g -O2 -DHAVE_CONFIG_H -c runcmd.c -o runcmd.o
  46. gcc -g -O2 -DHAVE_CONFIG_H -c nsutils.c -o nsutils.o
  47. gcc -g -O2 -DHAVE_CONFIG_H -c fanout.c -o fanout.o
  48. gcc -g -O2 -DHAVE_CONFIG_H -c pqueue.c -o pqueue.o
  49. gcc -g -O2 -DHAVE_CONFIG_H -c worker.c -o worker.o
  50. gcc -g -O2 -DHAVE_CONFIG_H -c skiplist.c -o skiplist.o
  51. gcc -g -O2 -DHAVE_CONFIG_H -c nsock.c -o nsock.o
  52. gcc -g -O2 -DHAVE_CONFIG_H -c nspath.c -o nspath.o
  53. ar cr libnagios.a squeue.o kvvec.o iocache.o iobroker.o bitmap.o dkhash.o runcmd.o nsutils.o fanout.o pqueue.o worker.o skiplist.o nsock.o nspath.o
  54. make[2]: Leaving directory `/root/nagios-4.0.6/lib\'
  55. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -o nagios nagios.o broker.o nebmods.o ../common/shared.o nerd.o query-handler.o workers.o checks.o config.o commands.o events.o flapping.o logging.o macros-base.o netutils.o notifications.o sehandlers.o utils.o retention-base.o xretention-base.o comments-base.o xcomments-base.o objects-base.o xobjects-base.o statusdata-base.o xstatusdata-base.o perfdata-base.o xperfdata-base.o downtime-base.o -Wl,-export-dynamic -lm -ldl ../lib/libnagios.a
  56. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -o nagiostats nagiostats.c -lm ../lib/libnagios.a
  57. make[1]: Leaving directory `/root/nagios-4.0.6/base\'
  58. cd ./cgi && make
  59. make[1]: Entering directory `/root/nagios-4.0.6/cgi\'
  60. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o getcgi.o getcgi.c
  61. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o cgiutils.o cgiutils.c
  62. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o cgiauth.o cgiauth.c
  63. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o macros-cgi.o ../common/macros.c
  64. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o objects-cgi.o ../common/objects.c
  65. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o xobjects-cgi.o ../xdata/xodtemplate.c
  66. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o statusdata-cgi.o ../common/statusdata.c
  67. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o xstatusdata-cgi.o ../xdata/xsddefault.c
  68. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o comments-cgi.o ../common/comments.c
  69. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o downtime-cgi.o ../common/downtime.c
  70. ../common/downtime.c:194: 警告:‘downtime_remove’定义后未使用
  71. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -DJSON_NAGIOS_4X -c -o archiveutils.o archiveutils.c
  72. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -DJSON_NAGIOS_4X -c -o jsonutils.o jsonutils.c
  73. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -DJSON_NAGIOS_4X -o archivejson.cgi archivejson.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a archiveutils.o jsonutils.o
  74. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o avail.cgi avail.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  75. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o extcmd_list.o extcmd_list.c
  76. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o cmd.cgi cmd.c extcmd_list.o ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  77. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o config.cgi config.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  78. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o extinfo.cgi extinfo.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  79. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o history.cgi history.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  80. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o notifications.cgi notifications.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  81. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -DJSON_NAGIOS_4X -o objectjson.cgi objectjson.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a jsonutils.o
  82. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o outages.cgi outages.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  83. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o showlog.cgi showlog.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  84. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o status.cgi status.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  85. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -DJSON_NAGIOS_4X -o statusjson.cgi statusjson.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a jsonutils.o
  86. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o statuswml.cgi statuswml.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  87. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o summary.cgi summary.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  88. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o tac.cgi tac.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a
  89. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o statuswrl.cgi statuswrl.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a -lm
  90. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o statusmap.cgi statusmap.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a -lgd -lpng -ljpeg -lz -lm
  91. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o trends.cgi trends.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a -lgd -lpng -ljpeg -lz -lm
  92. gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -o histogram.cgi histogram.c ../common/shared.o getcgi.o cgiutils.o cgiauth.o macros-cgi.o objects-cgi.o xobjects-cgi.o statusdata-cgi.o xstatusdata-cgi.o comments-cgi.o downtime-cgi.o ../lib/libnagios.a -lgd -lpng -ljpeg -lz -lm
  93. make[1]: Leaving directory `/root/nagios-4.0.6/cgi\'
  94. cd ./html && make
  95. make[1]: Entering directory `/root/nagios-4.0.6/html\'
  96. make[1]: Nothing to be done for `all\'.
  97. make[1]: Leaving directory `/root/nagios-4.0.6/html\'
  98. if [ xyes = xyes ]; then \\
  99.         cd ./module && make; \\
  100.     fi
  101. make[1]: Entering directory `/root/nagios-4.0.6/module\'
  102. gcc -I.. -fPIC -g -O2 -DHAVE_CONFIG_H -o helloworld.o helloworld.c -shared
  103. make[1]: Leaving directory `/root/nagios-4.0.6/module\'
  104. cd ./worker && make all
  105. make[1]: Entering directory `/root/nagios-4.0.6/worker\'
  106. cd ./ping && make all
  107. make[2]: Entering directory `/root/nagios-4.0.6/worker/ping\'
  108. gcc -I.. -I ../../include -I ../.. -g -O2 -DHAVE_CONFIG_H -o worker-ping worker-ping.c -L ../../lib -l nagios
  109. make[2]: Leaving directory `/root/nagios-4.0.6/worker/ping\'
  110. make[1]: Leaving directory `/root/nagios-4.0.6/worker\'

  111. *** Compile finished ***

  112. If the main program and CGIs compiled without any errors, you
  113. can continue with installing Nagios as follows (type \'make\'
  114. without any arguments for a list of all possible options):

  115.   make install
  116.      - This installs the main program, CGIs, and HTML files

  117.   make install-init
  118.      - This installs the init script in /etc/rc.d/init.d

  119.   make install-commandmode
  120.      - This installs and configures permissions on the
  121.        directory for holding the external command file

  122.   make install-config
  123.      - This installs *SAMPLE* config files in /usr/local/nagios/etc
  124.        You\'ll have to modify these sample files before you can
  125.        use Nagios. Read the HTML documentation for more info
  126.        on doing this. Pay particular attention to the docs on
  127.        object configuration files, as they determine what/how
  128.        things get

  129.   make install-webconf
  130.      - This installs the Apache config file for the Nagios
  131.        web interface

  132.   make install-exfoliation
  133.      - This installs the Exfoliation theme for the Nagios
  134.        web interface

  135.   make install-classicui
  136.      - This installs the classic theme for the Nagios
  137.        web interface


  138. *** Support Notes *******************************************

  139. If you have questions about configuring or running Nagios,
  140. please make sure that you:

  141.      - Look at the sample config files
  142.      - Read the documentation on the Nagios Library at:
  143.            http://library.nagios.com

  144. before you post a question to one of the mailing lists.
  145. Also make sure to include pertinent information that could
  146. help others help you. This might include:

  147.      - What version of Nagios you are using
  148.      - What version of the plugins you are using
  149.      - Relevant snippets from your config files
  150.      - Relevant error messages from the Nagios log file

  151. For more information on obtaining support for Nagios, visit:

  152.        http://support.nagios.com

  153. *************************************************************

  154. Enjoy.

5.2 make install

[root@cache-2 nagios-4.0.6]# make install

点击(此处)折叠或打开

  1. [root@cache-2 nagios-4.0.6]# make install
  2. cd ./base && make install
  3. make[1]: Entering directory `/root/nagios-4.0.6/base\'
  4. make install-basic
  5. make[2]: Entering directory `/root/nagios-4.0.6/base\'
  6. /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
  7. /usr/bin/install -c -m 774 -o nagios -g nagios nagios /usr/local/nagios/bin
  8. /usr/bin/install -c -m 774 -o nagios -g nagios nagiostats /usr/local/nagios/bin
  9. make[2]: Leaving directory `/root/nagios-4.0.6/base\'
  10. make strip-post-install
  11. make[2]: Entering directory `/root/nagios-4.0.6/base\'
  12. /usr/bin/strip /usr/local/nagios/bin/nagios
  13. /usr/bin/strip /usr/local/nagios/bin/nagiostats
  14. make[2]: Leaving directory `/root/nagios-4.0.6/base\'
  15. make[1]: Leaving directory `/root/nagios-4.0.6/base\'
  16. cd ./cgi && make install
  17. make[1]: Entering directory `/root/nagios-4.0.6/cgi\'
  18. make install-basic
  19. make[2]: Entering directory `/root/nagios-4.0.6/cgi\'
  20. /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/sbin
  21. for file in *.cgi; do \\
  22.         /usr/bin/install -c -m 775 -o nagios -g nagios $file /usr/local/nagios/sbin; \\
  23.     done
  24. make[2]: Leaving directory `/root/nagios-4.0.6/cgi\'
  25. make strip-post-install
  26. make[2]: Entering directory `/root/nagios-4.0.6/cgi\'
  27. for file in *.cgi; do \\
  28.         /usr/bin/strip /usr/local/nagios/sbin/$file; \\
  29.     done
  30. [root@cache-2 nagios-4.0.6]# make install-config
  31. /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
  32. /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
  33. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
  34. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
  35. /usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
  36. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
  37. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
  38. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
  39. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
  40. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
  41. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
  42. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
  43. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg

  44. *** Config files installed ***

  45. Remember, these are *SAMPLE* config files. You\

5.3 make install-config

点击(此处)折叠或打开

  1. [root@cache-2 nagios-4.0.6]# make install-config
  2. /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
  3. /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
  4. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
  5. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
  6. /usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
  7. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
  8. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
  9. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
  10. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
  11. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
  12. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
  13. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
  14. /usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg

  15. *** Config files installed ***

5.4 make install-commandmode


点击(此处)折叠或打开

  1. [root@cache-2 nagios-4.0.6]# make install-commandmode
  2. /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw
  3. chmod g+s /usr/local/nagios/var/rw
  4.  
  5. *** External command directory configured ***
  6.  
  7. Remember, these are *SAMPLE* config files. You\


5.5 make install-init


点击(此处)折叠或打开

  1. [root@cache-2 nagios-4.0.6]# make install-init
  2. /usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
  3. /usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
  4. *** Init script installed ***


[root@cache-2 nagios-4.0.6]#

加到启动项里面去:

# chkconfig --add nagios

# chkconfig --level 35 nagios on

# chkconfig --list nagios


检查主机配置文件是否正确:

/var/www/nagios/bin/nagios -v /var/www/nagios/etc/nagios.cfg


5.6 Check安装是否正确:

5.6.1说明:

切换目录到安装路径(这里是/usr/local/nagios),看是否存在etcbinsbinsharevar 这五个目录,如果存在则可以表明程序被正确的安装到系统了。Nagios 各个目录用途说明如下:

bin    Nagios 可执行程序所在目录

etc   Nagios 配置文件所在目录

sbin  Nagios CGI 文件所在目录,也就是执行外部命令所需文件所在的目录

share        Nagios网页文件所在的目录

libexec      Nagios 外部插件所在目录

var   Nagios 日志文件、lock 等文件所在的目录

var/archives     Nagios 日志自动归档目录

var/rw      用来存放外部命令文件的目录


5.6.2 check
 cd /usr/local/nagios
ll

点击(此处)折叠或打开

  1. [root@cache-2 nagios-4.0.6]# cd /usr/local/nagios
  2. [root@cache-2 nagios]# ll
  3. 总用量 24
  4. drwxrwxr-x. 2 nagios nagios 4096 5月 5 15:31 bin
  5. drwxrwxr-x. 3 nagios nagios 4096 5月 5 15:32 etc
  6. drwxrwxr-x. 2 nagios nagios 4096 5月 5 15:31 libexec
  7. drwxrwxr-x. 2 nagios nagios 4096 5月 5 15:31 sbin
  8. drwxrwxr-x. 10 nagios nagios 4096 5月 5 15:31 share
  9. drwxrwxr-x. 5 nagios nagios 4096 5月 5 15:32 var


5.7 安装nagios插件
wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz

点击(此处)折叠或打开

  1. [root@cache-2 ~]# wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
  2. --2014-05-05 15:52:52-- http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
  3. 正在解析主机 nagios-plugins.org... 72.14.186.43
  4. 正在连接 nagios-plugins.org|72.14.186.43|:80... 已连接。
  5. 已发出 HTTP 请求,正在等待回应... 200 OK
  6. 长度:2501847 (2.4M) [application/x-gzip]
  7. 正在保存至: “nagios-plugins-2.0.tar.gz”

  8. 15% [======================> ] 390,650 116K/s eta(英国中部时19% [============================> ] 486,218 131K/s eta(英国中部时23% [==================================> ] 594,818 147K/s eta(英国中部时28% [=========================================> ] 715,002 163K/s eta(英国中部时34% [==================================================> ] 859,802 183K/s eta(英国中部时40% [============================================================> ] 1,020,530 203K/s eta(英国中部时48% [=======================================================================> ] 1,217,458 227K/s eta(英国中部时56% [====================================================================================> ] 1,421,626 250K/s eta(英国中部时66% [==================================================================================================> ] 1,666,338 277K/s eta(英国中部时77% [==================================================================================================================> ] 1,929,874 303K/s eta(英国中部时88% [====================================================================================================================================> ] 2,222,370 332K/s eta(英国中部时100%[=====================================================================================================================================================>] 2,501,847 373K/s in 6.5s

  9. 2014-05-05 15:53:00 (373 KB/s) - 已保存 “nagios-plugins-2.0.tar.gz” [2501847/2501847])
  10. [root@cache-2 ~]# tar -xvf nagios-plugins-2.0.tar.gz

    [root@cache-2 ~]# cd nagios-plugins-2.0

    [root@cache-2 ~]#./configure --with-nagios-user=nagios --with-nagios-group=nagios  --prefix=/usr/local/nagios --with-mysql

    [root@cache-2 ~]# make && make install



5.8 安装配置apache和php
(1)安装apache
下载 wget http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz

点击(此处)折叠或打开

  1. [root@cache-2 ~]# wget http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz
  2. --2014-05-05 16:15:48-- http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz
  3. 正在解析主机 archive.apache.org... 192.87.106.229, 140.211.11.131, 2001:610:1:80bc:192:87:106:229
  4. 正在连接 archive.apache.org|192.87.106.229|:80... 已连接。
  5. 已发出 HTTP 请求,正在等待回应... 200 OK
  6. 长度:6747087 (6.4M) [application/x-gzip]
  7. 正在保存至: “httpd-2.4.7.tar.gz”

  8.  1% [=> ] 117,271 33.5K/s eta(英国中部时 2% [==> ] 144,857 36.2K/s eta(英国中部时 2% [===> ] 194,163 43.0K/s eta(英国中部时 3% [====> ] 265,189 52.9K/s eta(英国中部时 5% [======> ] 343,455 62.3K/s eta(英国中部时 6% [========> ] 442,449 73.4K/s eta(英国中部时 8% [===========> ] 560,877 85.8K/s eta(英国中部时10% [===============> ] 730,441 104K/s eta(英国中部时14% [====================> ] 947,789 125K/s eta(英国中部时18% [==========================> ] 1,230,297 152K/s eta(英国中部时23% [==================================> ] 1,602,729 185K/s eta(英国中部时30% [=============================================> ] 2,083,761 228K/s eta(英国中部时40% [===========================================================> ] 2,706,697 280K/s eta(英国中部时52% [=============================================================================> ] 3,512,081 346K/s eta(英国中部时67% [===================================================================================================> ] 4,537,561 445K/s eta(英国中部时87% [=================================================================================================================================> ] 5,872,913 575K/s eta(英国中部时96% [===============================================================================================================================================> ] 6,514,833 633K/s eta(英国中部时100%[=====================================================================================================================================================>] 6,747,087 655K/s in 11s

  9. 2014-05-05 16:16:01 (574 KB/s) - 已保存 “httpd-2.4.7.tar.gz” [6747087/6747087])

开始安装:
 tar -xvf httpd-2.4.7.tar.gz
 cd httpd-2.4.7
 ./configure --prefix=/usr/local/apache2
make && make install

点击(此处)折叠或打开

  1. [root@cache-2 ~]# tar -xvf httpd-2.4.7.tar.gz
  2. [root@cache-2 ~]# cd httpd-2.4.7
  3. [root@cache-2 httpd-2.4.7]# ./configure --prefix=/usr/local/apache2
  4. checking for chosen layout... Apache
  5. checking for working mkdir -p... yes
  6. checking for grep that handles long lines and -e... /bin/grep
  7. checking for egrep... /bin/grep -E
  8. checking build system type... x86_64-unknown-linux-gnu
  9. checking host system type... x86_64-unknown-linux-gnu
  10. checking target system type... x86_64-unknown-linux-gnu
  11. configure:
  12. configure: Configuring Apache Portable Runtime library...
  13. configure:
  14. checking for APR... no
  15. configure: error: APR not found. Please read the documentation.
  16. Google之后,发现可能是gcc版本太低了,可能是apache版本太高,换低点的2.2.23版本吧。
  17. wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz
  18. tar -xvf httpd-2.2.23.tar.gz
  19. cd httpd-2.2.23
  20. ./configure --prefix=/usr/local/apache2
  21. make && make install



(2) 安装php版本

wget http://cn2.php.net/distributions/php-5.4.26.tar.gz

tar -xvf php-5.4.26.tar.gz

cd php-5.4.26

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs

有报错信息:

Configuring extensions

checking size of long... (cached) 8

checking size of int... (cached) 4

checking for int32_t... yes

checking for uint32_t... yes

checking for sys/types.h... (cached) yes

checking for inttypes.h... (cached) yes

checking for stdint.h... (cached) yes

checking for string.h... (cached) yes

checking for stdlib.h... (cached) yes

checking for strtoll... yes

checking for atoll... yes

checking for strftime... (cached) yes

checking which regex library to use... php

checking whether to enable LIBXML support... yes

checking libxml2 install dir... no

checking for xml2-config path...

configure: error: xml2-config not found. Please check your libxml2 installation.

 

需要重新安装lib

yum install libxml2 –y

yum install libxml2-devel –y

 

之后继续make,成功了:

Make && make install

[activating module `php5' in /usr/local/apache2/conf/httpd.conf]

Installing PHP CLI binary:        /usr/local/php/bin/

Installing PHP CLI man page:      /usr/local/php/php/man/man1/

Installing PHP CGI binary:        /usr/local/php/bin/

Installing PHP CGI man page:      /usr/local/php/php/man/man1/

Installing build environment:     /usr/local/php/lib/php/build/

Installing header files:          /usr/local/php/include/php/

Installing helper programs:       /usr/local/php/bin/

  program: phpize

  program: php-config

Installing man pages:             /usr/local/php/php/man/man1/

  page: phpize.1

  page: php-config.1

Installing PEAR environment:      /usr/local/php/lib/php/

[PEAR] Archive_Tar    - installed: 1.3.11

[PEAR] Console_Getopt - installed: 1.3.1

warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.4)

warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)

[PEAR] PEAR           - installed: 1.9.4

Wrote PEAR system config file at: /usr/local/php/etc/pear.conf

You may want to add: /usr/local/php/lib/php to your php.ini include_path

[PEAR] Structures_Graph- installed: 1.0.4

[PEAR] XML_Util       - installed: 1.2.1

/root/php/php-5.4.26/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin

ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar

Installing PDO headers:          /usr/local/php/include/php/ext/pdo/


(3) 配置apache

Apache的配置文件在 /usr/local/apache2/conf/httpd.conf ,vim打开

User daemon

Group daemon

修改成:

User nagios

Group nagios

 

  DirectoryIndex index.html

修改成:

  DirectoryIndex index.html index.php

    AddType application/x-httpd-php .php

 

为了安全起见:nagiosweb监控页面需要经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:

#setting for nagios

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

     AuthType Basic

     Options ExecCGI

     AllowOverride None

     Order allow,deny

     Allow from all

     AuthName "Nagios Access"

     AuthUserFile /usr/local/nagios/etc/htpasswd  //用于此目录访问身份验证的文件             

     Require valid-user

Alias /nagios "/usr/local/nagios/share"

     AuthType Basic

     Options None

     AllowOverride None

     Order allow,deny

     Allow from all

     AuthName "nagios Access"

     AuthUserFile /usr/local/nagios/etc/htpasswd

     Require valid-user


(4) 创建apache目录验证文件

在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:

/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david

[root@cache-2 php-5.4.26]#  /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david

New password:

Re-type new password:

Adding password for user david

查看认证文件的内容:

[root@cache-2 php-5.4.26]#  cat /usr/local/nagios/etc/htpasswd

david:$apr1$Pf9XIJjd$m5hR2vw70MlqwrChgN7zc/

[root@cache-2 php-5.4.26]#

 

启动apache服务:

/usr/local/apache2/bin/apachectl start


[root@cache-2 php-5.4.26]# /usr/local/apache2/bin/apachectl start

httpd: Could not reliably determine the server's fully qualified domain name, using 10.254.3.41 for ServerName

(98)Address already in use: make_sock: could not bind to address [::]:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

no listening sockets available, shutting down

Unable to open logs

修改ServerName以及Port

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

ServerName 改成 10.xx.3.x1

Listen 80 改成 Listen 81

http://10.xx.3.x1:81/nagios/,可以打开了,如下所示:





请使用浏览器的分享功能分享到微信等