Re: Re: Re: Re: Process exists - Segmentation fault

2008-01-14 Thread abhishek jain
Hi Gerald,
Sorry for a late reply ,
no make test did not worked correctly, it did tested the modperl part and
gave error like an error on line 21.
I will try to give the exact error later,
Thanks,
Abhishek jain


On 1/9/08, Gerald Richter - ECOS GmbH <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Maybe we should go one step back:
>
> Does "make test" works correctly for you?
>
> Does it also test the mod_perl part?
>
> Gerald
>
>
> > -Original Message-
> > From: abhishek jain [mailto:[EMAIL PROTECTED]
> > Sent: Monday, January 07, 2008 2:59 AM
> > To: Gerald Richter
> > Cc: modperl@perl.apache.org
> > Subject: Re: Re: Re: Process exists - Segmentation fault
> >
> > Hi Its me again,
> > But still the things are not working right.
> > I tried to recompile Embperl and put PerlModule Embperl after
> > LoadModule embperl_module ..
> >
> > Now i do not remember it was before or now but after i
> > uncomment the 'PerlModule Embperl' line and things stop
> > working i do not receieve $r=shift; variable i mean $r = undef here.
> > Is it due to something i did during installation of embperl.
> > Also If i uncomment the line 'MaxRequestsPerChild 1' and
> > comment 'PerlModule Embperl ' then i recveive this line in
> > error log [Sun Jan 06 18:44:11 2008] [notice] child pid 30280
> > exit signal Segmentation fault (11)
> >
> > (May be error and page refreshes itself i mean the code
> > produces output.)
> >
> > and page appears , sometimes the same error appears twice and
> > page does not appears.
> >
> > I am not sure have this error been encountered by someone
> > else but things are not working right for me . Also if
> > someone wants i can mail the Embperl logs to someone
> > individually, i do not want to make the logs public.
> > Pl help. I am working on the site http://delhi.pm.org/ it is
> > the delhi perl mongers site and people in this group have
> > limited knowledge of embperl but this will push up the
> > embperl in Delhi .
> > --
> > Thanks
> > Abhishek jain
> >
> >
> > On 1/4/08, Gerald Richter - ECOS GmbH <[EMAIL PROTECTED]> wrote:
> >
> >   Hi,
> >
> >   Not sure if it makes any difference, but the lines
> >
> >   LoadModule  embperl_module
> >
> > /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Em
> > bperl/Embp
> >   erl.so
> >   PerlModule Apache::DBI
> >   PerlModule Embperl
> >
> >   Should be outside of the VirtualHost block (they are
> > global anyway)
> >
> >   The other thing that you should make sure, is that
> > mod_perl is compiled
> >   with the same Perl that Embperl is and both are using
> > modules from the
> >   path /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
> >
> >   If there is any version mismatch, things cannot run correctly.
> >
> >   Gerald
> >
> >
> >   > -Original Message-
> >   > From: abhishek jain [mailto: [EMAIL PROTECTED]
> >   > Sent: Thursday, January 03, 2008 8:20 PM
> >   > To: Gerald Richter
> >   > Cc: modperl@perl.apache.org
> >   > Subject: Re: Re: Process exists - Segmentation fault
> >   >
> >   > Hi,
> >   > Adding PerlModule Embperl did not solved the problem , infact
> >   > it aggreviated it. With this the page is not didsplaye at all.
> >   > My apache configuration is:
> >   >
> >   > :80>
> >   > SuexecUserGroup "#" "#"
> >   > ServerName x
> >   > ServerAlias www.x
> >   > DocumentRoot 
> >   > ErrorLog /logs/error_log
> >   > CustomLog /logs/access_log combined
> >   > LoadModule  embperl_module
> >   > /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Em
> >   bperl/Embperl.so
> >   > PerlModule Apache::DBI
> >   > PerlModule Embperl
> >   > >
> >   > Options Indexes IncludesNOEXEC FollowSymLinks
> >   > allow from all
> >   > AllowOverride All
> >   >
> >   > $">
> >   > SetHandler  perl-script
> >   > PerlHandler Embperl::Object
> >   > Options ExecCGI
> >   > 
> >   >  
> >   > Order allow,deny
> >   > Deny From all
> >   > 
> >   >  
> >   > Order allow,deny
> >   > Deny From all
> >   > 
> >   >
> >   >
> >   > 
> >   > >
> >   > allow from all
> >   > 
> >   > PerlSetEnv EMBPERL_ESCMODE 0
> >   > PerlSetEnv EMBPERL_OPTIONS 16
> >   > PerlSetEnv EMBPERL_MAILHOST 
> >   > PerlSetEnv EMBPERL_OBJECT_BASE _base.epl
> >   > PerlSetEnv EMBPERL_OBJECT_FALLBACK
> > notfound.html
> >   > PerlSetEnv EMBPERL_DEBUG 0
> >   > PerlSetEnv EMBPERL_OBJECT_APP epwebapp.pl
> >   > 
> >  

RE: Printing for debugging

2008-01-14 Thread Raful Mr Mitchell H
Thanks!  Using the Apache2::RequestUtil and Apache2::Log, I can find out what 
my variables' values are to debug and check my code.

Mitch



Mitchell Raful MCSE CCNP
MCB Quantico
Personal and Family Readiness (MRI)
3044 Catlin Avenue
Quantico, VA 22134
Com: 703-784-5991
DSN: 278-5991
Cell: 804-363-0731


-Original Message-
From: Colin Wetherbee [mailto:[EMAIL PROTECTED]
Sent: Monday, January 14, 2008 11:08 AM
To: Raful Mr Mitchell H
Cc: Modperl (E-mail)
Subject: Re: Printing for debugging


Raful Mr Mitchell H wrote:
> I have my code pasted below.  My module, loaded with  
> directive in Apache2, works well.  However, sometimes switches don't 
> respond correctly to bulk queries of fdbPorts object.  What I want to do 
> is to be able print the value of my variables either to the browser or a 
> log file.  A regular print statement does not work for this.  The 
> relevant variables are in a subroutine called from my sub handler.

I'm not entirely sure where, in those lines of unindented HTML, you're 
trying to perform your logging.  The only thing I could find quickly was 
the following code, but I can't be certain that's the subject of your 
question.

if( $arp_session->{ErrorNum} ){ print "Got $arp_session->{ErrorStr} for 
$router\n"; }

In order to print log messages to Apache's (or your virtual host's) 
error log, you can use the following.

use Apache2::RequestUtil;
use Apache2::Log;

Apache2::RequestUtil->request->log->error('some_text');

Substituting other log levels (debug, info, warn, etc.) works, as well. 
  See the following URL for more information.

http://perl.apache.org/docs/2.0/api/Apache2/Log.html#LogLevel_Methods

If this isn't what you're seeking, perhaps you could include a more 
concise test case and a more elaborate explanation in your next post?

Colin



Re: Refreshing stored data at administrator's signal

2008-01-14 Thread Colin Wetherbee

Clinton Gormley wrote:
I'm not sure what you're suggesting.  The first few pages of "cache" on 
CPAN have some modules for caching data in memory and on disk and so 
forth, but I don't see how they relate to my problem.


Which is that of notifying all of my application's perl processes when 
an update has been performed on a table in a database, without having 
them access the database to determine this on their own.


My personal favourite is Cache::Memcached, but that's only relevant if
you have more than one web server.  If not, the file based caches are
the fastest (or you could try looking at SQLite or Cache::BerkleyDB or
even a memory table in MySQL, but on a different DB server)


Memcached sounds like a good idea.  I could cache the update timestamps 
and compare them on each run.


I guess I wasn't thinking about "cache" the right way around.

Thanks!

Colin


Re: Refreshing stored data at administrator's signal

2008-01-14 Thread Clinton Gormley

> I'm not sure what you're suggesting.  The first few pages of "cache" on 
> CPAN have some modules for caching data in memory and on disk and so 
> forth, but I don't see how they relate to my problem.
> 
> Which is that of notifying all of my application's perl processes when 
> an update has been performed on a table in a database, without having 
> them access the database to determine this on their own.

There are two ways of achieving your task:
 - active: forcing all the apache processes to update their list of 
   aircraft
 - passive: having each apache child check on whether the copy of the 
   list they already have is still up to date

By far the simplest way of achieving the first option is by having the
parent load and cache the list (which means that memory is shared by all
the child processes) and restarting your apache processes when the list
changes.

For the passive route, each apache child has to perform some kind of
check to see whether their version is up to date.  This requires some
kind of check somewhere, eg:
 - checking the last modified time of a file
 - loading the list from a cache 
 - loading the list from the database

Your intention is to reduce the number of database hits.  That's fine,
but it needs to be weighed against the cost of inflexibility, or the
cost of checking and rebuilding the cache.

For data that almost never changes, I would go the active route.

For data that changes more regularly, but has a certain time-to-live, I
would go the caching route.  For data that changes by the second, get it
directly from the DB.

So searching for 'cache' on CPAN, indeed gives you a number of very
useful modules that ease your path to reducing the number of DB hits
that you have.

My personal favourite is Cache::Memcached, but that's only relevant if
you have more than one web server.  If not, the file based caches are
the fastest (or you could try looking at SQLite or Cache::BerkleyDB or
even a memory table in MySQL, but on a different DB server)

regards

Clint


> 
> Thanks.
> 
> Colin
> 



Re: Refreshing stored data at administrator's signal

2008-01-14 Thread Colin Wetherbee

Scott Gifford wrote:

Colin Wetherbee <[EMAIL PROTECTED]> writes:

[...]


At the moment (and not in a production environment), every time the
drop-down list is generated for a web page, the script queries the
database to retrieve the entire list of aircraft.  I would prefer to
retrieve the list of aircraft when each Perl interpreter starts and
then not retrieve it again until the administrator sends a signal.
For this particular table, the signal would only occur when new
aircraft hit the market, like the Boeing 787 will (hopefully) in
December of this year.


Essentially what you want is an in-memory cache of a possibly slow
database query.  There are several modules on CPAN that do this;
search for "cache".


I'm not sure what you're suggesting.  The first few pages of "cache" on 
CPAN have some modules for caching data in memory and on disk and so 
forth, but I don't see how they relate to my problem.


Which is that of notifying all of my application's perl processes when 
an update has been performed on a table in a database, without having 
them access the database to determine this on their own.


Thanks.

Colin



Re: Printing for debugging

2008-01-14 Thread Colin Wetherbee

Raful Mr Mitchell H wrote:
I have my code pasted below.  My module, loaded with  
directive in Apache2, works well.  However, sometimes switches don't 
respond correctly to bulk queries of fdbPorts object.  What I want to do 
is to be able print the value of my variables either to the browser or a 
log file.  A regular print statement does not work for this.  The 
relevant variables are in a subroutine called from my sub handler.


I'm not entirely sure where, in those lines of unindented HTML, you're 
trying to perform your logging.  The only thing I could find quickly was 
the following code, but I can't be certain that's the subject of your 
question.


if( $arp_session->{ErrorNum} ){ print "Got $arp_session->{ErrorStr} for 
$router\n"; }


In order to print log messages to Apache's (or your virtual host's) 
error log, you can use the following.


use Apache2::RequestUtil;
use Apache2::Log;

Apache2::RequestUtil->request->log->error('some_text');

Substituting other log levels (debug, info, warn, etc.) works, as well. 
 See the following URL for more information.


http://perl.apache.org/docs/2.0/api/Apache2/Log.html#LogLevel_Methods

If this isn't what you're seeking, perhaps you could include a more 
concise test case and a more elaborate explanation in your next post?


Colin



Printing for debugging

2008-01-14 Thread Raful Mr Mitchell H
I have my code pasted below.  My module, loaded with  directive in 
Apache2, works well.  However, sometimes switches don't respond correctly to 
bulk queries of fdbPorts object.  What I want to do is to be able print the 
value of my variables either to the browser or a log file.  A regular print 
statement does not work for this.  The relevant variables are in a subroutine 
called from my sub handler.
 
Thanks in advance.
 

#!/usr/bin/perl -w

package Handlers::PortMapper;

use warnings;

use strict;

use HTML::Template;

use DBI;

use Socket qw(:DEFAULT :crlf);

use dec_hex;

use snmpSession;

use SNMP;

use Net::NBName;

use Net::Ping;

use Apache2::Request ();

use Apache2::Const -compile=>'OK';

 

# %seen_vlans --tracks those vlans which are seen as each ports vlan membership 
is looked at 

# %device --all results for each device found on a switch are placed here for 
dispatching to a web page

# @answer;

my @switch_row; #--hold results of db query for switch

my @router_row; #--hold results of db query for router whose arp cache you want

my %devices_ref;

my %hash;

my $time; # --gets time query began

my $chosen_switch; #--switch passed via http form data

my $chosen_router; #--switch passed via http form data

my $switch_ip; #--result one for initial query

my $switch_model; #--result two for initial query

my $devices_ref;

my $router_ip; # --result for query of router address

my $dbh; #--database handle

my $sql; #--database query

my @loop_data; #--hold hashes for my template

# $i = 0 --counters

# $j = 0 --counters

sub handler {

my $r = shift;

my $req = Apache2::Request->new( $r );

$r->content_type('text/html'); 

my %mac_data;

my @mac_array; #hold individual hex digits returned by ipNetToMediaPhysAddress

my @loop_data = (); #array of anonymous hashes which is dispatched to web page 
for display

my $template = HTML::Template->new( filename => 
'/home/mitch/www-dev/mod_perl/templates/portmapper.tmpl',

debug => 1,

die_on_bad_params => 0 );

my $time = localtime();

$chosen_switch = $req->param('chosen_switch');

$chosen_switch =~ s/(\s.*)//g;

$chosen_router = $req->param( 'chosen_router' );

$dbh = DBI->connect( 'dbi:ODBC:MRIServer2k', 'mriinventory', '[EMAIL 
PROTECTED]',

{ PrintError => 1, RaiseError => 0, AutoCommit => 1 } );

$sql = "SELECT address, chassis_description FROM tblLiveCisco WHERE 
name='$chosen_switch'";

@switch_row = $dbh->selectrow_array( $sql );

$switch_ip = $switch_row[0];

$switch_model = $switch_row[1];

@router_row = $dbh->selectrow_array("SELECT address FROM tblLiveCisco WHERE 
name='$chosen_router'" );

$router_ip = $router_row[0];

$devices_ref = getDevices( $router_ip, $switch_ip, 'public');

foreach $_ (@{$devices_ref}) {

%hash = %$_;

push @loop_data, \%hash ;

}

$template->param(CHOSEN_SWITCH => $chosen_switch );

$template->param(MODEL => $switch_model );

$template->param(TIME => $time );

$template->param(LOOP_DATA => [EMAIL PROTECTED] );

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

print $template->output;

return Apache2::Const::OK;

}

sub getDevices {

my $router = shift;

my $switch = shift;

my $community = shift;

my @mac_array = ();

my %seen_vlans = ();

my %ifnames; #holds the ifIndex number and names of ports

my %trunk; #holds all ports on a switch that are trunking

my %arpCache;

my @data;

my @vlans; #all vlans found using vmVlan object

my $arp_mib = 'ipNetToMediaPhysAddress';

my ( $mac_address,$ip, $dns_name, $device_type );

my $arp_session = snmpSession::openSession( $router , $community, 1 );

my $vb_arp = new SNMP::Varbind( [$arp_mib] );

for(my $var = $arp_session->getnext( $vb_arp );

( $vb_arp->tag eq $arp_mib ) and not ( $arp_session->{ErrorNum} );

$var = $arp_session->getnext( $vb_arp )

) {

my $ip_addr = ( $vb_arp->tag . $vb_arp->iid );

$ip_addr =~ s/$arp_mib\d+\.//g;

my @vars = split(/:/, $var );

for( my $x = 0; $x < scalar( @vars ); $x++ ) {

if( length( $vars[$x] ) < 2 )

{

$vars[$x] = "0"."$vars[$x]";

}

push( @mac_array, $vars[$x] );

}

my $arp_mac_address = join( "", @mac_array );

push( @{$arpCache{$arp_mac_address}}, $ip_addr );

@mac_array = ();

}

if( $arp_session->{ErrorNum} ){ print "Got $arp_session->{ErrorStr} for 
$router\n"; }

my $vlan_session = snmpSession::openSession ( $switch, $community, 1 );

my $vb_vlan = new SNMP::VarList( ['vmVlan'], ['ifName'], 
['vlanTrunkPortDynamicStatus'] );

my @answers1 = $vlan_session->bulkwalk(0, 100, $vb_vlan );

if( $vlan_session->{ErrorNum} ) {

print "Got ", $vlan_session->{ErrorStr}, "on", $vlan_session->{DestHost}, " 
during Bulkwalk\n";

}

my $vlan_answer = $answers1[0];

my $ifName_answer = $answers1[1];

my $trunk_ports = $answers1[2];

for( my $i = 0; $i < scalar(@$vlan_answer); $i++ )

{

my $vlan = $vlan_answer->[$i]->[ 2];

if ( !exists ($seen_vlans{$vlan} ) ) {

push( @vlans, $vlan );

$seen_vlans{$vlan} = 1;

}

}

for( my $j = 0; $j < scalar(@$ifName_answer); $j++ )

{

my $index = $ifName_answer->[$j]->[1];

my $interface_name = $ifName_answ

Re: loading Apache2::ServerRec

2008-01-14 Thread Carl Johnstone
Using the debian-stable-provided version of mod_perl, I've got an app 
that's

working fine however the way it was configured meant we were causing an
early load of perl during the configuration phase of apache.


Just curious -- why are you trying to avoid loading perl during this 
phase?


Faster restarts in our development environment.

perl gets loaded twice, once to test the config then again to actually 
start. From my observations apache even does this if you run apachectl stop!


We don't need the additional test in config as any problems will appear in 
the error log and the devs can check there.


Carl



AP2.2.7 + MP2.0.3 on Win32

2008-01-14 Thread Foo JH

Hi all,

Just want to slap a quick note that I've tried the following combo on 
Win32 platform (Windows 2003 Server x86):

Apache 2.2.7 from ApacheLounge (apachelounge.com)
modperl 2.0.3 from theoryx5 (ppd)
libapreq 2.6.2 from theoryx5 (ppd)
Perl 5.8.8 (ActivePerl build 822)

The only thing I'm interested (the rest I take for granted) is that it 
survives a restart from the ApacheMonitor app. Had painful issues with 
past versions, so this is always my priority. I know Linuxians take it 
for granted...