Friday, July 29, 2011

Installing NMIS (Network Management Information System)

Recently I was a presenter at the annual Tech Feast conference held at Heartland Community College in Normal, IL.  The conference is a gathering of technology educators in the K-12 schools of Illinois.  In my presentations on network troubleshooting I mentioned the open source tool NMIS and had several requests for more information on the installation and use of the tool.  This post will serve as an installation guide from a bare bones Ubuntu 10.04 LTS server install.  A subsequent post will cover configuration of NMIS.


Installing Ubuntu 10.04 LTS

The first step in this process I'm going to leave mostly to the reader and other HOWTOs as it in itself can be an entire post.  Installing Ubuntu 10.04 LTS server requires going to Ubuntu's website to download an ISO copy of the installer for either i386 (32-bit) or x64(64-bit).  Once downloaded burn the ISO to a CD or mount it to your VM and boot to CD.  Take the defaults and don't install any of the server roles, except OpenSSH Server, at the end of the install to get a bare bones server system.

Installing the Prerequisite Ubuntu Packages for NMIS

Once you have a working system, login to the server either locally or via SSH.  The first set of applications will be used later to compile other prerequisites.

sudo apt-get update
sudo apt-get install autoconf automake gcc
The next group of packages are required to compile RRDTools which will be done later in the process.


sudo apt-get install libcairo2 libcairo2-dev \
libglib2.0-dev libpango1.0-dev libxml2 libxml2-dev
Packages for SNMP (Simple Network Management Protocol) are the next to be installed.


sudo apt-get install snmp net-snmp-lib net-snmp-utils net-snmp-perl
 Finally we need to install the packages for the Apache webserver.


sudo apt-get install apache2

 Installing RRDTool From Source for NMIS


The developers of NMIS recommend that you use RRDTool compiled from source instead of the Ubuntu maintained packages.  This is a relatively straightforward process.


wget http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz
tar xzvf rrdtool.tar.gz
cd rrdtool-1.4.5/
./configure --enable-shared --prefix=/usr/local/rrdtool
make
sudo make install

 Installing Perl Packages from CPAN


NMIS uses several Perl packages that are maintained in the Comprehensive Perl Archive Network (CPAN).  These packages can be installed using the CPAN module of Perl.  In my instructions I include upgrading the CPAN module first because it sometimes helps to have the newest version. When you first open CPAN you can accept the defaults unless you need to setup an HTTP proxy


sudo perl -MCPAN -e "shell"
o conf prerequisites_policy follow
o conf commit
install CPAN::Bundle YAML
reload CPAN
install JSON
install Proc::ProcessTable
install Image::Resize
install Crypt::DES
install Crypt::Rijndael
install Digest::HMAC
install Digest::SHA1
install Socket6
install Net::SNMP
install Time::HiRes
install Time::ParseDate
install Statistics::Lite
install Net::SNPP
install Net::SMTP
install Net::DNS
install IPC::Shareable
install BSD::Resource
install GD::Graph
install Net::EasyTCP
install Data::Dumper
install Cache::Mmap
install Proc::Queue
install Date::Parse
install Date::Calc
install Math::Round
install DBI
 Install NMIS


Now that we have the prerequisites out of the way it's time to install the NMIS application itself.  You will have to go to Opmantek's website to download NMIS.  While it is free, they do currently require you to register to get a link to download the newest version of NMIS.  Once you have the link download the nmis-8.1.1.tar.gz file to your Ubuntu server and proceed as follows.  The first step is to decompress the archive and copy the files into /usr/local.


