Difference between revisions of "Nagios FreeBSD"

From Teknologisk videncenter
Jump to: navigation, search
m (Step 4: Apache configuration)
m
 
(11 intermediate revisions by the same user not shown)
Line 79: Line 79:
 
You need a "nagios" user.
 
You need a "nagios" user.
 
Would you like me to create it [YES]? <input>YES</input>
 
Would you like me to create it [YES]? <input>YES</input>
 +
 
<notice> ..... Output omitted ..... </notice>
 
<notice> ..... Output omitted ..... </notice>
**********************************************************************
 
 
Enable Nagios in /etc/rc.conf with the following line:
 
 
  nagios_enable="YES"
 
  
Configuration templates are available in /usr/local/etc/nagios as
 
*.cfg-sample files.  Copy them to *.cfg files where required and
 
edit to suit your needs.  Documentation is available in HTML form
 
in /usr/local/www/nagios/docs.
 
 
If you don't already have a web server running, you will need to
 
install and configure one to finish off your Nagios installation.
 
When used with Apache, the following should be sufficient to publish
 
the web component of Nagios (modify the allow list to suit):
 
 
  <Directory /usr/local/www/nagios>
 
    Order deny,allow
 
    Allow from all
 
    Allow from 127.0.0.1
 
  </Directory>
 
 
  <Directory /usr/local/www/nagios/cgi-bin>
 
    Options ExecCGI
 
  </Directory>
 
 
  ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
 
  Alias /nagios/ /usr/local/www/nagios/
 
 
**********************************************************************
 
 
===> Installing rc.d startup script(s)
 
===> Installing rc.d startup script(s)
 
===>  Registering installation for nagios-3.0.6
 
===>  Registering installation for nagios-3.0.6
Line 120: Line 92:
 
== Step 4: Apache configuration ==
 
== Step 4: Apache configuration ==
 
<source lang=cli>
 
<source lang=cli>
[root@sun /etc]# <input>echo '   <Directory /usr/local/www/nagios></input>
+
[root@sun /etc]# <input>echo '<Directory /usr/local/www/nagios>
    Order deny,allow
+
        Options None
    Deny from all
+
        AllowOverride None
    Allow from 127.0.0.1
+
        Order allow,deny
  </Directory>
+
        Allow from all
 +
        AuthName "Nagios Access"
 +
        Authtype Basic
 +
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
 +
        Require valid-user
 +
</Directory>
  
  <Directory /usr/local/www/nagios/cgi-bin>
+
<Directory /usr/local/www/nagios/cgi-bin>
    Options ExecCGI
+
        Options ExecCGI
  </Directory>
+
        AllowOverride None
 +
        Order allow,deny
 +
        Allow from all
 +
        AuthName "Nagios Access"
 +
        Authtype Basic
 +
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
 +
        Require valid-user
 +
</Directory>
  
  ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
+
ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
  Alias /nagios/ /usr/local/www/nagios/
+
Alias /nagios/ /usr/local/www/nagios/
 
' >> /usr/local/etc/apache/httpd.conf</input>
 
' >> /usr/local/etc/apache/httpd.conf</input>
 
[root@sun /etc]# <input>/usr/local/etc/rc.d/apache restart</input>
 
[root@sun /etc]# <input>/usr/local/etc/rc.d/apache restart</input>
Line 137: Line 121:
 
Waiting for PIDS: 969, 969, 969, 969.
 
Waiting for PIDS: 969, 969, 969, 969.
 
Starting apache.
 
Starting apache.
 +
</source>
 +
=== Adding users ===
 +
<source lang=cli>
 +
[root@sun ~]# <input>htpasswd -c /usr/local/etc/nagios/htpasswd.users nagiosadmin</input>
 +
New password:
 +
Re-type new password:
 
</source>
 
</source>
  
== Step 5: Nagios minimal configuration ==
+
== Step 5: Sample configuration ==
 
+
<source lang=cli>
 +
[root@sun ~]# <input>cd /usr/local/etc/nagios</input>
 +
[root@sun /usr/local/etc/nagios]# <input>cp nagios.cfg-sample nagios.cfg</input>
 +
[root@sun /usr/local/etc/nagios]# <input>cp resource.cfg-sample resource.cfg</input>
 +
[root@sun /usr/local/etc/nagios]# <input>cp cgi.cfg-sample cgi.cfg</input>
 +
[root@sun /usr/local/etc/nagios]# <input>cd objects</input>
 +
[root@sun /usr/local/etc/nagios/objects]# <input>cp commands.cfg-sample commands.cfg</input>
 +
[root@sun /usr/local/etc/nagios/objects]# <input>cp contacts.cfg-sample contacts.cfg</input>
 +
[root@sun /usr/local/etc/nagios/objects]# <input>cp localhost.cfg-sample localhost.cfg</input>
 +
[root@sun /usr/local/etc/nagios/objects]# <input>cp templates.cfg-sample templates.cfg</input>
 +
[root@sun /usr/local/etc/nagios/objects]# <input>cp timeperiods.cfg-sample timeperiods.cfg</input>
 +
[root@sun /usr/local/etc/nagios/objects]# <input>/usr/local/etc/rc.d/nagios start</input>
 +
