下载地址如下: 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
点击(此处)折叠或打开
-
2 tar -xvf nagios-4.0.6.tar.gz
-
cd /root/nagios-4.0.6
-
[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
-
checking for a BSD-compatible install... /usr/bin/install -c
-
checking build system type... x86_64-unknown-linux-gnu
-
checking host system type... x86_64-unknown-linux-gnu
-
checking for gcc... gcc
-
checking for C compiler default output file name... a.out
-
checking whether the C compiler works... yes
-
checking whether we are cross compiling... no
-
checking for suffix of executables...
-
checking for suffix of object files... o
-
checking whether we are using the GNU C compiler... yes
-
checking whether gcc accepts -g... yes
-
checking for gcc option to accept ISO C89... none needed
-
checking whether make sets $(MAKE)... yes
-
checking for strip... /usr/bin/strip
-
checking how to run the C preprocessor... gcc -E
-
checking for grep that handles long lines and -e... /bin/grep
-
checking for egrep... /bin/grep -E
-
checking for ANSI C header files... yes
-
checking whether time.h and sys/time.h may both be included... yes
-
checking for sys/wait.h that is POSIX.1 compatible... yes
-
checking for sys/types.h... yes
-
checking for sys/stat.h... yes
-
checking for stdlib.h... yes
-
checking for string.h... yes
-
checking for memory.h... yes
-
checking for strings.h... yes
-
checking for inttypes.h... yes
-
checking for stdint.h... yes
-
checking for unistd.h... yes
-
checking arpa/inet.h usability... yes
-
checking arpa/inet.h presence... yes
-
checking for arpa/inet.h... yes
-
checking ctype.h usability... yes
-
checking ctype.h presence... yes
-
checking for ctype.h... yes
-
checking dirent.h usability... yes
-
checking dirent.h presence... yes
-
checking for dirent.h... yes
-
checking errno.h usability... yes
-
checking errno.h presence... yes
-
checking for errno.h... yes
-
checking fcntl.h usability... yes
-
checking fcntl.h presence... yes
-
checking for fcntl.h... yes
-
checking getopt.h usability... yes
-
checking getopt.h presence... yes
-
checking for getopt.h... yes
-
checking grp.h usability... yes
-
checking grp.h presence... yes
-
checking for grp.h... yes
-
checking libgen.h usability... yes
-
checking libgen.h presence... yes
-
checking for libgen.h... yes
-
checking limits.h usability... yes
-
checking limits.h presence... yes
-
checking for limits.h... yes
-
checking math.h usability... yes
-
checking math.h presence... yes
-
checking for math.h... yes
-
checking netdb.h usability... yes
-
checking netdb.h presence... yes
-
checking for netdb.h... yes
-
checking netinet/in.h usability... yes
-
checking netinet/in.h presence... yes
-
checking for netinet/in.h... yes
-
checking pwd.h usability... yes
-
checking pwd.h presence... yes
-
checking for pwd.h... yes
-
checking regex.h usability... yes
-
checking regex.h presence... yes
-
checking for regex.h... yes
-
checking signal.h usability... yes
-
checking signal.h presence... yes
-
checking for signal.h... yes
-
checking socket.h usability... no
-
checking socket.h presence... no
-
checking for socket.h... no
-
checking stdarg.h usability... yes
-
checking stdarg.h presence... yes
-
checking for stdarg.h... yes
-
checking for string.h... (cached) yes
-
checking for strings.h... (cached) yes
-
checking sys/mman.h usability... yes
-
checking sys/mman.h presence... yes
-
checking for sys/mman.h... yes
-
checking for sys/types.h... (cached) yes
-
checking sys/time.h usability... yes
-
checking sys/time.h presence... yes
-
checking for sys/time.h... yes
-
checking sys/resource.h usability... yes
-
checking sys/resource.h presence... yes
-
checking for sys/resource.h... yes
-
checking for sys/wait.h... (cached) yes
-
checking sys/socket.h usability... yes
-
checking sys/socket.h presence... yes
-
checking for sys/socket.h... yes
-
checking for sys/stat.h... (cached) yes
-
checking sys/timeb.h usability... yes
-
checking sys/timeb.h presence... yes
-
checking for sys/timeb.h... yes
-
checking sys/un.h usability... yes
-
checking sys/un.h presence... yes
-
checking for sys/un.h... yes
-
checking sys/ipc.h usability... yes
-
checking sys/ipc.h presence... yes
-
checking for sys/ipc.h... yes
-
checking sys/msg.h usability... yes
-
checking sys/msg.h presence... yes
-
checking for sys/msg.h... yes
-
checking sys/poll.h usability... yes
-
checking sys/poll.h presence... yes
-
checking for sys/poll.h... yes
-
checking syslog.h usability... yes
-
checking syslog.h presence... yes
-
checking for syslog.h... yes
-
checking uio.h usability... no
-
checking uio.h presence... no
-
checking for uio.h... no
-
checking for unistd.h... (cached) yes
-
checking locale.h usability... yes
-
checking locale.h presence... yes
-
checking for locale.h... yes
-
checking wchar.h usability... yes
-
checking wchar.h presence... yes
-
checking for wchar.h... yes
-
checking for an ANSI C-conforming const... yes
-
checking whether struct tm is in sys/time.h or time.h... time.h
-
checking for struct tm.tm_zone... yes
-
checking for mode_t... yes
-
checking for pid_t... yes
-
checking for size_t... yes
-
checking return type of signal handlers... void
-
checking for uid_t in sys/types.h... yes
-
checking type of array argument to getgroups... gid_t
-
checking for va_copy... yes
-
checking for vsnprintf... yes
-
checking for snprintf... yes
-
checking for asprintf... yes
-
checking for vasprintf... yes
-
checking for C99 vsnprintf... yes
-
checking for library containing getservbyname... none required
-
checking for library containing connect... none required
-
checking for initgroups... yes
-
checking for setenv... yes
-
checking for strdup... yes
-
checking for strstr... yes
-
checking for strtoul... yes
-
checking for unsetenv... yes
-
checking for type of socket size... size_t
-
checking for library containing nanosleep... none required
-
checking for mail... /bin/mail
-
checking for glibc at least version 2.4... yes
-
checking sys/epoll.h usability... yes
-
checking sys/epoll.h presence... yes
-
checking for sys/epoll.h... yes
-
checking sys/select.h usability... yes
-
checking sys/select.h presence... yes
-
checking for sys/select.h... yes
-
checking for main in -liconv... no
-
checking for gdImagePng in -lgd (order 1)... no
-
checking for gdImagePng in -lgd (order 2)... no
-
checking for gdImagePng in -lgd (order 3)... no
-
checking for gdImagePng in -lgd (order 4)... no
-
-
-
*** GD, PNG, and/or JPEG libraries could not be located... *********
-
- Boutell\
5 开始make安装
5.1 make all
[root@cache-2 nagios-4.0.6]# make all
点击(此处)折叠或打开
-
[root@cache-2 nagios-4.0.6]# make all
-
cd ./base && make
-
make[1]: Entering directory `/root/nagios-4.0.6/base\'
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nagios.o nagios.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o broker.o broker.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nebmods.o nebmods.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o ../common/shared.o ../common/shared.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o nerd.o nerd.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o query-handler.o query-handler.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o workers.o workers.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o checks.o checks.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o config.o config.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o commands.o commands.c
-
commands.c: 在函数‘process_passive_service_check’中:
-
commands.c:2247: 警告:赋值丢弃了指针目标类型的限定
-
commands.c: 在函数‘process_passive_host_check’中:
-
commands.c:2339: 警告:赋值丢弃了指针目标类型的限定
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o events.o events.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o flapping.o flapping.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o logging.o logging.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o macros-base.o ../common/macros.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o netutils.o netutils.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o notifications.o notifications.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o sehandlers.o sehandlers.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o utils.o utils.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o retention-base.o sretention.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xretention-base.o ../xdata/xrddefault.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o comments-base.o ../common/comments.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xcomments-base.o ../xdata/xcddefault.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o objects-base.o ../common/objects.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xobjects-base.o ../xdata/xodtemplate.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o statusdata-base.o ../common/statusdata.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xstatusdata-base.o ../xdata/xsddefault.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o perfdata-base.o perfdata.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o xperfdata-base.o ../xdata/xpddefault.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -c -o downtime-base.o ../common/downtime.c
-
make -C ../lib
-
make[2]: Entering directory `/root/nagios-4.0.6/lib\'
-
gcc -g -O2 -DHAVE_CONFIG_H -c squeue.c -o squeue.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c kvvec.c -o kvvec.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c iocache.c -o iocache.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c iobroker.c -o iobroker.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c bitmap.c -o bitmap.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c dkhash.c -o dkhash.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c runcmd.c -o runcmd.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c nsutils.c -o nsutils.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c fanout.c -o fanout.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c pqueue.c -o pqueue.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c worker.c -o worker.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c skiplist.c -o skiplist.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c nsock.c -o nsock.o
-
gcc -g -O2 -DHAVE_CONFIG_H -c nspath.c -o nspath.o
-
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
-
make[2]: Leaving directory `/root/nagios-4.0.6/lib\'
-
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
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCORE -o nagiostats nagiostats.c -lm ../lib/libnagios.a
-
make[1]: Leaving directory `/root/nagios-4.0.6/base\'
-
cd ./cgi && make
-
make[1]: Entering directory `/root/nagios-4.0.6/cgi\'
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o getcgi.o getcgi.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o cgiutils.o cgiutils.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o cgiauth.o cgiauth.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o macros-cgi.o ../common/macros.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o objects-cgi.o ../common/objects.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o xobjects-cgi.o ../xdata/xodtemplate.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o statusdata-cgi.o ../common/statusdata.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o xstatusdata-cgi.o ../xdata/xsddefault.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o comments-cgi.o ../common/comments.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o downtime-cgi.o ../common/downtime.c
-
../common/downtime.c:194: 警告:‘downtime_remove’定义后未使用
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -DJSON_NAGIOS_4X -c -o archiveutils.o archiveutils.c
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -DJSON_NAGIOS_4X -c -o jsonutils.o jsonutils.c
-
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
-
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
-
gcc -Wall -I.. -g -O2 -DHAVE_CONFIG_H -DNSCGI -c -o extcmd_list.o extcmd_list.c
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
make[1]: Leaving directory `/root/nagios-4.0.6/cgi\'
-
cd ./html && make
-
make[1]: Entering directory `/root/nagios-4.0.6/html\'
-
make[1]: Nothing to be done for `all\'.
-
make[1]: Leaving directory `/root/nagios-4.0.6/html\'
-
if [ xyes = xyes ]; then \\
-
cd ./module && make; \\
-
fi
-
make[1]: Entering directory `/root/nagios-4.0.6/module\'
-
gcc -I.. -fPIC -g -O2 -DHAVE_CONFIG_H -o helloworld.o helloworld.c -shared
-
make[1]: Leaving directory `/root/nagios-4.0.6/module\'
-
cd ./worker && make all
-
make[1]: Entering directory `/root/nagios-4.0.6/worker\'
-
cd ./ping && make all
-
make[2]: Entering directory `/root/nagios-4.0.6/worker/ping\'
-
gcc -I.. -I ../../include -I ../.. -g -O2 -DHAVE_CONFIG_H -o worker-ping worker-ping.c -L ../../lib -l nagios
-
make[2]: Leaving directory `/root/nagios-4.0.6/worker/ping\'
-
make[1]: Leaving directory `/root/nagios-4.0.6/worker\'
-
-
*** Compile finished ***
-
-
If the main program and CGIs compiled without any errors, you
-
can continue with installing Nagios as follows (type \'make\'
-
without any arguments for a list of all possible options):
-
-
make install
-
- This installs the main program, CGIs, and HTML files
-
-
make install-init
-
- This installs the init script in /etc/rc.d/init.d
-
-
make install-commandmode
-
- This installs and configures permissions on the
-
directory for holding the external command file
-
-
make install-config
-
- This installs *SAMPLE* config files in /usr/local/nagios/etc
-
You\'ll have to modify these sample files before you can
-
use Nagios. Read the HTML documentation for more info
-
on doing this. Pay particular attention to the docs on
-
object configuration files, as they determine what/how
-
things get
-
-
make install-webconf
-
- This installs the Apache config file for the Nagios
-
web interface
-
-
make install-exfoliation
-
- This installs the Exfoliation theme for the Nagios
-
web interface
-
-
make install-classicui
-
- This installs the classic theme for the Nagios
-
web interface
-
-
-
*** Support Notes *******************************************
-
-
If you have questions about configuring or running Nagios,
-
please make sure that you:
-
-
- Look at the sample config files
-
- Read the documentation on the Nagios Library at:
-
http://library.nagios.com
-
-
before you post a question to one of the mailing lists.
-
Also make sure to include pertinent information that could
-
help others help you. This might include:
-
-
- What version of Nagios you are using
-
- What version of the plugins you are using
-
- Relevant snippets from your config files
-
- Relevant error messages from the Nagios log file
-
-
For more information on obtaining support for Nagios, visit:
-
-
http://support.nagios.com
-
-
*************************************************************
-
- Enjoy.
5.2 make install
[root@cache-2 nagios-4.0.6]# make install
点击(此处)折叠或打开
-
[root@cache-2 nagios-4.0.6]# make install
-
cd ./base && make install
-
make[1]: Entering directory `/root/nagios-4.0.6/base\'
-
make install-basic
-
make[2]: Entering directory `/root/nagios-4.0.6/base\'
-
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
-
/usr/bin/install -c -m 774 -o nagios -g nagios nagios /usr/local/nagios/bin
-
/usr/bin/install -c -m 774 -o nagios -g nagios nagiostats /usr/local/nagios/bin
-
make[2]: Leaving directory `/root/nagios-4.0.6/base\'
-
make strip-post-install
-
make[2]: Entering directory `/root/nagios-4.0.6/base\'
-
/usr/bin/strip /usr/local/nagios/bin/nagios
-
/usr/bin/strip /usr/local/nagios/bin/nagiostats
-
make[2]: Leaving directory `/root/nagios-4.0.6/base\'
-
make[1]: Leaving directory `/root/nagios-4.0.6/base\'
-
cd ./cgi && make install
-
make[1]: Entering directory `/root/nagios-4.0.6/cgi\'
-
make install-basic
-
make[2]: Entering directory `/root/nagios-4.0.6/cgi\'
-
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/sbin
-
for file in *.cgi; do \\
-
/usr/bin/install -c -m 775 -o nagios -g nagios $file /usr/local/nagios/sbin; \\
-
done
-
make[2]: Leaving directory `/root/nagios-4.0.6/cgi\'
-
make strip-post-install
-
make[2]: Entering directory `/root/nagios-4.0.6/cgi\'
-
for file in *.cgi; do \\
-
/usr/bin/strip /usr/local/nagios/sbin/$file; \\
-
done
-
[root@cache-2 nagios-4.0.6]# make install-config
-
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
-
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
-
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg
-
-
*** Config files installed ***
-
- Remember, these are *SAMPLE* config files. You\
5.3 make install-config
点击(此处)折叠或打开
-
[root@cache-2 nagios-4.0.6]# make install-config
-
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
-
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
-
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
-
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg
-
- *** Config files installed ***
5.4 make install-commandmode
点击(此处)折叠或打开
-
[root@cache-2 nagios-4.0.6]# make install-commandmode
-
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw
-
chmod g+s /usr/local/nagios/var/rw
-
-
*** External command directory configured ***
-
- Remember, these are *SAMPLE* config files. You\
5.5 make
install-init
点击(此处)折叠或打开
-
[root@cache-2 nagios-4.0.6]# make install-init
-
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
-
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
- *** 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),看是否存在etc、bin、sbin、share、var 这五个目录,如果存在则可以表明程序被正确的安装到系统了。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
点击(此处)折叠或打开
-
[root@cache-2 nagios-4.0.6]# cd /usr/local/nagios
-
[root@cache-2 nagios]# ll
-
总用量 24
-
drwxrwxr-x. 2 nagios nagios 4096 5月 5 15:31 bin
-
drwxrwxr-x. 3 nagios nagios 4096 5月 5 15:32 etc
-
drwxrwxr-x. 2 nagios nagios 4096 5月 5 15:31 libexec
-
drwxrwxr-x. 2 nagios nagios 4096 5月 5 15:31 sbin
-
drwxrwxr-x. 10 nagios nagios 4096 5月 5 15:31 share
- 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
点击(此处)折叠或打开
-
[root@cache-2 ~]# wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
-
--2014-05-05 15:52:52-- http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
-
正在解析主机 nagios-plugins.org... 72.14.186.43
-
正在连接 nagios-plugins.org|72.14.186.43|:80... 已连接。
-
已发出 HTTP 请求,正在等待回应... 200 OK
-
长度:2501847 (2.4M) [application/x-gzip]
-
正在保存至: “nagios-plugins-2.0.tar.gz”
-
-
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
-
- 2014-05-05 15:53:00 (373 KB/s) - 已保存 “nagios-plugins-2.0.tar.gz” [2501847/2501847])
-
[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
点击(此处)折叠或打开
-
[root@cache-2 ~]# wget http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz
-
--2014-05-05 16:15:48-- http://archive.apache.org/dist/httpd/httpd-2.4.7.tar.gz
-
正在解析主机 archive.apache.org... 192.87.106.229, 140.211.11.131, 2001:610:1:80bc:192:87:106:229
-
正在连接 archive.apache.org|192.87.106.229|:80... 已连接。
-
已发出 HTTP 请求,正在等待回应... 200 OK
-
长度:6747087 (6.4M) [application/x-gzip]
-
正在保存至: “httpd-2.4.7.tar.gz”
-
-
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
-
- 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
点击(此处)折叠或打开
-
[root@cache-2 ~]# tar -xvf httpd-2.4.7.tar.gz
-
[root@cache-2 ~]# cd httpd-2.4.7
-
[root@cache-2 httpd-2.4.7]# ./configure --prefix=/usr/local/apache2
-
checking for chosen layout... Apache
-
checking for working mkdir -p... yes
-
checking for grep that handles long lines and -e... /bin/grep
-
checking for egrep... /bin/grep -E
-
checking build system type... x86_64-unknown-linux-gnu
-
checking host system type... x86_64-unknown-linux-gnu
-
checking target system type... x86_64-unknown-linux-gnu
-
configure:
-
configure: Configuring Apache Portable Runtime library...
-
configure:
-
checking for APR... no
-
configure: error: APR not found. Please read the documentation.
-
Google之后,发现可能是gcc版本太低了,可能是apache版本太高,换低点的2.2.23版本吧。
-
wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz
-
tar -xvf httpd-2.2.23.tar.gz
-
cd httpd-2.2.23
-
./configure --prefix=/usr/local/apache2
-
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
为了安全起见:nagios的web监控页面需要经过授权才能访问,这需要增加验证配置,即在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/,可以打开了,如下所示:
