Difference between revisions of "Netband Project - Ubuntu server"

From Teknologisk videncenter
Jump to: navigation, search
m (External links)
 
(38 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__
 +
 +
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
 +
<pre>$ sudo aptitude install mrtg
 +
</pre>
 +
2. Create the initial config file and poll a device
 +
<pre>sudo cfgmaker  --output /home/mrtg/mrtg.cfg ciscodisco@10.0.0.21 [comunity@router/switch IP]
 +
</pre>
 +
 +
<pre># 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
 +
</pre>
 +
For more information see [http://oss.oetiker.ch/mrtg/doc/cfgmaker.en.html 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
 +
<pre>$ sudo env LANG=C /usr/bin/mrtg /home/mrtg/mrtg.cfg
 +
</pre>
 +
5. Make MRTG run every 5 minutes
 +
<pre>$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
 +
</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>
  
OS version:
+
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
  
=Applications:=
+
<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);
  
==FreeNac==
+
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>
  
==MRTG==
+
Remember to make it executable with chmod +x index.pl
 +
==External links==
 +
[http://freenac.net/ FreeNac]<br>
 +
[http://oss.oetiker.ch/mrtg/ MRTG]<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