Performing sanity check of nagios configuration: OK
 +
Starting nagios.
 +
</source>
 +
== Step 6: First view in browser ==
 +
*goto: http://YOUR-HOST/nagios/index.html
 +
= Configuring =
 +
== Files ==
 +
*'''/usr/local/etc/nagios''': config directory
 +
*'''/usr/local/etc/rc.d/nagios''': Run script
 +
*'''/usr/local/libexec/nagios''': Plugin directory
 +
*'''/usr/local/www/nagios''': Web installation
  
  
  
{{#css: 
+
{{Source cli}}
    pre {  font-family: Lucida Console; font-weight: bold; font-size: 14px; color: #00FF00; background: black; margin: 10px 50px; width: 800px; line-height: 200%; overflow: auto;}
 
}}
 
 
[[category:FreeBSD]][[Category:Network Management]]
 
[[category:FreeBSD]][[Category:Network Management]]

Latest revision as of 17:33, 28 February 2010

Installation

Step 1: prepare

[root@sun ~]# <input>cd /usr/ports/net-mgmt/nagios</input>
[root@sun /usr/ports/net-mgmt/nagios]# <input>make</input>
===>  Vulnerability check disabled, database not found
===>  Found saved configuration for nagios-3.0.6
=> nagios-3.0.6.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://nchc.dl.sourceforge.net/sourceforge/nagios/.
fetch: http://nchc.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz: Moved Temporarily
<notice> ..... Output omitted ..... </notice>
*** 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 /usr/local/etc/rc.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/etc/nagios
       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 monitored!

  make install-webconf
     - This installs the Apache config file 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 HTML documentation
     - Read the FAQs online at http://www.nagios.org/faqs

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://www.nagios.org/support/

*************************************************************

Enjoy.

Step 2: Install

[root@sun /usr/ports/net-mgmt/nagios]# <input>make install</input>
===>  Installing for nagios-3.0.6
===>   nagios-3.0.6 depends on file: /usr/local/libexec/nagios/check_nagios - not found
<notice> ..... Output omitted ..... </notice>
===>   nagios-3.0.6 depends on shared library: ltdl.4 - found
pw: unknown group `nagios'
You need a "nagios" group.
Would you like me to create it [YES]? <input>YES</input>
Done.
pw: no such user `nagios'
You need a "nagios" user.
Would you like me to create it [YES]? <input>YES</input>

<notice> ..... Output omitted ..... </notice>

===> Installing rc.d startup script(s)
===>   Registering installation for nagios-3.0.6

Step 3: nagios daemon config

[root@sun /etc]# <input>echo 'nagios_enable="YES"' >> /etc/rc.conf</input>

Step 4: Apache configuration

[root@sun /etc]# <input>echo '<Directory /usr/local/www/nagios>
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
        AuthName "Nagios Access"
        Authtype Basic
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
        Require valid-user
</Directory>

<Directory /usr/local/www/nagios/cgi-bin>
        Options ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
        AuthName "Nagios Access"
        Authtype Basic
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
        Require valid-user
</Directory>

ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
Alias /nagios/ /usr/local/www/nagios/
' >> /usr/local/etc/apache/httpd.conf</input>
[root@sun /etc]# <input>/usr/local/etc/rc.d/apache restart</input>
Stopping apache.
Waiting for PIDS: 969, 969, 969, 969.
Starting apache.

Adding users

[root@sun ~]# <input>htpasswd -c /usr/local/etc/nagios/htpasswd.users nagiosadmin</input>
New password:
Re-type new password:

Step 5: Sample configuration

[root@sun ~]# <input>cd /usr/local/etc/nagios</input>
[root@sun /usr/local/etc/nagios]# <input>cp nagios.cfg-sample nagios.cfg</input>
[root@sun /usr/local/etc/nagios]# <input>cp resource.cfg-sample resource.cfg</input>
[root@sun /usr/local/etc/nagios]# <input>cp cgi.cfg-sample cgi.cfg</input>
[root@sun /usr/local/etc/nagios]# <input>cd objects</input>
[root@sun /usr/local/etc/nagios/objects]# <input>cp commands.cfg-sample commands.cfg</input>
[root@sun /usr/local/etc/nagios/objects]# <input>cp contacts.cfg-sample contacts.cfg</input>
[root@sun /usr/local/etc/nagios/objects]# <input>cp localhost.cfg-sample localhost.cfg</input>
[root@sun /usr/local/etc/nagios/objects]# <input>cp templates.cfg-sample templates.cfg</input>
[root@sun /usr/local/etc/nagios/objects]# <input>cp timeperiods.cfg-sample timeperiods.cfg</input>
[root@sun /usr/local/etc/nagios/objects]# <input>/usr/local/etc/rc.d/nagios start</input>
Performing sanity check of nagios configuration: OK
Starting nagios.

Step 6: First view in browser

Configuring

Files

  • /usr/local/etc/nagios: config directory
  • /usr/local/etc/rc.d/nagios: Run script
  • /usr/local/libexec/nagios: Plugin directory
  • /usr/local/www/nagios: Web installation