Nagios伺服器端安裝部署詳解(1)

mchdba發表於2014-05-12


下載地址如下: 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/,可以開啟了,如下所示:





來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26230597/viewspace-1159459/,如需轉載,請註明出處,否則將追究法律責任。

相關文章