分类: LINUX
2006-08-30 11:01:51
Apt can be used to install Apache2, the gdlib libraries and Nagios from the Ubuntu repositories, however I had problems with those versions. I ended up only using the Apache2 package and I compiled the graphics, gd libraries and Nagios from source.
tar xzf nagios-2.0b3.tar.gz
tar xzf nagios-plugins-1.4.tar.gz
tar xzf gd-2.0.33.tar.gz
tar xzf zlib-1.2.2.tar.gz
tar xzf libpng-1.2.8-config.tar.gz
tar xzf jpegsrc.v6b.tar.gz
adduser nagios
mkdir /usr/local/nagios
chown nagios.nagios /usr/local/nagios
grep "^User" /etc/apache2/apache2.conf
User www-dataIn the case of my Apache2 install, it is www-data
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd www-data
/usr/sbin/usermod -G nagcmd nagios
./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd
*** Configuration summary for nagios 2.0b3 04-03-2005 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Lock file: ${prefix}/var/nagios.lock
Init directory: /etc/init.d
Host OS: linux-gnu
Web Interface Options:
------------------------
HTML URL:
CGI URL:
Traceroute (used by WAP):
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
make all
make install
make install-init
make install-commandmode
make install-config
./configure
--with-cgiurl: /nagios/cgi-bin --with-nagios-user: nagios --with-nagios-group: nagios --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin --with-ping-command: /bin/ping -n -U -w %d -c %d %s --with-ping6-command: /bin/ping6 -n -U -c %d %s --with-lwres: no --with-ipv6: yes --with-openssl: no --enable-emulate-getaddrinfo: no
make
make check
===================== 18 of 20 tests failed =====================
make install
# BEGIN FOR NAGIOS
ScriptAlias /cgi-bin/nagios /usr/local/nagios/sbin
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
Options ExecCGI
AllowOverride AuthConfig
Order Allow,Deny
Allow From All
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user
Alias /nagios /usr/local/nagios/share
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
# END FOR NAGIOS
htpasswd2 -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
and set a password for the admin account, repeat as necessary for each account you would like to make.
/etc/init.d/apache2 restart
cd /usr/local/nagios/etc
for i in *cfg-sample; do mv $i `echo $i | sed -e s/cfg-sample/cfg/`; done;
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Reading configuration data...Apparently this is a common problem with version 2.0b3, and I found a temporary solution on the unofficial forums: Simply comment out all of the definitions it complains about! So for me, that was all of the lines between the Commands section and the Contacts section. Once you've done that you should ideally see the following at the bottom of your test:
Error: Command 'check-host-alive' has already been defined
Error: Could not register command (config file '/usr/local/nagios/etc/minimal.cfg', starting on line 76)
***> One or more problems was encountered while processing the config files...
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
/etc/init.d/nagios restart
cd /usr/local/nagios/libexec
./plugin_name -help
(ie, "./check_tcp -help")
authorized_for_system_information=nagiosadmin
authorized_for_configuration_information=nagiosadmin
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin
/etc/init.d/nagios start|stop|restart|reload|force-reload|status
/etc/init.d/apache2 start|stop|restart|reload|force-reload
/etc/apache2/apache2.conf | The config file for Apache2. This contains information about the directories your web server can access and the authentication required. |
/usr/local/nagios/bin | Contains the binary files |
/usr/local/nagios/etc | Contains the object configuration files, including minimal.cfg and cgi.cfg. |
/usr/local/nagios/libexec | Contains the plugins. |
/usr/local/nagios/sbin | Contains the cgi files for the web interface. |
/usr/local/nagios/share | Contains the web files. |
/usr/local/nagios/var | Contains the log file called nagios.log, the cache file, temp file, status file, archives folder and more. |
/etc/apache2 | Contains the configuration files for Apache2, necessary for configuring authentication. |
/var/log/apache2 | Contains the log files for Apache2, useful for confirming authentication is configured correctly. |
/var/www | The root directory for web documents. I placed an index.html file here that directed visitors to /nagios and provided information about the server. |
apt-get install gcc
apt-get install gcc-3.4
apt-get install gcc-3.4-doc
cd ~/downloads/zlib-1.2.2
./configure
make
make install
cd ~/downloads/libpng-1.2.8-config
cp scripts/makefile.std makefile
./configure
make
make install
cd ~/downloads/jpeg-6b
./configure --prefix=${prefix} --enable-static --enable-sharedMake
make
strip rdjpgcom wrjpgcom .libs/{cjpeg,djpeg,jpegtran}Install
mkdir -p ${prefix}/{bin,include,lib,man/man1}
make test
make install
cd ~/downloads/gd-2.0.33
./configure
** Configuration summary for gd 2.0.33:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: no
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes
This was my output, I'm not sure if the three libraries that lack support are needed or not, however PNG and JPEG support are necessary otherwise some of the CGI scripts won't function.
make
make install