plainblack.com
Username Password
search
Bookmark and Share

Asset Checker Diagnostic Tool

This script allows you to look for broken assets as well as performance hogging assets in your site. For example, you might want to find out if some poorly performing SQL Reports are hindering site performance.

perl classLoadTester.pl --conf=www.example.com.conf --class=WebGUI::Asset::Wobject::SQLReport

 

System Requirements

Please be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.

Release Notes for Version 1 (11/10/2008)

 

Comments
3elnino: "
what versions does this work with?
"
3JT: "
It's tested with 7.4, but should work with any 7.x version.
"
0ehab: "better run with /data/wre/prereqs/bin/perl classLoadTester.pl --conf=www.example.com.conf --class=WebGUI::Asset::Wobject::SQLReport"
0ehab: "Getting the following error when using this on 7.5

hiWx_jdCbWXmVwaqBz4RIgWide character in print at /data/WebGUI/lib/WebGUI/Session                                                          /Output.pm line 94.
Wide character in print at /data/WebGUI/lib/WebGUI/Session/Output.pm line 94.
Wide character in print at /data/WebGUI/lib/WebGUI/Session/Output.pm line 94.
                   0.0136            0.2603
hjhNzme21VcAMKRAjbCnawWide character in print at /data/WebGUI/lib/WebGUI/Session                                                          /Output.pm line 94.
Wide character in print at /data/WebGUI/lib/WebGUI/Session/Output.pm line 94.
Wide character in print at /data/WebGUI/lib/WebGUI/Session/Output.pm line 94.
                   0.0072            0.0654
hqQVV3unO0a9B9dCKawQzwWide character in print at /data/WebGUI/lib/WebGUI/Sessio                                                           /Output.pm line 94.
Wide character in print at /data/WebGUI/lib/WebGUI/Session/Output.pm line 94.
Wide character in print at /data/WebGUI/lib/WebGUI/Session/Output.pm line 94.
Wide character in print at /data/WebGUI/lib/WebGUI/Session/Output.pm line 94.
                   0.0018            0.0260"
0ehab: "We patched the file to not show the above error and show the URL of the asset. below is the new code"
0ehab: "use lib "/data/WebGUI/lib";
use strict;
use Getopt::Long;
use WebGUI::Session;
use Time::HiRes;
my $class;

my $session = start();

unless ($class) {
   print "Usage: perl $0 --config=www.example.com.conf --class=WebGUI::Asset::Wobject::SQLReport";
   exit;
}

open(my $null, ">:utf8","/dev/null");
$session->output->setHandle($null);

printf "%22s\t\%18s\t%12s\t%s\n", 'Asset ID', 'Instanciate Time', 'Render Time','URL';

my $count = 0;
my $sth = $session->db->read("select assetId from asset where className=? and state='published'",[$class]);
while (my ($id) = $sth->array) {
   $count++;
   print $id;

   # check instanciation time
   my $t = [Time::HiRes::gettimeofday];
   my $asset = eval { WebGUI::Asset->new($session, $id)};
   if (!defined $asset || $@) {
       my $st = $session->db->read("select url from assetData where assetId=? ",[$id]);
       my @url = $st->array;
       print "\tbad asset: $@ \t url: @url[0] \n";
       next;
   }
   my $instanciation = Time::HiRes::tv_interval($t);

   # set the default asset for those things that need it
   $session->asset($asset);

   # check render time
   $t = [Time::HiRes::gettimeofday];
   eval {my $junk = $asset->www_view};
   my $rendering = Time::HiRes::tv_interval($t);
   if ($@) {
       $rendering = $@;
   }
   my $url =  $asset->getValue("url");
   # output the results
   printf "\t%18.4f\t%12.4f\t%s\n", $instanciation, $rendering ,$url;
}

close($null);

print "Total assets: $count\n";


finish($session);


#-------------------------------------------------
sub start {
   my $configFile;
   $| = 1; #disable output buffering
   GetOptions(
       'configFile=s' => \$configFile,
       'className=s'  => \$class,
   );
   my $session = WebGUI::Session->open("/data/WebGUI",$configFile);
   return $session;
}

#-------------------------------------------------
sub finish {
   my $session = shift;
   $session->var->end;
   $session->close;
}
"
DownloadclassLoadTester_pl.txt classLoadTester_pl.txt
LinksPlain Black Corporation
No Support Offered
Statistics Downloads: 649
Views: 3776
Rating: 3
Updated: 11/10/2008
Keywords miscellaneous utility
NavigationMore from Plain Black Corporation
Back to the Bazaar
© 2018 Plain Black Corporation | All Rights Reserved