Sunday, August 26, 2012

Network device management and graphs for the busy Admin

If you are a busy admin and want to setup a SNMP based monitoring system quickly and easy, try JFFNMS. Its licensed under the GNU GPL model so there is no charge for using or modifying the tool. I will install JFF in a VMWare virtual machine using FreeBSD 9.0 as OS. I just created a new virtual machine with a 50GB hard disk to have many months of historical data.. also we can have years of information for reference and behavior. I just installed FreeBSD with the default options and making sure to set up the correct time-zone and assigned an IP address. After reboot,  logged on to the JFF box and verify network connection.

First step in every new OS installation are patches. I used the following command to patch the new FreeBSD installation:

jff# freebsd-update fetch


Once patches are downloaded, we need to install them:

jff# freebsd-update install


Once my OS is patched I need the newest FreeBSD ports collection using the built-in tool portsnap.

jff# portsnap fetch


Now its time to extract the downloaded ports file; go and grab a cup of coffee and work on your pending tasks, it could take a while.

jff# portsnap extract


Now we are ready to install applications. The first we need its our Apache web server. Any version newer that 2.2 works. We are going to install the newest Apache version from the ports collection. Again, go to lunch or finish your pending tasks and go back in 20 mins.

jff# cd /usr/ports/www/apache22
jff# make config
jff# make install clean BATCH=YES



It's time to test our web server. Add the following line to the /etc/rc.conf and start the web server.

jff# echo 'apache22_enable="YES"' >> /etc/rc.conf
jff# apachectl start


Browse to the JFF box IP address and you should receive the default page.







JFF use PHP languaje so we need to install it. 

jff# cd /usr/ports/lang/php5

Very important once in the  /usr/ports/lang/php5 directory, tell php to work with apache and then install it.

jff# make config













jff# make install clean BATCH=YES



JFF needs some PHP modules so let go ahead and install them. Select the GD, SNMP, SOCKETS and MYSQL modules from the 'make config' screen.

jff# cd /usr/ports/lang/php5-extensions/
jff# make config














jff# make install clean BATCH=YES


Modify the php.ini file after copiyng from the defaults

jff# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

jff# vi /usr/local/etc/php.ini


    error_reporting  =  E_ALL & ~E_NOTICE
    allow_url_fopen = On
    short_open_tag = On
    date.timezone = "America/Mexico_City"

Save the php.ini file after setting the previous values.


JFF uses MySQL for store of all configuration and data grabbed from devices. So lets proceed the installation.

jff# cd /usr/ports/databases/mysql55-server/
jff# make install clean BATCH=YES


Now that MySQL is installed we need to initialize the grant tables

jff# mysql_install_db --user=mysql


We will start MySQL for the first time

jff# mysqld_safe --user=mysql &


Modify the /etc/rc.conf file to start MySQL at boot and start MySQL as daemon.

jff# echo 'mysql_enable="YES"' >> /etc/rc.conf
jff# /usr/local/etc/rc.d/mysql-server start


Lets change the mysql root account password

jff# mysql
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd') WHERE User = 'root';

mysql> FLUSH PRIVILEGES;
mysql> exit;


There are another pre-requisites that we need to install, they are nmap, rrdtool, fping, diffutils.

jff# cd /usr/ports/security/nmap && make install clean BATCH=YES

jff# cd /usr/ports/databases/rrdtool && make install clean BATCH=YES


jff# cd /usr/ports/net/fping  && make install clean BATCH=YES

jff# cd /usr/ports/textproc/diffutils  && make install clean BATCH=YES

jff# cd /usr/ports/graphics/graphviz  && make install clean BATCH=YES



After all the packages are installed, we will need to create the groups and users used by JFF.

jff# pw groupadd jffnms

jff# pw useradd jffnms -c 'JFFNMS User' -d /usr/local/etc/jffnms -s /nologin -g jffnms

jff# pw groupmod jffnms -m www


Its time to download the JFF software, unpack it and assign the required permissions. Download the package from http://sourceforge.net/projects/jffnms/files/ and store it in the /usr/local/etc directory.

jff# cd /usr/local/etc

jff# tar xvzf jffnms-0.9.3.tgz


jff# chown -R jffnms:jffnms /usr/local/etc/jffnms-0.9.3

jff# chmod 770 /usr/local/etc/jffnms-0.9.3


jff# chmod -R ug+rw /usr/local/etc/jffnms-0.9.3

jff# ln -s /usr/local/etc/jffnms-0.9.3 /usr/local/etc/jffnms


Import the crontab file to schedule the pollers and modify the crontab file to match the values of our installation.

jff# crontab -u jffnms /usr/local/etc/jffnms/docs/unix/crontab

jff# crontab -e -u jffnms














 The next its to change the permissions of some folders and files.


jff# chmod +s /usr/local/bin/nmap

jff# chmod a+x /usr/local/bin/nmap


jff# chmod +s /usr/local/sbin/fping

jff# chmod a+x /usr/local/sbin/fping


We are almost done.. Lets create and configure our MySQL database.


jff# mysql -u root -p

mysql> CREATE DATABASE jffnms;

mysql> GRANT ALL PRIVILEGES ON jffnms.* TO jffnms@localhost IDENTIFIED BY 'jffnms';

mysql> FLUSH PRIVILEGES;

mysql> quit

jff# mysql -u jffnms -pjffnms jffnms < /usr/local/etc/jffnms/docs/install/jffnms-0.9.3.mysql

We have created the JFF tables and required records.


Next step its to setup apache for the JFF management web page. I preffer to set the jffnms directory as the Root Document  because in this case its a dedicated box. If the Apache web server will host another virtual directories or virtual servers, set it up accordingly.

jff# vi /usr/local/etc/apache22/httpd.conf


Add/modify the following values: 

SetHandler application/x-httpd-php
SetHandler application/x-httpd-php-source

RewriteEngine On
RewriteRule (.*\.php)s$ $1 [H=application/x-httpd-php-source]

ServerAdmin admin@domain.local
ServerName jff.domain.local:80


#DocumentRoot "/usr/local/www/apache22/data"
DocumentRoot "/usr/local/etc/jffnms/htdocs"

AllowOverride None
Order deny,allow
Allow from all

DirectoryIndex index.php index.html


Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
Allow from all


Restart Apache web server

jff# apachectl restart


We are almost done..point your browser to the IP Address of your JFF Box  and will redirect you to the Setup page






























Replace the correct values on the ERROR fields and save the configuration

WE ARE DONE!!!  Go to the main screen and browse a little to be familiar with the tool. Next step its to add the network devices and servers. You will need to know the read_only snmo community and allow to read snmp information.





In another article I will show you how to add hosts and obtain graphics like the following




See you in another post.. 

























No comments: