Tags:
create new tag
, view all tags

DiskUsagePluginDev Discussion: Page for developer collaboration, enhancement requests, patches and improved versions on DiskUsagePlugin contributed by the TWikiCommunity.
• Please let us know what you think of this extension.
• For support, check the existing questions, or ask a new support question in the Support web!
• Please report bugs below

Feedback on DiskUsagePlugin

This is pretty limited, I know.

Thanks to MS- and CrawfordCurrie on TWikiIRC - they rewrote the regex in perl.

-- MartinCleaver - 10 Mar 2004

I did some minor formatting on the Plugins page, you could take this back into the next release.

This Plugin uses unofficial TWiki functions and variables. There are FuncDotPm functions to get the data dir, pub dir. The $exampleCfgVar variable can be removed, it also uses an unofficial call (err, that is a bug in the EmptyPlugin)

-- PeterThoeny - 11 Mar 2004

Oh, okay, thanks.

I guess there should be a way of hiding all but the official Func symbols from the TWiki:: package at the start of the plugins call. This could ensure compliance.

-- MartinCleaver - 11 Mar 2004

Nice idea but that would have a negative performance impact.

-- PeterThoeny - 11 Mar 2004

I don't understand. Why would it?

-- MartinCleaver - 11 Mar 2004

.zip checked into CVSplugins:DiskUsagePlugin

-- WillNorris - 23 Nov 2004

When I try to view this plugin on my system the page never shows, just sits there waiting. And the machine doesn't seem to be doing anything out of the ordinary (CPU or disk wise).

-- MichaelRosett - 09 Jun 2005

I made some improvements to get this plugin to operate on our installed wiki (v4.0.3)

I fixed a problem where the %QUOTA% failed if there was no quota (returned a divide by zero error)

I also fixed a problem where the calcs were using a mix of units and therefore the sums were incorrect. Now uses actual bytes only.

As an improvement I also made it sum the entire table.

I also made it work with the new logfile names which have dates in them, so it returns the size of the current logfile.

Somebody may wish to take the following diff from DuskUsagePlugin.pm and incorporate it or improve it (I'm not familiar with the process to do this).

Hope someone will find this useful... (I apologise in advance for long post smile )

88,106c88,92
<     my $debugSize = -s $TWiki::cfg{DebugFileName};
<     my $configSize = -s $TWiki::cfg{ConfigurationLogName};
<     my $logfile = $TWiki::cfg{LogFileName};
<     my $warningfile = $TWiki::cfg{WarningFileName};
< # allow for logfiles that have %DATE% in the filename...
< # obtain the size for the current log file...
<     my $time = TWiki::Time::formatTime( time(), '$year$mo', 'servertime');
<     $logfile =~ s/%DATE%/$time/go;
<     $warningfile =~ s/%DATE%/$time/go;
<     my $logSize = -s $logfile;
<     my $warningSize = -s $warningfile;
<     if (not $debugSize) { $debugSize = 0; };
<     if (not $warningSize) { $warningSize = 0; };
<     if (not $logSize) { $logSize = 0; };
<     if (not $configSize) { $configSize = 0; };
<     return "   * Debug log is $debugSize bytes\n".
<            "   * Current Warning log is $warningSize bytes\n".
<            "   * Current Access log is $logSize bytes\n".
<            "   * Configuration log is $configSize bytes\n";
---
>     my $debugSize = -s $TWiki::debugFilename;
>     my $warningSize = -s $TWiki::warningFilename;
> 
>     return "   * Debug log is $debugSize\n".
>            "   * Warning log is $warningSize\n";
111c97
<     my $web = TWiki::Func::extractNameValuePair( @_, "web" );
---
>     my $web = TWiki::extractNameValuePair( @_, "web" );
114,115c100,102
<     my $datadir = $TWiki::cfg{DataDir};
<     my $cmd = "/usr/bin/du -b $datadir/$web/*.txt 2>&1";
---
> 
>     my $cmd = "/usr/bin/du -k $TWiki::dataDir/$web/*.txt 2>&1";
> 
120c107
<       my ($bytes, $file) = split /\s+/, $line;
---
>       my ($kb, $file) = split /\s+/, $line;
122c109
<       $topic =~ s!$datadir/(.*).txt!$1!;
---
>       $topic =~ s!$TWiki::dataDir/(.*).txt!$1!;
124,125c111,112
<       $usageByTopic{$topic}{text} = $bytes;
<       $usageByTopic{$topic}{history} = (-s "$file,v");
---
>       $usageByTopic{$topic}{text} = $kb;
>       $usageByTopic{$topic}{history} = (-s "$file,v") % 1024;
127,128c114,115
<     my $pubdir = $TWiki::cfg{PubDir};
<     $cmd = "/usr/bin/du -b $pubdir/$web/* 2>&1";
---
> 
>     $cmd = "/usr/bin/du -k $TWiki::pubDir/$web/* 2>&1";
134,135c121,122
<       my ($bytes, $topic) = split /\s+/, $line;
<       $topic =~ s!$pubdir/(.*)!$1!;
---
>       my ($kb, $topic) = split /\s+/, $line;
>       $topic =~ s!$TWiki::pubDir/(.*)!$1!;
137c124
<       $usageByTopic{$topic}{attachments} = $bytes;
---
>       $usageByTopic{$topic}{attachments} = $kb;
140c127
<     my $ans = "| *Topic* | *Topic (bytes)* | *History (bytes)* | *Attachments (bytes)* | *Total (bytes)*| \n";
---
>     my $ans = "| *Topic* | *Topic (Kb)* | *History (Kb)* | 
> *Attachments (Kb)* | *Total (Kb)*| \n";
142d128
<     my $sum = 0;
151d136
<        $sum += $lineTotal;
153d137
<     $ans .= "| Total |||| ". $sum ."|\n"; 
169,176c153
<     if ($quota)
<     {
<         return "$blocks of $quota";
<     }
<     else
<     {
<         return "No Quota";
<     }
---
>     return "$blocks of $quota";
181,188c158
<     if ($quota)
<     {    
<        return $blocks / $quota;
<     }
<     else
<     {
<        return 0;
<     }
---
>     return $blocks / $quota;
194,201c164,165
<     if ($length)
<     {
<         return "<TABLE WIDTH=100 CELLSPACING=0 CELLPADDING=0><TR><TD BGCOLOR=$usedColour WIDTH='$length'></TD><TD bgcolor=$unusedColour>&nbsp;</TD><TR></TABLE>"
<     }
<     else
<     {
<         return "";
<     }
---
>     return "<TABLE WIDTH=100 CELLSPACING=0 CELLPADDING=0><TR><TD BGCOLOR=$usedColour WIDTH='$length'></TD><TD bgcolor=$unusedColour>&nbsp;</TD><TR></TABLE>"
> 

-- DarrenElkerton - 26 Jul 2006

I applied DarrenElkerton's patch and uploaded an updated bundle as a dot-tgz file. Sorry, didn't have zip.

Darren, the command to apply the changes was: patch -R lib/TWiki/Plugins/DiskUsagePlugin.pm DiskUsage.patch however one of your diff lines was off (some sort of linebreak was introduced) which initially stopped the patch from working correctly. Thanks for doing the hard work of recording the module.

-- AJAlfieriCrispin - 13 Nov 2006

I updated the .zip file with the content from the .tgz file. It woukd be helpful to have the .txt file updated with the new version info.

Suggestion: Generate proper XHTML, e.g. "<table width="100" cellspacing="0" ... instead of "<TABLE WIDTH=100 CELLSPACING=0 ....

-- PeterThoeny - 14 Nov 2006

Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2006-11-14 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.