Difference between revisions of "Netband Project - Ubuntu server"

From Teknologisk videncenter
Jump to: navigation, search
(MRTG)
m (External links)
 
(22 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<accesscontrol>NetBand</accesscontrol>
+
=Ubuntu Server=
 +
 
 
This page is part of the [[Netband_Project|Netband Project]]  
 
This page is part of the [[Netband_Project|Netband Project]]  
 
__TOC__
 
__TOC__
Line 5: Line 6:
 
OS version:  
 
OS version:  
  
=Applications:=
+
==FreeNac(Incomplete)==
 
 
 
 
==FreeNac==
 
  
 
* Dynamic Virtual LAN management and assignment per end-device
 
* Dynamic Virtual LAN management and assignment per end-device
Line 21: Line 19:
 
</pre>
 
</pre>
 
2. Create the initial config file and poll a device
 
2. Create the initial config file and poll a device
<pre>sudo cfgmaker  --output /home/mrtg/mrtg.cfg ciscodisco@10.0.0.21
+
<pre>sudo cfgmaker  --output /home/mrtg/mrtg.cfg ciscodisco@10.0.0.21 [comunity@router/switch IP]
 
</pre>
 
</pre>
  
 
<pre># Created by  
 
<pre># Created by  
# /usr/bin/cfgmaker --output /home/mrtg/mrtg.cfg ciscodisco@10.0.0.21
+
# /usr/bin/cfgmaker --output /home/mrtg/10.0.0.21.cfg ciscodisco@10.0.0.21 [comunity@router/switch IP]
  
  
Line 42: Line 40:
  
 
#  to get bits instead of bytes and graphs growing to the right
 
#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits
+
# Options[_]: growright, bits, unknaszero
  
 
EnableIPv6: no
 
EnableIPv6: no
  
######################################################################
+
Include: /home/mrtg/10.0.0.21.cfg
# System: B1rt1.domain.netband.dk
 
# Description: Cisco IOS Software, 2801 Software (C2801-ADVIPSERVICESK9-M), Version 12.4(9)T, RELEASE SOFTWARE (fc1)
 
#          Technical Support: http://www.cisco.com/techsupport
 
#          Copyright (c) 1986-2006 by Cisco Systems, Inc.
 
#          Compiled Sat 17-Jun-06 00:19 by prod_rel_team
 
# Contact:
 
# Location:
 
######################################################################
 
 
 
 
 
### Interface 1 >> Descr: 'FastEthernet0/0' | Name: 'Fa0/0' | Ip: '192.168.1.4' | Eth: '00-1b-d4-0f-8c-a2' ###
 
 
 
Target[10.0.0.21_Fa0_0]: #Fa0/0:ciscodisco@10.0.0.21:
 
SetEnv[10.0.0.21_Fa0_0]: MRTG_INT_IP="192.168.1.4" MRTG_INT_DESCR="FastEthernet0/0"
 
MaxBytes[10.0.0.21_Fa0_0]: 12500000
 
Title[10.0.0.21_Fa0_0]: Traffic Analysis for Fa0/0 -- B1rt1.domain.netband.dk
 
PageTop[10.0.0.21_Fa0_0]: <h1>Traffic Analysis for Fa0/0 -- B1rt1.domain.netband.dk</h1>
 
<div id="sysdetails">
 
<table>
 
<tr>
 
<td>System:</td>
 
<td>B1rt1.domain.netband.dk in </td>
 
</tr>
 
<tr>
 
<td>Maintainer:</td>
 
<td></td>
 
</tr>
 
<tr>
 
<td>Description:</td>
 
<td>FastEthernet0/0  </td>
 
</tr>
 
<tr>
 
<td>ifType:</td>
 
<td>ethernetCsmacd (6)</td>
 
</tr>
 
<tr>
 
<td>ifName:</td>
 
<td>Fa0/0</td>
 
</tr>
 
<tr>
 
<td>Max Speed:</td>
 
<td>12.5 MBytes/s</td>
 
</tr>
 
<tr>
 
<td>Ip:</td>
 
<td>192.168.1.4 ()</td>
 
</tr>
 
</table>
 
</div>
 
 
 
 
 
 
</pre>
 
</pre>
 
For more information see [http://oss.oetiker.ch/mrtg/doc/cfgmaker.en.html cfgmaker]
 
For more information see [http://oss.oetiker.ch/mrtg/doc/cfgmaker.en.html cfgmaker]
Line 107: Line 54:
 
</pre>
 
</pre>
 
5. Make MRTG run every 5 minutes
 
5. Make MRTG run every 5 minutes
<pre>$crontab  -e
+
<pre>$sudo crontab  -e
  
 
#        m      h      dom    mon    dow    command
 
#        m      h      dom    mon    dow    command
 
         */5      *      *      *      *      env LANG=C /usr/bin/mrtg /home/mrtg/mrtg.cfg  --logging /var/log/mrtg/mrtg.log
 
         */5      *      *      *      *      env LANG=C /usr/bin/mrtg /home/mrtg/mrtg.cfg  --logging /var/log/mrtg/mrtg.log
 +
</pre>
 +
*If snmpv3 is needed, install the net:snmp module
 +
<pre>$aptitude install libnet-snmp-perl
 +
</pre>
 +
*If you want automatic index genereation with indexmaker
 +
<pre>$sudo crontab  -e
 +
 +
#        m      h      dom    mon    dow    command
 +
*/5      *      *      *      *      /usr/bin/indexmaker /home/mrtg/mrtg.cfg > /var/www/mrtg/index.html
 +
</pre>
 +
===Make apache run perl script===
 +
This will install the perl module in apache
 +
<pre>
 +
$ sudo aptitude install libapache2-mod-perl2
 +
</pre>
 +
 +
This addition in /etc/apache2/apache2.conf configuration file will allow cgi and perl script to be run in every directory, not just cgi-bin/.
 +
<pre>
 +
AddHandler cgi-script .cgi .pl
 +
 +
<Files ~ "\.pl$">
 +
Options +ExecCGI
 +
</Files>
 +
<Files ~ "\.cgi$">
 +
Options +ExecCGI
 +
</Files>
 +
</pre>
 +
 +
===Perl Scripts===
 +
If you want a index page to show all the mrtg graphs in one page create a new textfile and name it index.pl in your mrtg root folder.
 +
The indexfile should look like this
 +
<pre>#!/usr/bin/perl -w
 +
#############################################
 +
# This script is created by Rasmus Elmholt  #
 +
#############################################
 +
use strict;
 +
use CGI::Carp qw(fatalsToBrowser);
 +
 +
print "Content-type: text/html\n\n";
 +
 +
print '<?xml version="1.0" encoding="iso-8859-1"?>' , "\n";
 +
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"' , "\n";
 +
print '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' , "\n";
 +
print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da">' , "\n";
 +
print "<head><title>MRTG Network Monitoring</title></head><body>\n";
 +
 +
 +
open(MRTGFILE, "/home/mrtg/mrtg.cfg");
 +
 +
while(my $line = <MRTGFILE>)
 +
{
 +
if($line =~ /^Include:/)
 +
{
 +
  $line =~ /^Include:\s(.*)/;
 +
  open(MRTGFILE1, $1);
 +
  #print "Found Include file";
 +
  while(my $line1 = <MRTGFILE1>)
 +
  {
 +
  #print "line in Include: $line1<br>";
 +
  if($line1 =~ /^PageTop/)
 +
  {
 +
    $line1 =~ /^PageTop\[(.*)\]:\s(.*)/;
 +
    my $url = lc($1);
 +
    print "<a href=\"$url.html\">$2</a><img src=\"$url-day.png\" /><img src=\"$url-week.png\" /><br /><br />";
 +
  }
 +
  }
 +
}
 +
if($line =~ /^PageTop/)
 +
{
 +
  $line =~ /^PageTop\[(.*)\]:\s(.*)/;
 +
  my $url = lc($1);
 +
  print "<a href=\"$url.html\">$2</a><img src=\"$url-day.png\" /><img src=\"$url-week.png\" /><br /><br />";
 +
}
 +
}
 +
close(MRTGFILE);
 +
 +
 +
print "</body></html>\n";
 
</pre>
 
</pre>
  
 +
Remember to make it executable with chmod +x index.pl
 
==External links==
 
==External links==
 
[http://freenac.net/ FreeNac]<br>
 
[http://freenac.net/ FreeNac]<br>
 
[http://oss.oetiker.ch/mrtg/ MRTG]<br>
 
[http://oss.oetiker.ch/mrtg/ MRTG]<br>
 
[http://oss.oetiker.ch/rrdtool/ RDDTool]<br>
 
[http://oss.oetiker.ch/rrdtool/ RDDTool]<br>
 +
[https://help.ubuntu.com/10.04/serverguide/C/serverguide.pdf Ubuntu Server Guide]
 +
[[Category:network]][[Category:CCNP]][[category:students]][[Category:Linux]][[Category:Network Management]]

Latest revision as of 16:23, 27 September 2011

Ubuntu Server

This page is part of the Netband Project

OS version:

FreeNac(Incomplete)

  • Dynamic Virtual LAN management and assignment per end-device
  • LAN Access control (authentication, authorization)

MRTG

  • Network monitoring

1. Install the MRTG package

$ sudo aptitude install mrtg

2. Create the initial config file and poll a device

sudo cfgmaker  --output /home/mrtg/mrtg.cfg ciscodisco@10.0.0.21 [comunity@router/switch IP]
# Created by 
# /usr/bin/cfgmaker --output /home/mrtg/10.0.0.21.cfg ciscodisco@10.0.0.21 [comunity@router/switch IP]


### Global Config Options

#  for UNIX
# WorkDir: /home/http/mrtg

#  for Debian
WorkDir: /var/www/mrtg

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits, unknaszero

EnableIPv6: no

Include: /home/mrtg/10.0.0.21.cfg

For more information see cfgmaker

3. Either create additional cfg files for other devices, and copy/paste the relevant parts to the mrtg.cfg file or add them manually

4. Start MRTG

$ sudo env LANG=C /usr/bin/mrtg /home/mrtg/mrtg.cfg

5. Make MRTG run every 5 minutes

$sudo crontab  -e

#        m      h       dom     mon     dow     command
         */5      *       *       *       *       env LANG=C /usr/bin/mrtg /home/mrtg/mrtg.cfg  --logging /var/log/mrtg/mrtg.log
  • If snmpv3 is needed, install the net:snmp module
$aptitude install libnet-snmp-perl
  • If you want automatic index genereation with indexmaker
$sudo crontab  -e

#        m      h       dom     mon     dow     command
*/5      *       *       *       *       /usr/bin/indexmaker /home/mrtg/mrtg.cfg > /var/www/mrtg/index.html

Make apache run perl script

This will install the perl module in apache

$ sudo aptitude install libapache2-mod-perl2

This addition in /etc/apache2/apache2.conf configuration file will allow cgi and perl script to be run in every directory, not just cgi-bin/.

AddHandler cgi-script .cgi .pl

<Files ~ "\.pl$">
Options +ExecCGI
</Files>
<Files ~ "\.cgi$">
Options +ExecCGI
</Files>

Perl Scripts

If you want a index page to show all the mrtg graphs in one page create a new textfile and name it index.pl in your mrtg root folder. The indexfile should look like this

#!/usr/bin/perl -w 
#############################################
# This script is created by Rasmus Elmholt  #
#############################################
use strict; 
use CGI::Carp qw(fatalsToBrowser); 

print "Content-type: text/html\n\n"; 

print '<?xml version="1.0" encoding="iso-8859-1"?>' , "\n"; 
print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"' , "\n"; 
print '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' , "\n"; 
print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da">' , "\n"; 
print "<head><title>MRTG Network Monitoring</title></head><body>\n"; 


open(MRTGFILE, "/home/mrtg/mrtg.cfg");

while(my $line = <MRTGFILE>)
{
 if($line =~ /^Include:/)
 {
  $line =~ /^Include:\s(.*)/;
  open(MRTGFILE1, $1);
  #print "Found Include file";
  while(my $line1 = <MRTGFILE1>)
  {
   #print "line in Include: $line1<br>";
   if($line1 =~ /^PageTop/)
   {
    $line1 =~ /^PageTop\[(.*)\]:\s(.*)/;
    my $url = lc($1);
    print "<a href=\"$url.html\">$2</a><img src=\"$url-day.png\" /><img src=\"$url-week.png\" /><br /><br />";
   }
  }
 }
 if($line =~ /^PageTop/)
 {
  $line =~ /^PageTop\[(.*)\]:\s(.*)/;
  my $url = lc($1);
  print "<a href=\"$url.html\">$2</a><img src=\"$url-day.png\" /><img src=\"$url-week.png\" /><br /><br />";
 }
}
close(MRTGFILE);
 

print "</body></html>\n";

Remember to make it executable with chmod +x index.pl

External links

FreeNac
MRTG
RDDTool
Ubuntu Server Guide