Skip to content

Instantly share code, notes, and snippets.

@narutaro
Last active June 23, 2016 06:38
Show Gist options
  • Save narutaro/64d3b6edd16625ca3e58 to your computer and use it in GitHub Desktop.
Save narutaro/64d3b6edd16625ca3e58 to your computer and use it in GitHub Desktop.
nfsen install on ubuntu 14.04

Settin up nfsen

Error

inoue@netflowc:~/nfsen-1.3.6p1$ ./install.pl 
Can't locate RRDs.pm in @INC (you may need to install the RRDs module) (@INC contains: ./libexec ./installer-items /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at libexec/NfSenRRD.pm line 38.
BEGIN failed--compilation aborted at libexec/NfSenRRD.pm line 38.
Compilation failed in require at libexec/NfSen.pm line 43.
BEGIN failed--compilation aborted at libexec/NfSen.pm line 43.
Compilation failed in require at ./install.pl line 46.
BEGIN failed--compilation aborted at ./install.pl line 46.

Error

me@netflowc:~/nfsen-1.3.6p1$ sudo perl -MCPAN -e 'install Mail::Header'
CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.
Would you like to configure as much as possible automatically? [yes] 
ALERT: 'make' is an essential tool for building perl Modules.
Please make sure you have 'make' (or some equivalent) working.
Autoconfigured everything but 'urllist'.
Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.
Would you like me to automatically choose some CPAN mirror
sites for you? (This means connecting to the Internet) [yes] 
Trying to fetch a mirror list from the Internet
Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/MIRRORED.BY
Looking for CPAN mirrors near you (please be patient)
.......................... done!
New urllist
  http://noodle.portalus.net/CPAN/
  http://cpan.develooper.com/
  http://mirrors.gossamer-threads.com/CPAN/
Autoconfiguration complete.
commit: wrote '/home/inoue/.cpan/CPAN/MyConfig.pm'
You can re-run configuration any time with 'o conf init' in the CPAN shell
Fetching with HTTP::Tiny:
http://noodle.portalus.net/CPAN/authors/01mailrc.txt.gz
Reading '/home/inoue/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with HTTP::Tiny:
http://noodle.portalus.net/CPAN/modules/02packages.details.txt.gz
Reading '/home/inoue/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Wed, 04 Nov 2015 04:29:02 GMT
  HTTP::Date not available
..............
  New CPAN.pm version (v2.10) available.
  [Currently running version is v2.00]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.
..............................................................DONE
Fetching with HTTP::Tiny:
http://noodle.portalus.net/CPAN/modules/03modlist.data.gz
Reading '/home/inoue/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /home/inoue/.cpan/Metadata
Running install for module 'Mail::Header'
Running make for M/MA/MARKOV/MailTools-2.14.tar.gz
Fetching with HTTP::Tiny:
http://noodle.portalus.net/CPAN/authors/id/M/MA/MARKOV/MailTools-2.14.tar.gz
Fetching with HTTP::Tiny:
http://noodle.portalus.net/CPAN/authors/id/M/MA/MARKOV/CHECKSUMS
Checksum for /home/inoue/.cpan/sources/authors/id/M/MA/MARKOV/MailTools-2.14.tar.gz ok
  CPAN.pm: Building M/MA/MARKOV/MailTools-2.14.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Mail
Writing MYMETA.yml and MYMETA.json
  MARKOV/MailTools-2.14.tar.gz
  make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible

Apache, PHP and modules

sudo apt-get install make gcc
apt-get install apache2 libapache2-mod-php5 php5-common libmailtools-perl rrdtool librrds-perl

sudo perl -MCPAN -e 'install Mail::Header'
sudo cpan YAML
adduser netflow
adduser www

User 'netflow' not a member of group 'www'

sudo usermod -g www-data netflow

nfsen.conf

The portion to change:

# Required for default layout
$BASEDIR = "/disk/nfsen"

# Run nfcapd as this user
# This may be a different or the same uid than your web server.
# Note: This user must be in group $WWWGROUP, otherwise nfcapd
#       is not able to write data files!
$USER    = "netflow";

# user and group of the web server process
# All netflow processing will be done with this user
# Apache default is "www-data"
$WWWUSER  = "www-data";
$WWWGROUP = "www-data";

# nfdump tools path
#$PREFIX  = '/usr/local/bin';
$PREFIX  = '/usr/bin';

# Netflow sources
# Define an ident string, port and colour per netflow source
#
# Required parameters:
#    ident   identifies this netflow source. e.g. the router name, 
#            Upstream provider name etc.
#    port    nfcapd listens on this port for netflow data for this source
#                        set port to '0' if you do not want a collector to be started
#    col     colour in nfsen graphs for this source
#
# Optional parameters
#    type    Collector type needed for this source. Can be 'netflow' or 'sflow'. Default is netflow
#        optarg  Optional args to the collector at startup
#
# Syntax: 
#         'ident' => { 'port' => '<portnum>', 'col' => '<colour>', 'type' => '<type>' }
# Ident strings must be 1 to 19 characters long only, containing characters [a-zA-Z0-9_].
%sources = (
    'gin'    => { 'port' => '5678', 'col' => '#0000ff', 'type' => 'netflow' },
    'sim'    => { 'port' => '9001', 'col' => '#ff0000', 'type' => 'netflow' },
);

Config

sudo /data/nfsen/bin/nfsen reconfig

Start

sudo /data/nfsen/bin/nfsen start

Change apache's DocumentRoot to the same as nfsen configuration file - /var/www

vi /etc/apache2/sites-enabled/000-default.conf

#Access to the web interface

http://<server_ip>/nfsen/nfsen.php

But, on the web interface,

ERROR: nfsend connect() error: Permission denied!
ERROR: nfsend - connection failed!!
ERROR: Can not initialize globals!

This will solve - workaround

inoue@netflowc:/data/nfsen/var/run$ file *
nfsen.comm: socket 
nfsend.pid: ASCII text
p2055.pid:  ASCII text
p9001.pid:  ASCII text
inoue@netflowc:/data/nfsen/var/run$ sudo chmod 777 ./nfsen.comm 

#Changing graph color I found this way in the nfsen mailing list archive.

I've had better success changing these colors in the web interface. Click on the stats tab for the live profile and edit each channel list. You can change the color there also.

Please change the colours using the web interface. The colours in nfsen.conf are for initial ( installation ) purpose only and will actually no longer be used in 1.3. They will get removed in future versions.

Apache2 setting

/etc/apache2/sites-available/000-default.conf

DocumentRoot /var/www

And go to http"/<tour_server>/nfsen/nfsen.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment