Other stuff...

Step-by-step guide: SwitchMap under CactiEZ

René Jorissen on December 1, 2009 8 Comments • Tags: #cactiez #findofficepl #guide #howto #searchportlistshtml #step #stepbystep #switchmap #thissitepm

Switchmap is a Perl program that creates HTML pages that show information about a set of Cisco Ethernet switches. It uses SNMP to gather data from the switches. Normally I install Switchmap in conjunction with CactiEZ and every time I am struggling to get Switchmap to work perfectly.

During another installation I wrote this step-by-step guide to configure switchmap correctly. This step-by-step guide is based on switchmap version 11.19. At first you have to download switchmap, extract it to the /var/www/html directory and rename the folder.

tar zxvf switchmap-11.19.tar.gz
mv switchmap-11.19 switchmap

Switchmap depends on multiple Perl modules, so install the necessary modules.

perl -MCPAN -e shell
install Log::Log4perl
install Module::Build
install Net::SNMP
install Log::Dispatch::Screen

Make sure your routers and Catalyst switches are configured to speak SNMP.

snmp-server community read4switchmap RO

Now you have to define your site-specific variables in ThisSite.pm. I changed the following parameters.

@routers = ();
push @routers, ‘10.62.4.2’;

@LocalSwitches = ();
push @LocalSwitches, ‘10.62.4.2’;

$Community = ‘read4switchmap’;

$DnsDomain = ‘.booches.nl’;

$DestinationDirectory = ‘/var/www/html/switchmap’;

$DestinationDirectoryRoot = ‘/switchmap’;

$StateFileDirectory = ‘/var/www/html/switchmap’;

Change the configfile variable in index.php to the following:

$configfile=’/var/www/html/switchmap/ThisSite.pm’;

Switchmap has the option to search for IP addresses and MAC addresses, but you have to alter the configuration to get this functionality working. First change the following in FindOffice.pl.

use lib ‘/var/www/html/switchmap’;

Change the configuration of the web server to allow it to run CGI files from the switchmap directory. I added the following lines above the existing ScriptAlias in /etc/httpd/conf/httpd.conf.

ScriptAlias /cgi/ “/var/www/html/switchmap/”

<Directory “/var/www/html/switchmap”>
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Edit SearchPortLists.html and change the following lines.

<link href=”/switchmap/SwitchMap.css” rel=”stylesheet”>

<form method=GET action=”/cgi/FindOffice.pl”>

Change the rights on the files FindOffice.pl and ThisSite.pm

chmod 777 FindOffice.pl
chmod 777 ThisSite.pm

Now you can test run your installation by executing the following 3 commands:

perl GetArp.pl
perl ScanSwitch.pl
perl SwitchMap.pl

When the commands are executed you can point your browser to:

http://<cacti-url>/switchmap/index.html

and you should have a working Switchmap configuration.

The last step is configuring a cron job to schedule switchmap. Change the cron configuration using the command

crontab –e

and add the following lines.

44 * * * * perl /var/www/html/switchmap/ScanSwitch.pl
49 * * * * perl /var/www/html/switchmap/GetArp.pl
05 14 * * * perl /var/www/html/switchmap/SwitchMap.pl

You are good to go!! I hope this step-by-step guides makes my life (and hopefully also your life) a bit easier when installing a new Switchmap under CactiEZ.

The following two tabs change content below.

René Jorissen

Co-owner and Solution Specialist at 4IP Solutions
René Jorissen works as Solution Specialist for 4IP in the Netherlands. Network Infrastructures are the primary focus. René works with equipment of multiple vendors, like Cisco, Aruba Networks, FortiNet, HP Networking, Juniper Networks, RSA SecurID, AeroHive, Microsoft and many more. René is Aruba Certified Edge Expert (ACEX #26), Aruba Certified Mobility Expert (ACMX #438), Aruba Certified ClearPass Expert (ACCX #725), Aruba Certified Design Expert (ACDX #760), CCNP R&S, FCNSP and Certified Ethical Hacker (CEF) certified. You can follow René on Twitter and LinkedIn.

Latest posts by René Jorissen (see all)

  1. Perl says:

    Hai,

    I tried the step by step for Switchmap and working fine.
    Thanks for your help.
    Only thing searchportlist is not working.
    I get the error message

    Not Found

    The requested URL /cgi/FindOffice.pl was not found on this server

    Can you please help me to resolve this.

  2. Bas says:

    Very nice Step-by-step guide!

    When you change the file switchmap/SearchPortlists.html
    from:

    To:

    the portsearch function works fine.

  3. Perl says:

    Hai,

    What I should do in

    from:
    To:

    in Searchportlists.html

  4. Bas wanted to tell that the following needs to be changes:

    from: “/cgi/FindOffice.pl”

    to: “/cgi-bin/FindOffice.pl”

  5. Perl says:

    Hai,

    Logged in throu webmin and cgi programes then Regexp CGI directory aliases there I have added this from to.
    Working fine.Since I am very new to this difficult for me to identify this location.
    Thanks a lot.

  6. Roma says:

    Hi,

    The file SearchPortlists.html is not generated, can you please tell me what am I missing?

    Thanks.

  7. visit here says:

    I don’t leave many remarks, but i did a few searching and wound up here Step-by-step guide: SwitchMap under CactiEZ | Booches.nl. And I actually do have some questions for you if it’s allright. Is it just me or does it look like some of the responses look like written by brain dead visitors? :-P And, if you are writing at additional social sites, I would like to follow anything new you have to post. Would you make a list of all of all your shared pages like your twitter feed, Facebook page or linkedin profile?

  8. Alex says:

    I noticed an error when installing the perl modules “Log::Dispatch::Screen” and “Log::Log4perl” this resulted in an error running the command “perl GetArp.pl”

    When u do a forced install of de modules “perl GetArp” seems to work and the result seems ok.

    The only thing i found is that the command ” perl SwitchMap.pl” will result in :
    “Use of uninitialized value in numeric gt (>) at /var/www/html/switchmap/SwitchUtils.pm line 747.”

    i’m going to sort this out sometime later. but for now it works.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.