Page 2 of 2

Re: Ubuntu Quickguide issues

Posted: Tue Jul 14, 2015 10:37 am
by nathanplatt

Code: Select all

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#       /etc/apache2/
#       |-- apache2.conf
#       |       `--  ports.conf
#       |-- mods-enabled
#       |       |-- *.load
#       |       `-- *.conf
#       |-- conf-enabled
#       |       `-- *.conf
#       `-- sites-enabled
#               `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
        Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
This is what mine says, so it look identical to yours

Re: Ubuntu Quickguide issues

Posted: Tue Jul 14, 2015 10:41 am
by jolson
Here is the whole install procedure, from top to bottom. This was tested on versions 14.04 and above. Make sure you didn't miss anything.

Log in as the super user:

Code: Select all

sudo -i
Install pre-reqs

Code: Select all

apt-get --ignore-missing install wget build-essential apache2 php5-gd libgd2-xpm-dev libapache2-mod-php5 unzip m4 automake libtool gettext apache2-utils

Change to the tmp directory, and download Nagios Core and Nagios Plugins:

Code: Select all

cd /tmp
wget https://github.com/NagiosEnterprises/nagioscore/archive/master.tar.gz -O nagioscore.tar.gz
wget https://github.com/nagios-plugins/nagios-plugins/archive/master.tar.gz -O nagiosplugins.tar.gz

Add the appropriate user and group for the Nagios process (we recommend 'nagios' and 'nagcmd'), and assign 'nagios' and apache to the nagcmd group:

Code: Select all

useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data

Run the following commands to unpack the Nagios Core and Nagios Plugins source code into tmp:

Code: Select all

tar xzf nagioscore.tar.gz
tar xzf nagiosplugins.tar.gz
Change to the Nagios Core directory:

Code: Select all

cd nagioscore-master

Run the configure command to get the source code ready for compilation:

Code: Select all

./configure --with-command-group=nagcmd --with-nagios-group=nagios --with-mail=/usr/bin/sendmail

Compile and install:

Code: Select all

make all
make install
make install-init
make install-config
make install-commandmode

Complete the installation:

Code: Select all

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf
cp -R contrib/eventhandlers /usr/local/nagios/libexec
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
a2enmod rewrite
a2enmod cgi

Run the Nagios verification command to ensure the install completed properly:

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Start Nagios:

Ubuntu 14

Code: Select all

/etc/init.d/nagios start
Ubuntu 15

Code: Select all

/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg

Add a default user for web interface access, and start apache (we recommend calling the user 'nagiosadmin'):

Code: Select all

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/etc/init.d/apache2 restart

Change to the Nagios Plugins directory to compile and install the plugins:

Code: Select all

cd /tmp/nagios-plugins-master/
./tools/setup
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

Register the Nagios service and Apache to be run upon system startup:

Code: Select all

ln -s /etc/init.d/apache2 /etc/rcS.d/S99apache2
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

After correctly following the above procedures you should now be able to access your Nagios Core installation from a web browser. Simply visit the following URL:

Code: Select all

http://<your.nagios.server.ip>/nagios
Log in with the credentials you chose when adding the nagiosadmin user to the htpasswd.users file.

Re: Ubuntu Quickguide issues

Posted: Tue Jul 14, 2015 10:42 am
by jdalrymple
Do you get the same error if you try to start apache the proper way?

Code: Select all

systemctl start apache2

Re: Ubuntu Quickguide issues

Posted: Wed Jul 15, 2015 5:23 am
by nathanplatt
Hi Guys,

Just managed to get Nagios running now but I'm importing the config files from V3 and am getting loads of errors.

When running the verification for Nagios i'm getting;

Code: Select all

Nagios Core 4.1.0rc1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 02-18-2015
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
Error: Invalid max_check_attempts value for host 'AD-1'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/windows.cfg', starting on line 243)
   Error processing object config files!


***> One or more problems was encountered while processing the config files...

     Check your configuration file(s) to ensure that they contain valid
     directives and data defintions.  If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version.  Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.

nagios@nagios:~$
I tried modifying the windows.cfg file to solve this but nothing is working;

Code: Select all


define host{
        use             generic-host    ;
        host_name       AD1             ;
        alias           AD1             ;
        address         192.168.XXX.XXX  ;
        vrml_image      rack-server.gif ;
        statusmap_image rack-server.gd2 ;
        }


###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

#Monitoring Section#

define service{
        use                     generic-service
        host_name               DR1,DR2,DR3,DR Mail,SQL_DR,AD1,AD3,AD4,TS1,TS1-V,TS2,TS2-V,TS3-V,TS4,TS4-V,TS5,TS6,TS7,TS8,TS8-V,TS9,TS9-V,TS10,TS10-V,APP1,Kratos 3,Kratos 3-V,Kratos 4,Kratos 4-V,MS2,MS2-V,REPORT SERVER
        service_description     Check Uptime
        check_command           check_nt!UPTIME
}

define service{
        use                     generic-service
        host_name               DR1,DR2,DR3,DR Mail,SQL_DR,AD1,AD3,AD4,TS1,TS1-V,TS2,TS2-V,TS3-V,TS4,TS4-V,TS5,TS6,TS7,TS8,TS8-V,TS9,TS9-V,TS10,TS10-V,APP1,Kratos 3,Kratos 3-V,Kratos 4,Kratos 4-V,MS2,MS2-V,REPORT SERVER
        service_description     Check C Drive
        check_command           check_nt!USEDDISKSPACE -l C
}

define service{
        use                     generic-service
        host_name               DR1,DR2,DR3,DR Mail,SQL_DR,AD1,AD3,AD4,TS1,TS1-V,TS2,TS2-V,TS3-V,TS4,TS4-V,TS5,TS6,TS7,TS8,TS8-V,TS9,TS9-V,TS10,TS10-V,APP1,Kratos 3,Kratos 3-V,Kratos 4,Kratos 4-V,MS2,MS2-V
        service_description     CPU Load
        check_command           check_nt!CPULOAD -l 30,80,90
}

define service{
        use                     generic-service
        host_name               DR1,DR2,DR3,DR Mail,SQL_DR,AD1,AD3,AD4,TS1,TS1-V,TS2,TS2-V,TS3-V,TS4,TS4-V,TS5,TS6,TS7,TS8,TS8-V,TS9,TS9-V,TS10,TS10-V,APP1,Kratos 3,Kratos 3-V,Kratos 4,Kratos 4-V,MS2,MS2-V,REPORT SERVER
        service_description     Memory Usage
        check_command           check_nt!MEMUSE -w 90 -c 95
}



Re: Ubuntu Quickguide issues

Posted: Wed Jul 15, 2015 7:55 am
by nathanplatt
Thanks for all the help, after some minor modifications I've managed to get this resolved. I have more questions but they aren't related to this this topic.

Re: Ubuntu Quickguide issues

Posted: Wed Jul 15, 2015 9:20 am
by jolson
nathanplatt,

Thanks for reporting back. I'll lock this thread and mark it as resolved - feel free to open additional threads for issues you may have. Thanks!