Showing posts with label Linux Administration. Show all posts
Showing posts with label Linux Administration. Show all posts

Thursday, October 1, 2015

Smokeping Configuration in Ubuntu 14.04

SmokePing is a deluxe latency measurement tool. It can measure, store and display latency, latency distribution and packet loss. SmokePing uses RRDtool to maintain a longterm data-store and to draw pretty graphs, giving up to the minute information on the state of each network connection. In this lab am going to show to configure smokeping to monitor latency for your network. Below are steps;


i. Prerequisite
This installation will require web service to be installed, for me am going to use Apache,but also it will need mail service for sending the email am going to use sendmail, run the following command to install web and mail service

$ sudo apt-get update
$ sudo apt-get install apache2
$ sudo apt-get install sendmail


ii. Install Smokeping

$ sudo -s
#
# apt-get install smokeping

For Ubuntu 14.04: you need to install a symlink to the apache2 config

# ln -s /etc/smokeping/apache2.conf /etc/apache2/conf-available/smokeping.conf
# a2enconf smokeping

Also, the CGI module needs to be enabled in Apache:
# a2enmod cgi

Finally, reload the Apache configuration:
# service apache2 reload

Then point your web browser at
http://X.X.X.X/smokeping/smokeping.cgi

where X.X.X.X is your server IP


iii. Initial Configuration

# cd /etc/smokeping/config.d
# ls -l
Output:
total 40K
drwxr-xr-x 2 root root 4.0K Oct  1 13:12 .
drwxr-xr-x 3 root root 4.0K Oct  1 13:12 ..
-rw-r--r-- 1 root root  177 Jan 28  2014 Alerts
-rw-r--r-- 1 root root  237 Jan 28  2014 Database
-rw-r--r-- 1 root root  489 Jan 28  2014 General
-rw-r--r-- 1 root root  225 Jan 28  2014 pathnames
-rw-r--r-- 1 root root  876 Jan 28  2014 Presentation
-rw-r--r-- 1 root root   50 Jan 28  2014 Probes
-rw-r--r-- 1 root root  147 Jan 28  2014 Slaves
-rw-r--r-- 1 root root  380 Jan 28  2014 Targets

The files that you'll need to change, at a minimum, are:
-Alerts
-General
-Probes
-Targets

a. Now open the General file with your favoirite editor (note the first capital letter)

# vim General

Change the following lines;

owner    = NOC
contact  = sysadmin@localhost
mailhost = localhost
cgiurl   = http://localhost/smokeping.cgi
# specify this to get syslog logging
syslogfacility = local5

Save the file and exit. Now let's restart the Smokeping service to verify that no mistakes have been made before going any further:

# service smokeping restart


b. Now open the Alerts file (note the first capital letter)
# vi Alerts
 
Change the following lines:

to = root@localhost
from = smokeping-alert@localhost

Save the file and exit. Restart Smokeping:

# service smokeping reload

Note: When you do some changes there is not need of restarting smokeping, just reload it for it to see configuration.


iv. Configuring monitoring of devices
For device configuration, most of configuration is done on
/etc/smokeping/config.d/Targets file.


As an example am going to configure some few devices where am going to have two groups Local devices and Public Servers,

# vi /etc/smokeping/config.d/Targets

Add the following to creates two groups:


+ LocalDevices
menu = LocalDevices
title = Local Network Devices

+ PublicServers
menu = PublicServers
title = PublicServers


Then add devices on those two groups :

+ LocalDevices
menu = LocalDevices
title = Local Network Devices

++MyGateway
menu = Gateway
title = Gateway
host = 192.168.0.1

++PrintServer
menu = PServer
title = PServer
host = 192.168.0.41

+ PublicServers
menu = PublicServers
title = PublicServers

++Google
menu = Google
title = Google
host = google.com

++Yahoo
menu = Yahoo
title = Yahoo
host = yahoo.com

++Facebook
menu = Facebook
title = Facebook
host = facebook.com



Finally the file will look like below:


*** Targets ***

probe = FPing

menu = Top
title = Network Latency Grapher
remark = Welcome to the SmokePing website of JARASYOLA Company. \
         Here you will learn all about the latency of our network.