tar xzvf nmis-8.1.1.tar.gz
sudo cp -Rpv nmis8/ /usr/local/
sudo cp -Rpv /usr/local/nmis8/install/* /usr/local/nmis8/conf/
Once the files are copied you will need to setup the nmis user and nmis group as well as add the www-data user to the nmis group. We also need to give proper permissions to the NMIS files.

sudo useradd nmis
sudo usermod -G nmis www-data
sudo chown -Rv nmis:nmis /usr/local/nmis8
sudo chmod -Rv g+w /usr/local/nmis8

Verifying NMIS is Installed


Once everything above is done, it is a good time to verify that the basic install process is done.  You can do this by doing
sudo /usr/local/nmis8/cgi-bin/nmiscgi.pl
As long as you get HTML output, all of the Perl prerequisites have been installed.  If you get errors about missing modules, verify that they are installed via CPAN.  The next verification is to run a check on the basic configuration.


sudo /usr/local/nmis8/bin/nmis.pl type=config debug=true
This should result in something similar to the below output:



NMIS Copyright (C) 1999-2011 Opmantek Limited (www.opmantek.com)
This program comes with ABSOLUTELY NO WARRANTY;
This is free software licensed under GNU GPL, and you are welcome to
redistribute it under certain conditions; see www.opmantek.com or email
contact@opmantek.com

NMIS version 8.1.1


Root directory of NMIS is /usr/local/nmis8

14:07:35 checkConfig, Config Checking - Checking database directories
Continue with bin/nmis.pl type=apache for configuration rules of the Apache web server
Next we will check to make sure that the NMIS update and collection scripts work by running them against the NMIS server.

sudo /usr/local/nmis8/bin/nmis.pl type=update node=localhost debug=true
sudo /usr/local/nmis8/bin/nmis.pl type=collect node=localhost \
debug=true
 
Configure Apache for NMIS


Now that we know that NMIS is ready to answer the call, we need to setup Apache so that we can serve up the Web GUI for NMIS.  NMIS provides a script to produce the proper Apache configuration.


cd ~
sudo /usr/local/nmis8/bin/nmis.pl type=apache > 000-nmis
sudo mv /etc/apache2/sites-enabled/000-default \
/etc/apache2/sites-enabled/default
sudo cp 000-nmis /etc/apache2/sites-enabled/000-nmis
sudo htpasswd /usr/local/nmis8/conf/users.dat admin
sudo /etc/init.d/apache2 restart

Verify NMIS Web Interface

Point your web browser (Firefox or IE work best, Chrome UI is buggy unfortunately) to http://yournmishost/cgi-nmis8/nmiscgi.pl and you should see something like this:

NMIS Web User Interface

Install the NMIS Crontab

To begin polling you must add the NMIS applications to CRON.  To do that do a sudo crontab -e to open the crontab editor and then copy in the following with the e-mail address changed to your e-mail address.


MAILTO=WhoeverYouAre@yourdomain.tld
######################################################
# NMIS8 Cronfig
######################################################
# Run Statistics Collection
*/5 * * * * /usr/local/nmis8/bin/nmis.pl type=collect mthread=true maxthreads=10
#####################################################
# Run the interfaces 4 times an hour with Thresholding on!!!
*/15 * * * * nice /usr/local/nmis8/bin/nmis.pl type=threshold mthread=true maxthreads=10
######################################################
# Run the update once a day
30 20 * * * nice /usr/local/nmis8/bin/nmis.pl type=update mthread=true maxthreads=10
######################################################
# Check to rotate the logs 4am every day UTC
5 20 * * * /usr/sbin/logrotate /usr/local/nmis8/conf/logrotate.conf
##################################################
# save this crontab every day
0 8 * * * crontab -l > /usr/local/nmis8/conf/crontab.root

15 comments:

  1. Thank you for posting such a useful, impressive and a wicked article./Wow.. looking good!
    Software Testing Tutorial

    ReplyDelete
  2. Hi i have a problem with those line, please advice. im a beginner with linux :

    command
    --------
    root@nmis:~# sudo mv /etc/apache2/sites-enabled/000-default \
    /etc/apache2/sites-enabled/default
    error message
    --------------
    mv: cannot stat `/etc/apache2/sites-enabled/000-default': No such file or directory
    command
    ---------
    root@nmis:~# sudo /etc/init.d/apache restart
    Error
    ------
    sudo: /etc/init.d/apache: command not found

    ReplyDelete
  3. Mehdi, It would seem that you haven't installed Apache yet or you are using these instructions on a different flavor of Linux that puts things in a different place. If you're using Ubuntu 10.04 LTS Server, type
    sudo apt-get install apache2

    This will install Apache.

    ReplyDelete
  4. Hi Said,

    First, thanks a lot for ur reply and i like to thank you also for this steps. it's really helpful.

    For the Apache2 I did that, and it showed that the apache2 is already installed

    below is the version that i'm using
    --------------------------------

    noc@nmis:~$ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 10.04.2 LTS
    Release: 10.04
    Codename: lucid

    Thanks again

    ReplyDelete
  5. Ok, looks like I dropped a 2 from the restart command. It has been changed in the article. As for the mv command I am not sure. Can you show me a ls -lh from /etc/apache2/sites-enabled/

    Thanks

    ReplyDelete
  6. Hi,

    please see below:

    root@nmis:/etc/apache2/sites-enabled# ls
    000-nmis default

    ReplyDelete
  7. Looks like you should be good, not sure why the 000-default wasn't in there to start with.

    ReplyDelete
  8. hi thanks for all,

    I can acces NMIS now but i have another question :

    I don't know why nmis is not polling the metric is 0% reach 0% int avail 0% health 0% resptime 0MS

    it's like it' not polling and tried to ping the host, it's pingable.

    Please advise

    ReplyDelete
  9. Doh! That's what I get for not running through the instructions a second time after doing the install. I've added the steps for polling above. You have to install the jobs into CRON.

    ReplyDelete
  10. Hi,

    Great Job sir, it's polling right now. :)

    Another question, do you have an idea why the nmis goes back to current staus page(home page) automatically. eg, i want to create a node and it doesn't give me the time to do it!! did i missed something??

    Thanks again for everything :)

    ReplyDelete
  11. The refresh bug is a known issue. The development team addressed it in the following post.

    http://tech.groups.yahoo.com/group/nmis_users/message/8842

    ReplyDelete
  12. soory i forgot to mention something, during the installation, i got this message when i was installing the snmp :

    sudo apt-get install net-snmp net-snmp-lib net-snmp-utils net-snmp-perl
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package net-snmp <-------------

    I put sudo apt-get install snmp and it worked!

    ReplyDelete
  13. Hi,
    Can you post an article about how to configure and use NMIS, i.e. how to populate the tables of nodes,contacts, how to configure nmis.conf and what it means all like stuff.I didn't find out documentation abot using&configuring NMIS, only about installink it.

    Thanks for this post.

    ReplyDelete
  14. Florin,

    I have plans to do that, I just haven't gotten around to it yet.

    ReplyDelete