Difference between revisions of "Netband Project - Ubuntu server"
m (→Perl Scripts) |
m (→External links) |
||
(8 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | + | =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: | ||
− | + | ==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/10.0.0.21.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 | ||
Line 63: | Line 61: | ||
*If snmpv3 is needed, install the net:snmp module | *If snmpv3 is needed, install the net:snmp module | ||
<pre>$aptitude install libnet-snmp-perl | <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> | </pre> | ||
===Make apache run perl script=== | ===Make apache run perl script=== | ||
Line 134: | Line 138: | ||
</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 15:23, 27 September 2011
Ubuntu Server
This page is part of the Netband Project
Contents
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