+ Local
menu = Local
title = Local Network
#parents = owner:/Test/James location:/


#************************
# Local device monitoring
#************************

++ LocalMachine

menu = Local Machine
title = NOCServer
host = localhost
#alerts = someloss

+ LocalDevices
menu = LocalDevices
title = Local Network Devices

++MyGateway
menu = Gateway
title = Gateway
host = 192.168.0.1

++PrintServer
menu = PServer
title = PServer
host = 192.168.0.41


#**************************
#Public Server Monitoring
#**************************

+ PublicServers
menu = PublicServers
title = PublicServers

++Google
menu = Google
title = Google
host = google.com

++Yahoo
menu = Yahoo
title = Yahoo
host = yahoo.com

++Facebook
menu = Facebook
title = Facebook
host = facebook.com


OK. Let's see if we can get Smokeping to stop and start with the changes we have made, so far. Save and exit from the Targets file. Now try doing:

# service smokeping reload

If you see error messages, then read them closely and try to correct the problem in the Targets file. In addition, Smokeping is now sending log message to the file /var/log/syslog. You can view what Smokeping is saying by typing:

# tail /var/log/syslog

If you want to see all smokeping related messages in the file /var/log/syslog you can do this:

# grep smokeping /var/log/syslog

If there are no errors you can view the results of your changes by going to:

http://X.X.X.X/smokeping/smokeping.cgi

where X.X.X.X is your server IP


Your graph will look good as below;





From there you can add more devices and monitor their latency, i will explain more advanced features of smokeping on part two of this lab.

Happy monitoring.!!!



Saturday, September 12, 2015

How to Install GNS 1.3.10 in Ubuntu 14.04/Deepin 2014.3

Graphical Network Simulator-3 (GNS3) is a software emulator for networks, launched in 2008. It allows the combination of virtual devices and real devices, and so can be used to simulate complex networks. It uses Dynamips emulation software to simulate Cisco IOS.Below are steps of how to install it on Ubuntu/Deepin from official documentation found here , which i modified a bit to match with new version GNS 1.3.10

#Run apt-get update
➜  ~  sudo apt-get update

# - Install GNS3 Python dependencies
➜  ~  sudo apt-get install python3-setuptools python3-pyqt4 python3-ws4py python3-netifaces python3-crypto


#- Install Dynmips dependencies
➜  ~  sudo apt-get install cmake libelf-dev uuid-dev libpcap-dev

# - Download and unzip GNS3 Linux source files here
Migrade to your download directory and unzip the file

➜ unzip GNS3-1.3.10.source.zip
Results:
Archive:  GNS3-1.3.10.source.zip
 extracting: dynamips-0.2.14.zip  
 extracting: iouyap-0.95.zip      
 extracting: ubridge-0.9.0.zip    
 extracting: vpcs-0.6.1.zip        
 extracting: gns3-server-1.3.10.zip
 extracting: gns3-gui-1.3.10.zip

# - Build and Install Dynamips
➜  ~ unzip dynamips-0.2.14.zip
➜  ~ cd dynamips-0.2.14
➜  ~ mkdir build
➜  ~ cd build
➜  ~ cmake ..
➜  ~ make
➜  ~ sudo make install
➜  ~ sudo setcap cap_net_admin,cap_net_raw=ep /usr/local/bin/dynamips
➜  ~ cd ../..

# - Install GNS3 Server
➜ ~ unzip gns3-server-1.3.10.zip
➜ ~ cd gns3-server-1.3.10
➜ ~ sudo python3 setup.py install
➜ ~ cd ..

# - Install GNS3 GUI
➜ ~ unzip gns3-gui-1.3.10.zip
➜ ~ cd gns3-gui-1.3.10
➜ ~ sudo python3 setup.py install
➜ ~ cd ..

# - Install IOU dependencies
➜ ~ sudo apt-get install libssl1.0.0:i386
➜ ~ sudo ln -s /lib/i386-linux-gnu/libcrypto.so.1.0.0 /lib/libcrypto.so.4
➜ ~ sudo apt-get install bison
➜ ~ sudo apt-get install flex
➜ ~ git clone http://github.com/ndevilla/iniparser.git
➜ ~ cd iniparser
➜ ~ make
➜ ~ cd ..
➜ ~ sudo cp libiniparser.* /usr/lib/
➜ ~ cd iniparser
➜ ~ sudo cp libiniparser.* /usr/lib/
➜ ~ sudo cp src/iniparser.h /usr/local/include
➜ ~ sudo cp src/dictionary.h /usr/local/include
➜ ~ cd ..

