=head1 NAME

Netdisco INSTALL -- Instructions for setting up the Netdisco application.

=head1 VERSION

Netdisco 1.1

=head1 AUTHOR

Developed by team of Open Source authors headed by Eric Miller, Bill Fenner,
and Oliver Gorwits, originally created by Max Baker.  See list at the end of
README of all the contributors.

Netdisco was created at the University of California, Santa Cruz (UCSC),
Networking and Technology Services (NTS) department.   UCSC continues to
support the development of Netdisco by providing development servers and beer.

The Netdisco project is hosted by Source Forge at L<https://sourceforge.net/projects/netdisco>
and L<https://sourceforge.net/projects/snmp-info>.

=head1 SUPPORT

Netdisco is an Open Source project created and maintained by volunteer
developers.

Please use the C<netdisco-users> mailing list for all help, problems and
comments.  Developers, patches, and ideas are always welcome.

=over

=item In Case of Problems

In case of problems, the first thing you should do is B<search> for answers on
the mailing list at
L<http://sourceforge.net/search/?group_id=80033&type_of_search=mlists>.

=item To ask a Question

To subscribe to the C<netdisco-users> mailing list to ask questions go to
L<http://lists.sourceforge.net/lists/listinfo/netdisco-users>.

=item To report a bug

To report bugs, please use the Bug tracker on the Netdisco Source Forge project page at 
L<https://sourceforge.net/tracker2/?group_id=80033&atid=558508>

=item To become a developer

If you would like to help develop Netdisco, or have code to contribute, please
submit your code to the patches tracker at
L<https://sourceforge.net/tracker2/?group_id=80033&atid=558510> and join us on
the C<netdisco-devel> mailing list.

=item To register your install of Netdisco

The developers are now maintaining a registry of Netdisco installs.  This is
mainly for morale boosting purposes, but also helps us direct feature requests
to our target audience.  One drawback of the Source Forge system is that we
have no idea how many people are using the software compared to the number of
downloads.  So after you have Netdisco up and running please spend a minute to
let us know you're using it at L<http://netdisco.org/register.html>.

=back

=head1 INSTALL FLAVORS

There are three general flavors of installs out there for Netdisco:

=over

=item From Source

The most common way is to install it from source on your machine using an
install script (see F<bin/install> and
F<http://www.auburn.edu/~gouldwp/netdisco/>), or manually using this document.

=item From Package

Netdisco is available as a package / port on a few flavors of Linux
and BSD.  Check your favorite package repository first before 
going to the trouble of installing it manually.

=item Virtual Machine / VMWARE Applicance

Charles Goldsmith maintains a VMWARE Appliance version of Netdisco
at L<http://wokka.org/netdisco/>.  This is by far the easiest way
to get up and running w/ Netdisco. 

=back

=head1 REQUIREMENTS

Netdisco is built using lots of fine Open-Source tools:

=over

=item * Perl

5.8.x and newer advised.   Whatever version that comes with your distro should
be fine.

=item * Perl Modules

Listed below

=item * Net-SNMP

5.1.x and newer advised.  Reported working on 5.0.x as well.

=item * Postgres SQL Server

Version 8.x or higher suggested.

Reported working for versions 7.2, 7.3, 7.4, 8.0, 8.1

=item * Mason

1.26 or newer required.  1.39 or newer advised, especially
for Apache2 installs.

=item * Apache

1.3.x and 2.x supported.  2.x strongly preferred.

=item * mod_perl

Get the mod_perl version to match your Apache:

=over

=item Apache 1.3.x

mod_perl version  1.29 or higher is recommended.

=item Apache 2.x

B<Do not install version 1.99>!
Make sure you have mod_perl version 2.02 or later.

=back

=item * GraphViz (Optional)

Version 2.22 or higher recommended.

=back

See L<INSTALL|install> below for details on how to retrieve and install each prerequisite.

=head2 OS

Netdisco was developed on a FreeBSD system but should work on any
system that Postgres, Perl, Apache, and Net-SNMP run on.

Linux is a sure bet.  Successful installs have been reported under Redhat,
Mandrivia, Gentoo and Debian.  A beta RPM is available for Mandrivia, but may
be out of date.  One user has reported getting Netdisco running on OS X.
Solaris has been successful for 8 and 10.  Windows will take a lot of massaging
but should be possible under Cygwin.

See L<"OS Specific Notes"> below for details.

=head1 UPGRADE

If you are upgrading your copy of Netdisco, please read through this file
and then read the C<UPGRADE> document in this directory.

=head1 INSTALL

This is not a terribly easy install.  If you aren't comfortable installing
programs from source and using a text editor, get some help.  Some packaged
versions of Netdisco are available.

=head2 1. Download Netdisco

Get the newest version from L<http://www.netdisco.org>.

=over

=item [1.1]  Unarchive Netdisco

    tar xvfz netdisco-x.xx_with_mibs.tar.gz

=item [1.2]  Create a directory for Netdisco and move the files into that dir

    mkdir /usr/pkg/netdisco
    mv netdisco-x.xx/* /usr/pkg/netdisco

=item [1.3]  Non-Standard install Directory

If you plan to install to a directory other than C</usr/pkg/netdisco> then
you must change a couple files.  Otherwise Skip down to Number 2.

=over

=item [1.3.1] Shell Scripts

The following shell scripts require you specify the Netdisco directory
if it is not in the default location:

    sql/pg -d /path/to/netdisco
    bin/netdisco_daemon

=item [1.3.2]  netdisco.conf

Set the C<home> option in F<netdisco.conf>.

=item [1.3.3] netdisco_apache.conf

Change all the appearances of C</usr/pkg/netdisco> in F<netdisco_apache.conf>
to match your new directory.

=item [1.3.4]  netdisco_apache_dir.conf

Change all the appearances of C</usr/pkg/netdisco> in F<netdisco_apache_dir.conf>
to match your new directory.

=back

=back

=head2 2. Create a Unix User/Group for Netdisco

=over

=item [2.1] Create a user and group named C<netdisco>

Linux:

    useradd -d /usr/pkg/netdisco netdisco

BSD:

    adduser netdisco


=item [2.2] User Permissions

Give this user permission to the installed files

    chown -R netdisco.netdisco /usr/pkg/netdisco

=back

=head2 3. Add Unix Administrators to Netdisco Group

Once Netdisco is up and running most administration
can be done from the Web interface.  Whoever will be doing
the back-end administration will need to have write access and will need
write access on Netdisco's files.

Add the unix account names of administrators that will modify the
source code or use the command line interface interface to the C<netdisco>
group in F</etc/group>.

Don't forget to logout and login after adding yourself to a group.

=head2 4. Postgres

Netdisco runs Postgres SQL as its database back-end.

=over

=item [4.1] Install Postgres

See the section L<"OS Specific Notes"> below for any notes relating to your operating
system of for a binary version.

There is probably a binary package all ready for you.  See your distribution's
instructions for more help.

If you cannot use a binary package, download and compile the source code
from L<http://www.postgresql.org>.

If you are installing Postgres from source you may have to run these two commands in order
to install the DBD::Pg Perl module later on :

    export POSTGRES_INCLUDE=/usr/local/postgres/include
    export POSTGRES_LIB=/usr/local/postgres/lib

You may also have to modify your F</etc/ld.so.conf> to include your new
POSTGRES_LIB directory.  Don't forget to run C<ldconf> afterwards.

=item [4.2] Configure Postgres

Netdisco's settings in Postgres are

 Database User     : netdisco
 Database Name     : netdisco
 Database Password : you choose it

Edit F<netdisco.conf> and F<netdisco_apache.conf> to match this
user name and password.

Follow these steps to setup Netdisco in Postgres.

=item [4.3] Permissions

If you have just setup Postgres for the first time you may have to change the
default permissions in F<$PG_DATA/pg_hba.conf>.  $PG_DATA might be in
F</usr/local/pgsql> or in F</var/db>, depends on your OS.  Check the postgres
users' homedir files for the location of $PG_DATA.

For installation you must give the database user access to the C<template1> database.
The following line will give all users who have logon permissions in Unix access
to the C<template1> database.

    local template1 all ident

Restart Postgres.  If you have permission problems try the following line which
opens up access to all users.

    local template1 all all

Next you must give the C<netdisco> database user access to the C<netdisco> database.
The following line will give all database users access to a database that is the same
name as them.  This line must be put above all the rest of the uncommented lines in the
F<pg_hba.conf> file to take precedence.

    local sameuser all md5

For older 7.3 or 7.4 installs of Postgres you may have to swap C<md5> for C<crypt>.
Upgrade. Please.

Finally if you would like to have C<root> be able to access all databases,
try this one :

    local all root trust

=item [4.4] Restart Postgres

You must now restart Postgres

Linux : one of these three

    /etc/rc.d/init.d/postgresql restart
    service postgresql restart
    /etc/rc.d/postgresql restart

FreeBSD :

    /usr/local/etc/rc.d/*pgsql* restart

If there are problems with this step you will receive an error that mentions something
about F<pg_hba.conf>.

=item [4.5] Create Database.

Make sure Postgres is up and running.

The C<pg> command use F<netdisco.conf> to find the database
user name and password.  Make sure that the database user name and password are
set.

As root, run C<sql/pg --init> to create the database and user for Netdisco.

When you are prompted for a password, enter the new password for the database
user you are creating.  This is the same password you set in
F<netdisco_apache.conf> and in F<netdisco.conf>.  The C<pg> command has additional
options shown in C<pg --help>


    cd /usr/pkg/netdisco/sql
    ./pg --help
    ./pg --init


If you get permissions errors, find out the name of your database user.  This
is the C<unix> user that the Postgres database is running as.  The default name
for some Linux RPM versions is C<postgres> and for some BSD installations
C<pgsql>.  If yours is different, please specify it with the C<-u> option to 
F<sql/pg>.

=item [4.6] Check Settings

Now as a non-privileged user (root) make sure you can get into the database by
running C<sql/pg>.  The database user password given above will be
retrieved from F<netdisco.conf>.

    cd /usr/pkg/netdisco/sql
    ./pg

You should see output similar to the below:

    Welcome to psql 8.0.6, the PostgreSQL interactive terminal.

    Type:  \copyright for distribution terms
           \h for help with SQL commands
           \? for help with psql commands
           \g or terminate with semicolon to execute query
           \q to quit

    netdisco=>
    netdisco=> \q

=item [4.7] Optimizations

If you have freshly installed Postgres then the default memory usage B<NEEDS> to
be increased for efficiency.  See the Postgres documentation for
F<postgresql.conf>.   Newer versions may have options to turn on for
automatic tuning.

Specifically, you really need to up the maximum connections and shared memory
settings.  After you have Netdisco running on a large installation it would be
of great benefit to get a Postgres guru in there to tune things for you.  See
F<README> for more info about how to speed things up now and again.

See L<http://www.postgresql.org/docs/current/static/kernel-resources.html> for
kernel settings related to Postgres that you I<should> check.

=item [4.8] Postgres Startup

Make sure that Postgres is set to start on reboot of the server.

=over

=item Linux

    chkconfig postgresql on

=item BSD

Make sure that the file in C</usr/local/etc/rc.d> is alright and
you have added

    postgresql_enable="YES"

to F</etc/rc.conf>.

=back

=item [4.9] Postgres Maintenance

Read the section in F<README> about Database Maintenance... every once in a
while you may have to run a C<VACUUM> and C<REINDEX> by hand if things get too slow.
This appears to be less necessary in Postgres 8.0 and up.

=item [4.10] Remote Database (Optional)

If you have Postgres installed in a remote location then all you have
to do is add that host information to the C<db_Pg> line in F<netdisco.conf>.

    db_Pg = dbi:Pg:dbname=netdisco;host=HOSTNAME;port=PORT;

On the Postgres machine, allow your remote front end to contact the back-end
database. Here is a sample line in F<pg_hba.conf>.

 #TYPE  DATABASE          USER            IP-ADDRESS              IP-MASK           METHOD
 host   netdisco        netdisco         101.102.103.104         255.255.255.0       md5

Don't forget to restart Postgres after changing the F<pg_hba.conf> file.

=back

=head2 5. SNMP

There are three components to set up for SNMP:

=head3 5.1.  Net-SNMP

Net-SNMP lives at L<http://net-snmp.sourceforge.net>.

B<There are two known bad versions: 5.2.3 and 5.3.1 !>

Please use the older working versions 5.2.2 or 5.3.0.1, or try the
newer 5.2.4, 5.3.2 or 5.4 when they're available.  See
L<http://www.net-snmp.org/dev/schedule.html> for release schedule
plans.  You can also use a nightly version from the appropriate
patch branch, from L<http://www.net-snmp.org/nightly/tarballs/>.

The symptom of the failure is getting an error C<Not an ARRAY reference at SNMP/Info.pm line xxx>.  

A workaround if you must use a buggy Net-SNMP version is to use SNMPv1 or turn
off bulkwalk with C<bulkwalk_off: yes> -- but the best thing to do is change your
Net-SNMP version.

You can update the perl SNMP module seperately from the libraries and
binaries, using CPAN.  As of this writing, the current module on CPAN is 5.0301002
which does not have this bug.  Only try to use this module with a matching
Net-SNMP version - i.e., if you get a warning like this when you try to install:

        ERROR:
        Net-SNMP installed version: 5.2.3 => 5.0203
        Perl Module Version:        5.0301

then please try a different method.

=over

=item [5.1.0] Binary Install

Check the Net-SNMP page for binaries and see L<"OS Specific Notes"> below for
details.

=item [5.1.1] Source Install

Download Net-SNMP from http://net-snmp.sourceforge.net

This used to be called ucd-snmp.  However, don't download ucd-snmp; it
is too old.

=item [5.1.2] Install Net-SNMP to include Perl module that comes inside the distribution.

When you run C<./configure>, make sure you add the switch C<--with-perl-modules>

    ./configure --with-perl-modules --enable-shared
    make
    make install

If you already have Net-SNMP installed, then go to the source directory and
in the C<perl> subdirectory and run C<perl Makefile.PL>

    cd /path/to/net-snmp-5.1.x/perl
    perl Makefile.PL
    make
    make install


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

B<DO NOT> INSTALL the C<SNMP::> or C<Net::SNMP> modules off of CPAN.  These
modules are not related to Net-SNMP and are not compatible with Netdisco.

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

=item [5.1.3] Configure Net-SNMP for a non-standard setup (Optional)

You probably will not have to do this step unless you have installed Net-SNMP
somewhere other than F</usr/local/> or have some specific SNMP defaults to
change for these tools.   Usually the settings in F<netdisco.conf> are more
than enough.

    snmpconf

Make sure to set the MIB dir if non-standard or you are not using the MIBS that
come with Netdisco.

 (Textual mib Parsing -> Specifies directories to be searched for mibs)

Make sure this newly created F<snmp.conf> lives in F</usr/local/share/snmp> or
wherever you put a custom install.

=back

=head3 5.2. SNMP::Info

SNMP::Info is one half of the Netdisco application.  

SNMP::Info holds all the device-specific code to retrieve data from network
devices via SNMP.  A wide variety of devices are supported.  You may need to
add support for other devices if they do not follow a standard interface.  This
is not too complex.  See SNMP::Info and consult the mailing list archives for
more details.

SNMP::Info is available from L<http://snmp-info.sourceforge.net> and from CPAN.
You must have Net-SNMP installed before installing it.

You have four different options in installing SNMP::Info

=over

=item [5.2.1] CPAN

    perl -MCPAN -e shell
        o conf prerequisites_policy ask
        install SNMP::Info

=item [5.2.2] From Source

Download newest version from L<http://snmp-info.sourceforge.net>

    tar xvfz SNMP-Info-1.x.tar.gz
    cd SNMP-Info-1.x
    perl Makefile.PL
    make install

=item [5.2.3] From CVS

If you plan to add or change device support in SNMP::Info to customize Netdisco to your devices,
you should install SNMP::Info this way.

    make snmp

This will create the SNMP/ directory where SNMP::Info will live.   Periodically you should re-run

    make snmp

To update to the most current CVS version.

=item [5.2.4] From Package

See L<"OS Specific Notes"> below for details.

=back

=head3 5.3.  MIBs

MIBs that are required for F<SNMP::Info> are included with Netdisco in the
F<mibs/> directory if you installed the C<netdisco-1.0_with_mibs> package.

If you installed the C<netdisco> package B<without> included MIB files, then
please download the C<netdisco-mibs> package from
L<http://sourceforge.net/project/showfiles.php?group_id=80033>.  Place
these files in C</usr/pkg/netdisco/mibs>.

=head2 6. GraphViz  (Optional)

GraphViz is used to create the Network Map.

It lives at L<http://www.graphviz.org/>.

=over

=item [6.1] Download

Get the newest version from L<http://www.graphviz.org/pub/graphviz>.
Unarchive and install.  Some binary versions are available.

=item [6.2] True Type Font

Copy a True Type Font file (F<.ttf>) into the Netdisco directory and
change C<node_font> in F<netdisco.conf> to match.

    cp /path/to/windows/fonts/lucon.ttf /usr/pkg/netdisco

You can grab F<arial.ttf> or F<lucon.ttf> out of the F<c:\windows\fonts>
directory of any Windows machine.

=item [6.3] Graph Settings

Review other graph settings in F<netdisco.conf>.  See F<README> for
details on the settings.

=item [6.4] Check Path

Make sure that C<neato> or C<twopi> is in your path, and in the path
in F<netdisco.crontab>.

    which twopi
    which neato

After the Perl Modules step below,
make sure the Graphviz Perl module got installed

    perldoc GraphViz

NOTE: You can safely ignore all warnings about C<size too small for label>.

=back

=head2 7. Setup Apache

=over

=item [7.1] Apache2

Using recent versions of Mason and mod_perl, Netdisco runs fine under
Apache2.   

=item [7.2] Apache1

It is strongly advised to use Apache2.   Consider section 7.2 as
historical.

See the O/S specific notes at the bottom of this document for
a binary install or install B<Apache 1.3.x From Scratch>:

Comment out the lines at the top of F<netdisco_apache.conf> that
are related to Apache2.

Install Apache 1.3.x and mod_perl 1.x and mod_ssl

Netdisco is designed to work in a secure (https) or non-secure
environment.  Due to the security and privacy concerned associated with
this data, using a secure server is recommended.

Below is my method if you haven't installed apache and mod_perl before.
I statically compile mod_perl, and mod_ssl then leave the rest of the
modules as dynamically loadable objects (DSO).

=over

=item [7.2.1] Download and Unarchive

Get Apache from L<http://httpd.apache.org>

Get mod_perl from L<http://perl.apache.org>

Get mod_ssl from L<http://www.modssl.org>

Unarchive all three to the same directory, maybe F</usr/local/src>

=item [7.2.2] Inital Apache Setup

This step makes the framework that mod_ssl and mod_perl need.

 cd apache_1.3*
 ./configure

No need to make it yet.

=item [7.2.3] mod_ssl

Mod_SSL gives us a secure server (https) for Netdisco to run under.

The OpenSSL library is a prerequirement for mod_ssl and may or may not already
be on your system.  See L<"OS Specific Notes"> at the bottom of this document.

To use a source version, you need to point the apache1 installer to the
install.  First follow the instructions in the F<INSTALL> that comes with
C<mod_ssl>.  Then use the command below:

 SSL_BASE=/path/to/openssl-0.9.x \
 ./configure \
    --with-apache=../apache_1.3.x \
    --disable_rule=SSL_COMPAT

=item [7.2.4] mod_perl

This step sets up mod_perl for this copy of apache :

 cd ../mod_perl-1.x
 /usr/pkg/bin/perl Makefile.PL \
        APACHE_SRC=../apache_1.3.x/src \
        EVERYTHING=1 \
        DO_HTTPD=1 \
        USE_APACI=1 \
        PREP_HTTPD=1 \
        PERL_SECTIONS=1

 make

=item [7.2.5] Apache Again

Now we're ready to make the main apache and install all of
the above (mod_ssl, mod_perl, and Apache).

 cd ../apache_1.3*
 ./configure \
        --prefix=/usr/local/apache \
        --enable-module=most \
        --enable-shared=max \
        --activate-module=src/modules/perl/libperl.a \
        --with-perl=/usr/pkg/bin/perl \
        --enable-module=ssl
 make
 make certificate
 make install

=item [7.2.6] Install mod_perl

 cd ../mod_perl*
 make install

=back

=item [7.3]  Apache Configuration Files

Add the following lines in your C<httpd.conf>.

Your C<httpd.conf> will live in C</usr/local/apache/conf> if you installed
using the method above.   For system installed packages, try C</etc/httpd>
or C</usr/local/etc/httpd>.

=over

=item [7.3.1] In the Global Section

Add this line B<once> in the end of C<httpd.conf> not in a VirtualHost section.

    Include /usr/pkg/netdisco/netdisco_apache.conf

=item [7.3.2] No virtualhosts

If you do not have virtual hosts setup and/or you have a main server, add this
line right after the first include :

    Include /usr/pkg/netdisco/netdisco_apache_dir.conf

=item [7.3.3] In each VirtualHost

If you have Virtual Hosts or are setting up a secure server, put the following
line in each of them that you want Netdisco turned on for:

If you are not using Virtual Hosts, then add this line under the
I<netdisco_apache.conf> line.

    Include /usr/pkg/netdisco/netdisco_apache_dir.conf

Make sure you have this include line for the secure server virtual host
B<*:443> at the bottom of F<http.conf>.

=back

=item [7.4]  Mason Data Directory

Set the Mason data directory writable to the apache user that does the
requests.

Assuming C<nobody> is the user that the apache web server runs under,
run this command as C<root> :

    mkdir /usr/pkg/netdisco/mason
    chown nobody.netdisco /usr/pkg/netdisco/mason

The name of the user is listed in C<httpd.conf> under the C<User> directive.
Some distros use the name C<apache> or C<www> as the web server unix user.

=back

=head2 8. Perl Modules

Below is a list of required modules for Netdisco, freely available from
CPAN L<http://www.cpan.org>.   Many of these modules have prerequisite
modules.  Many of these are available in distros already as packages. 

PLEASE check that you have these in package form first to allow for
automatic updating of these dependency libraries.   A good place to start is the
Mason library.

=over

=item [8.1] Install required Perl modules from CPAN

Use the CPAN module that comes with Perl to install the modules
and their prerequisites automatically:

    perl -MCPAN -e shell

        o conf prerequisites_policy ask
        install Digest::MD5
        install Bundle::DBI
        install Apache::DBI
        install DBD::Pg
        install DB_File      (for Apache::Session)
        install Apache::Session
        install HTML::Entities
        install HTML::Mason
        install MasonX::Request::WithApacheSession
        install Graph        ( > 0.50 )
        install GraphViz     ( > 2.02 )
        install Compress::Zlib (probably already have this one)
        install Parallel::ForkManager
        install Net::NBName (optional for NetBIOS lookup on devices)
        install Net::LDAP (optional for LDAP authentication)
        install Net::SSLeay (optional for encrypted LDAP authentication)
        install IO::Socket::SSL (optional for encrypted LDAP authentication)

For Apache1 install these modules:

        install Apache::Test (for Apache::Request, you may need to do a 'force install')
        install Apache::Request

For Apache2 install this module:

        install Apache2::Request

Some of these you will probably already have installed. Others you may need to force
with C<force install ModuleName>.  B<Do Not> include the comments in (parens)!

=item [8.2] Non-Standard Perl Location

If you don't have Perl installed in C</usr/bin>, you will need to modify
the first lines of F<netdisco> and F<bin/doc_munge> to point to the
version of Perl you would like to use.

=back

=head2 9. Netdisco Configuration

=over

=item [9.1] netdisco.conf

Modify F<netdisco.conf> to match your site.

See F<README> for detailed configuration descriptions.

=item [9.2] netdisco_apache.conf

Change the follow lines in F<netdisco_apache.conf> to match
your database user name and password that you picked in
step 4.2:

    session_user_name
    session_password
    session_cookie_domain

=item [9.3] netdisco.crontab

Use this crontab to control the frequency of data collection done by Netdisco.
See section 15 of this document for details.

Change C<center_network_device> to a network device that is well connected to the main
segment by a supported discovery protocol (CDP/FDP/SONMP/LLDP).

=item [9.4] Add a web user in Netdisco

Add a user to the Netdisco application that will be the administrator account.

    /usr/pkg/netdisco/netdisco -u joebob

Add more users from the web C<Admin Panel> once Netdisco is up and running.

=item [9.5] Make Documentation (CVS Versions Only)

This step is only necessary if you have installed from CVS.

=over

=item i. Perl Location

Make sure that the C<POD2TEXT> lines in F<Makefile> point to where your Perl binaries
are installed.

=item ii. Create Docs

This step will create documentation files from the source C<.pod>, C<.pm>, and
C<.pl> files.

 cd /usr/pkg/netdisco && gmake doc

Run this step if you would like the SNMP::Info documentation available from
Netdisco.

=back

=item [9.6] Change Permissions on Config files

Since the config files contain SNMP community strings and database passwords,
you must make them only available to the administrators for security.

 chgrp netdisco /usr/pkg/netdisco/*.conf
 chmod 660 /usr/pkg/netdisco/*.conf

=back

=head2 10. OUI Database

The C<Organizationally Unique Identifier> (OUI) database allows Netdisco to
identify the manufacture of a network card using the first 24 bits of the MAC
address.

Run the following command to import the contents of F<oui.txt> into your
database.

    cd /usr/pkg/netdisco
    netdisco -O

If you run into errors because of UTF-8 or other exotic characters
in oui.txt you may need to add this line to F<netdisco.conf>.

    db_Pg_env = PGCLIENTENCODING => iso8859-1

You may also try changing the above from C<iso8859-1> to C<UTF-8>.

=over

=item [10.1] Updating oui.txt (Optional)

The database of OUIs is needed by Netdisco and is available from the IEEE.

This will use C<wget> to download F<oui.txt> from the IEEE and import it into
the Netdisco database.

    cd /usr/pkg/netdisco
    gmake oui

If you do not have C<wget> download F<oui.txt> manually and run C<netdisco -O>.

=back

=head2 11. Restart Apache

Now that you have everything setup, "cold" restart the
web-server.

    apachectl stop
    apachectl start

Check the apache F<error_log> for errors.
See L<"OS Specific Notes"> below for details.

=head2 12. Discover a Device in Netdisco

Pick a device that you can access with the command C<snmpwalk>.
Tell Netdisco to discover that device:

    cd /usr/pkg/netdisco
    ./netdisco -d devicename

Make sure that this step actually works.  This is a good metric that you have
now installed Netdisco correctly.  Add the I<-D> flag to get copious debugging
info.

=head2 13. Create Network Topology

See F<README> for a description of I<Topology Information>.

If your network uses a supported topology discovery protocol
(CDP/FDP/SONMP/LLDP) pick a device that you consider close to the center of the
network and start an auto-discovery from there:

    cd /usr/pkg/netdisco
    ./netdisco -r myrouter

If your network is I<not> CDP friendly, then see F<README> for how to use the
manual topology file F<netdisco-topology.txt>.

You MUST supply Netdisco with a working topology or MAC addresses will show up
on uplink ports instead of end ports.

=head2 14. Test Web Side

First restart Apache so that Netdisco will see the changes that you have made
in F<netdisco.conf>.  Note that a I<graceful> restart will not re-read the
configuration file.  A full restart is required.  See Step 11.

Next, point a browser to I</netdisco> on the server you have Netdisco installed
on.

    http://localhost/netdisco

If everything is working you should be able to login with the user name and
password you added in Step 9.4.  You should also be able to access the Admin
Panel.

If you have problems, check the F<error_log> of apache for messages.

    tail /usr/local/apache/logs/error_log

=head2 15. Add Cron Jobs

Once you're sure Netdisco is setup correctly, modify
F<netdisco.crontab>.

 vi netdisco.crontab

=over

=item Network Discovery

Change C<center_network_device> to one of your core routers or switches.

=item Data Collection

You may want to fine-tune these jobs to your network.  If jobs run too frequent
and overlap, nothing bad will happen, it's just higher load on your network
devices and Netdisco server.

Once Netdisco has been running for a day, look at the C<BackEnd Log> in the web
browser and see how long each of the jobs is taking to finish.  If there is overlap,
for example if your arpnip is taking over 60 minutes or your macsuck is taking
over 120 minutes, then consider decreasing the frequency of these jobs as to not
cause extra load on your network devices.

=back

Now, as C<root>, load the crontab for the C<netdisco> user.

    su
    crontab -u netdisco /usr/pkg/netdisco/netdisco.crontab

=head2 16. Start the Netdisco Admin Daemon

The admin deaemon performs administration jobs that are requested from the
web front-end.  See F<README> for a full description of the admin daemon.

    /usr/pkg/netdisco/bin/netdisco_daemon start

The daemon will be respawned daily in the Cron job listed above.  The restart
is not 100% necessary, it is added as a precaution in case any of the
prerequisite libraries have memory leaks.

=over

=item [16.1] Make the Admin Daemon start at every boot

If you would like the daemon to be started upon bootup, then do the following:

=over

=item Linux

This is for Redhat/Mandrake/Fedora.  Debian and Gentoo might be a little different.

    ln -s /usr/pkg/netdisco/bin/netdisco_daemon /etc/rc.d/init.d
    chkconfig --add netdisco_daemon
    chkconfig netdisco_daemon on

Now you should be able to use this command:

    service netdisco_daemon {stop,start,restart,status}

=item FreeBSD

    ln -s /usr/pkg/netdisco/bin/netdisco_daemon /usr/local/etc/rc.d/netdisco.sh

=item Other

Add the following line to your F</etc/rc.d/rc.local> file :

    /usr/pkg/netdisco/bin/netdisco_daemon start

=back

=back

=head1 OS Specific Notes

=head2 FreeBSD

A port is available for FreeBSD in C</usr/ports/net-mgmt/netdisco>.  Make sure
that the port is up to date with this version of Netdisco.  This is the best
way to install Netdisco on FreeBSD.

=over

=item * Postgres

Install Postgres from ports:

    cd /usr/ports/databases/postgresql83-server
    make install

Make sure Postgres is configured to start at system startup time by
putting

    postgresql_enable="YES"

in F</etc/rc.conf>.

Next initialize the database:

    /usr/local/etc/rc.d/010.pgsql.sh initdb

And start the database server:

    /usr/local/etc/rc.d/010.pgsql.sh start

=item * Net-SNMP

Install Net-SNMP from ports.

    cd /usr/ports/net/net-snmp && make install

=item * Make

Anywhere in this document you see a reference to F<make> you should
run F<gmake>.

=item * SNMP::Info

SNMP::Info is available on ports.  Please check that the version listed
there is as new as the version required by Netdisco.

    cd /usr/ports/net-mgmt/p5-SNMP-Info
    make install

=item * GraphViz

GraphViz is available on ports:

    cd /usr/ports/graphics/graphviz && make install

=item * Apache Restart

For the ports version of apache, to cold restart (ie. for Step 11) or for
whenever you change the config file, use this command :

    /usr/local/etc/rc.d/apache2.sh stop
    /usr/local/etc/rc.d/apache2.sh start

or

    /usr/local/etc/rc.d/apache.sh stop
    /usr/local/etc/rc.d/apache.sh start


Also, double-check that Apache starts on its own at reboot.  On BSD,
make sure that you've added

    apache2_enable="YES"

to F</etc/rc.conf>.

=item * Perl Modules

You can install these Perl modules from Ports

    www/p5-HTML-Mason
    database/p5-DBI
    database/p5-DBD-Pg
    www/p5-Apache-DBI
    www/p5-Apache-Session
    www/p5-MasonX-Request-WithApacheSession

=item * Apache2

Install these ports

    www/apache22
    www/mod_perl2
    www/p5-libapreq2

=item * Apache1

If you choose to use apache1 from source you will need to
install OpenSSL to provide a secure (https) server.

Installing OpenSSL :

    cd /usr/ports/devel/mm && make install
    cd /usr/ports/security/openssl && make install

Setup mod_ssl :

    cd /path/to/mod_ssl_1.x.x
    SSL_BASE=SYSTEM \
        ./configure \
            --with-apache=../apache_1.3.x \
            --disable_rule=SSL_COMPAT

=back

=head2 Mac OS X

=over

=item * Postgres

See L<http://developer.apple.com/internet/macosx/postgres.html> for detailed instructions
on installing PostgreSQL with OS X.

=item * GraphViz

It is reported to be in C<DarwinPorts> or you can check out
L<http://www.phil.uu.nl/~js/graphviz/>.

=item * Apache1

See the very old, following three links in addition to this document to use
Apache1 w/ OS X:

 http://www.oreillynet.com/pub/a/mac/2002/11/05/apache_osx.html
 http://www.oreillynet.com/pub/a/mac/2002/12/18/apache_modssl.html
 http://www.oreillynet.com/pub/a/mac/2003/02/07/libapreq_update.html

=back

=head2 Linux - Generic

Here are some notes for installing Netdisco on Linux.  If your distro is not
listed here, look over the install scripts for other distros at
L<http://www.auburn.edu/~gouldwp/netdisco/> in the READMEs section.

=over

=item * Net-SNMP

If you have installed the Net-SNMP RPM from an C<old> Redhat or Mandrake it
B<does not> include the Perl modules.  B<Uninstall it> and install a newer
version by hand as below.

    rpm -e net-snmp

Same goes for Debian.  DO NOT use the apt-get version of Net-SNMP,
install by hand (it's easy!).

=item * GraphViz

For Redhat and Mandrake systems you will make sure that a lot of C<-devel>
packages are installed.   For example, if  you see errors about not having a
PNG or JPEG library you must install the C<-devel> packages of those libraries
as needed:

    urpmi libjpeg62-devel libpng3-devel

If you get some weird error in build about not having C<intl.la> then
make sure you have the F<gettext> packages installed :

    urpmi gettext-devel

=item * Apache Restart

For most Linux distros where you use the built-in apache web server
use one of these commands to cold restart Apache in Step 11 :

  service httpd stop
  service httpd start

OR

    /path/to/init.d/httpd stop
    /path/to/init.d/httpd start

For the path try F</etc/init.d> or F</etc/rc.d/init.d>.

=item * Apache1

Warning: Some Linux distributions such as Redhat 6.x install mod_perl as a
Dynamic Shared Object (DSO).  This is known to be unstable, especially with
Mason.  Compile mod_perl statically using the method listed above if your
distro compiles mod_perl1 using DSOs.  If you suspect yours is not compiled in,
run C<httpd -l> and see if C<mod_perl.c> is listed (it should be).

OpenSSL is required for a secure (https) server when using apache1.
OpenSSL is installed by default on most Linux distros.

You will have to tell the OS to look for the Kerberos libraries
used in this version of OpenSSL:

    ./configure \
        --with-apache=../apache_1.3.x \
        --disable_rule=SSL_COMPAT
    make C_INCLUDE_PATH=/usr/kerberos/include

(Thanks to David Martin for this info)

=back

=head2 Fedora / CentOS / Redhat

Netdisco 0.95 packages are available in the Fedora 11 repositories, and the
EPEL repositories for RHEL/CentOS 5.

Newer releases may be available from the package author's website, at
L<http://www.auburn.edu/~gouldwp/netdisco>.

We expect RPMs for Netdisco 1.0 and its dependencies to appear in the Fedora
and EPEL repositories in due course.

=head2 Mandrivia Linux

An RPM is available for Mandrivia Linux, but may be out of date.  Please check
that the RPM for Netdisco 0.95 is marked at least 200611 or newer.

=head2 Debian Linux

Debian 5.0 (Lenny) contains the Netdisco 0.95 packages and all dependencies.
Newer releases may be available at L<http://packages.debian.org/netdisco>.

We expect packages for Netdisco 1.0 and its dependencies to appear in the
official repositories for Debian "Squeeze" in due course.

=over

=item * GraphViz

Jordi Guijarro reported that the version that comes with Woody is too old.
Install a newer version from source.

=back

=head2 Ubuntu 8.04 (Hardy)

There is an old version of Netdisco in aptitutde.  So what we'll do is use that to install
all the dependencies, then uninstall netdisco and use a version from Source.

=over

=item aptitude install netdisco-backend netdisco-frontend

You may want to do this from install aptitude and select all of the optional packages so you get a full and robust GraphViz install.

=item Now remove netdisco-backend netdisco-frontend netdisco-common and libnetsnmp

BUT keep all the dependencies.

=item Install Source

Grab netdisco-with-mibs from L<https://sourceforge.net/projects/netdisco/files/>  and install into /usr/pkg/netdisco.

=item Install SNMP::Info

=item Change database passwords in F<netdisco.conf> and F<netdisco_apache.conf>

=item Postgres

You have a little bit of setup to do here.

=over

=item Edit F</etc/postgresql/8.3/main/pg_hba.conf> and relax all security for now.

Comment out everything else and do this :

 local   all  all  trust 
 host all all 127.0.0.1/32 trust

=item Run C</etc/init.d/postgresql-8.3 restart>

=item Run /usr/pkg/netdisco/sql/pg --init

=item Go back into F<pg_hba.conf> and reinstate security

 local   all         all                               md5
 local   all         all                               ident sameuser

=item Run C</etc/init.d/postgresql-8.3 restart>

=back

=item Create an SSL certificate

 mkdir /etc/apache2/ssl 
 /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem 

=item Turn on a couple Apache modules you installed

 a2enmod ssl
 a2enmod apreq

=item Create an apache config file to load Netdisco

vim /etc/apache2/sites-available/netdisco

  Include /usr/pkg/netdisco/netdisco_apache.conf
  
  NameVirtualHost *:443
  NameVirtualHost *:80
  
  <VirtualHost *:80>
  	ServerName your.server.com
  	Include /usr/pkg/netdisco/netdisco_apache_dir.conf
  </VirtualHost>
  
  <VirtualHost *:443>
  	ServerName your.server.com
          SSLEngine on
          SSLCertificateFile /etc/apache2/ssl/apache.pem
  	Include /usr/pkg/netdisco/netdisco_apache_dir.conf
  </VirtualHost>

Make sure to turn on the secure server option in C<netdisco.conf>.

=item Run C</etc/init.d/apache2 restart>

=back

=head2 Mandrake Linux 9.1

Netdisco has been tested with Mandake 9.1

=over

=item * Perl 5.8.1

Perl 5.8.1 on Mandrake 9.x may be a problem (if you get
an C<out of memory> error, you may need to change to
5.6.1 or 5.8.3+).

=item * Postgres

Installing Postgres the easy way:

    urpmi postgresql postgresql-devel postgresql-server postgresql-docs

The files you will need to edit below are in F</var/lib/pgsql/data>.

If you lost / don't have install CDs :

The following line uses an FTP site that has the 9.0 RPMs because I lost
the CDs.  Check the current mirror list at L<http://www.mandrakelinux.com/en/ftp.php3>
and choose a mirror close to you.

    urpmi.addmedia ftpsite ftp://mirror.mcs.anl.gov/pub/Mandrake-old/9.0/i586/Mandrake/RPMS \
        with ../base/hdlist.cz

Now you have to add C<--media ftpsite>  in each C<urpmi> command like so :

    urpmi --media ftpsite postgresql postgresql-devel

Remember this for the Apache setup too.

=item * Apache

Mandrake 9.1 comes with Apache2.  It also has the option
of installing a version of Apache1/mod_perl on a different port
and then reverse-proxying it.

Install Apache1 and Mod_Perl 1 and their development packages :

    urpmi apache-devel-1 mod_perl-devel-1 apache-mod_perl-1 mod_perl-common-1

Mandrake 9.1 - Do this for the DB_File Perl module

    ln -s /usr/include/db1/* /usr/include
    ln -s /usr/lib/libdb1.so.2 /usr/lib/libdb.so

B<Configure Both Apaches:>

Mandrake and some Redhats come with two copies of Apache installed.
The mod_perl server sits on a weird port and is reversed proxied by
a normal Apache server.

Mandrake 9.0 uses two Apache1 servers, while Mandrake 9.1 uses an
Apache2 server that sits in front of the apache1/mod_perl server.

Configuration files for Mandrake live in F</etc/httpd/conf>

In the file F<httpd-perl.conf> add the two C<Include> lines:

    Include /usr/pkg/netdisco/netdisco_apache.conf
    Include /usr/pkg/netdisco/netdisco_apache_dir.conf

In the file F<httpd.conf> (F<httpd2.conf> for 9.1) add the final C<RewriteRule> line:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^proxy:.*  -  [F]
    RewriteRule ^(.*\/perl\/.*)$  http://%{HTTP_HOST}:8200$1 [P]
    RewriteRule ^(.*\/cgi-perl\/.*)$  http://%{HTTP_HOST}:8200$1 [P]
    RewriteRule ^(.*\/netdisco\/.*)$  http://%{HTTP_HOST}:8200$1 [P]
    </IfModule>

In the file F<commonhttpd.conf> add the Alias line :

    Alias /netdisco /netdisco/

Restart Apache.

    /etc/rc.d/init.d/httpd restart

=back

=head2 Solaris

See L<http://www.saintmarys.edu/~dmckeown/netdisco_solaris10.htm> for 
a great document on getting Netdisco 0.94 to work with Solaris 10.

=over

=item * Make

Anywhere in this document you see a reference to F<make> you should
run F<gmake>.

=item * GraphViz

Make the JPEG and EXPAT libraries first and when making the JPEG library
make sure you have

    ./configure --enabled-shared --enabled-static

=back

=head1 SUCCESS

Now that you have spent ten hours of your life installing this go drink a Beer,
you deserve it.

Once you have or have not succeeded, come join the Netdisco User's mailing list
at L<http://netdisco.org> and pass on any hints you may have in the INSTALL
process.  It's a good place to keep up on new features and releases, and it's
B<the> place to ask any questions.

The developers are now maintaining a registry of Netdisco installs.  This is
mainly for morale boosting purposes, but also helps us direct feature requests
to our target audience.  One drawback of the Source Forge system is that we
have no idea how many people are using the software compared to the number of
downloads.  So after you have Netdisco up and running please spend a minute to
let us know you're using it at L<http://netdisco.org/register.html>.

=cut