# - Install GNS3 IOUYAP app (provides network support for IOU)
➜ ~ unzip iouyap-0.95.zip
➜ ~ cd iouyap-0.95
➜ ~ sudo make install
➜ ~ sudo cp iouyap /usr/local/bin
➜ ~ cd ..

# - Install VPCS
➜ ~ unzip vpcs-0.6.1.zip
➜ ~ cd vpcs-0.6.1/src
➜ ~./mk.sh
➜ ~ sudo cp vpcs /usr/local/bin
➜ ~ cd ../..

# - Install VirtualBox
➜ ~ sudo apt-get install virtualbox

# - Install Wireshark
➜ ~ sudo apt-get install wireshark

# - Install QEMU - method 1
$ sudo apt-get install qemu
# - Install QEMU - method 2 (x86 arch. only)
$ sudo apt-get install qemu-system-x86
$ sudo apt-get install qemu-utils

# - Install cpulimit
$ sudo apt-get install cpulimit

# - Start GNS3
➜ ~ gns3

Note:
Don't include ➜ ~ when copying the command as that is Deepin terminal prompt.


Enjoy!

Tuesday, July 28, 2015

Migrating Cacti from One Server to another (Ubuntu 12.04 to Ubuntu 14.04)

You may need to migrate cacti from one server to another due to one reason or another, i did this lab migration from ubuntu server 12.04 to 14.04, i use this HOW TO (http://lifein0and1.com/2008/05/15/migrating-cacti-from-one-server-to-another/), doing some few modification according to need. Below are steps

1. Install Cacti on the New Server
2. Turn Off Cacti at the Old Server
3. Migrate the Database
4. Copy the RRD Files as XML
5.Reconvert the XML back to RRD File
6. Activate the New Cacti


1.  Install Cacti on the New Server
a. Use the following link (http://www.unixmen.com/install-cacti-ubuntu-14-04/), after finishing installation on command line, don't go to browser until step 6 when activating the new cacti.

b. Turn-off the poller
Run the command

$ sudo vim /etc/cron.d/cacti

Disable the poller by putting the character ‘#’ in front of the crontab entry then save & quit


2. Turn Off Cacti at the Old Server
Run the command

$ sudo vim /etc/cron.d/cacti

Disable the poller by putting the character ‘#’ in front of the crontab entry then save & quit.


3. Migrate the Database
a. At the old server run the command

$ sudo mysqldump -u root  -p  cacti > ~/cacti.sql

When it asks for the password, enter the password for mysql database

b. SCP on the old data and grap the data and move it to new server.

c. On the server run the following
$ sudo mysql -u root -p cacti < ~/cacti.sql


4. Copy the RRD Files as XML
Do the following on the old server

a. Go to the directory
$ cd /var/lib/cacti/rra/

c. Run the script
$ sudo ls -1 *.rrd | awk '{print "rrdtool dump "$1" > "$1".xml"}' | sh -x

d. Tar and Gzip the XML files using the command
$ sudo tar -czvf ~/rrd.tgz *.rrd.xml


5.Reconvert the XML back to RRD File

a. SFTP into the old server and download the ‘rrd.tgz’ created in the step before

b. Move the file to the new directory
/var/lib/cacti/rra/

c. Untar the file
tar -xzvf rrd.tgz

d. Run the command
$ sudo ls -1 *.rrd.xml | sed 's/\.xml//' | awk '{print "rrdtool restore "$1".xml "$1}' | sh -x

e. Change ownership of all RRD files to www-data by running the command:
$ sudo chown www-data:www-data *.rrd


6. Activate the New Cacti

a. Visit the new site and set the mode to ‘Upgrade’
b. Reactivate the Poller

Run the command
$ sudo vi /etc/cron.d/cacti

Enable the poller by removing the character ‘#’ in front of the crontab entry then save & quit


Enjoy!