Disk usage module checkin

This commit is contained in:
Jamie Cameron
2011-01-14 11:14:54 -08:00
parent 72357419a5
commit 1098539484
25 changed files with 274 additions and 0 deletions

10
disk-usage/close.cgi Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/local/bin/perl
# Remove some directory from the open list
require './disk-usage-lib.pl';
&ReadParse();
@heiropen = &get_heiropen();
@heiropen = grep { $_ ne $in{'what'} } @heiropen;
&save_heiropen(\@heiropen);
&redirect("index.cgi#$in{'what'}");

4
disk-usage/config Normal file
View File

@@ -0,0 +1,4 @@
dirs=/tmp
units=1048576
min=0
xdev=0

View File

@@ -0,0 +1,6 @@
dirs=/tmp
units=1048576
min=0
xdev=0
bsize=512
fs=nfs nfs4 smbfs proc devpty devfs usbdevfs sysfs rpc_pipefs autofs

View File

@@ -0,0 +1,6 @@
dirs=/tmp
units=1048576
min=0
xdev=0
bsize=512
fs=nfs procfs kernfs linprocfs portal smbfs

6
disk-usage/config-netbsd Normal file
View File

@@ -0,0 +1,6 @@
dirs=/tmp
units=1048576
min=0
xdev=0
bsize=512
fs=nfs procfs kernfs linprocfs portal smbfs

View File

@@ -0,0 +1,6 @@
dirs=/tmp
units=1048576
min=0
xdev=0
bsize=512
fs=nfs procfs kernfs linprocfs portal smbfs

View File

@@ -0,0 +1,6 @@
dirs=/tmp
units=1048576
min=0
xdev=0
bsize=512
fs=nfs devfs ctfs proc mntfs objfs fs autofs

7
disk-usage/config.info Normal file
View File

@@ -0,0 +1,7 @@
dirs=Directories to index,9,50,5,\t
skip=Directories to skip,9,50,3,\t
fs=Filesystem types to skip,0
units=Minumum units for sizes,1,1-bytes,1024-kB,1048576-MB,1073741824-GB
min=Minimum directory size to display,0,10,,bytes
xdev=Limit search to one filesystem?,1,1-Yes,0-No
bsize=Filesystem block size (in bytes),3,Unknown

View File

View File

@@ -0,0 +1,7 @@
dirs=Directorios a indexar,9,50,5,\t
skip=Directorios a ignorar,9,50,3,\t
fs=Tipos de sistemas de archivos a ignorar,0
units=Unidades mínimas para tamaños,1,1-bytes,1024-kB,1048576-MB,1073741824-GB
min=Tamaño mínimo de directorio a mostrar,0,10,,bytes
xdev=¿Limitar búsqueda a un sistema de archivos?,1,1-Sí,0-No
bsize=Tamaño de bloque de sistema de archivos (en bytes),3,Desconocido

29
disk-usage/edit_sched.cgi Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/local/bin/perl
# Show a form for setting up scheduled collection
require './disk-usage-lib.pl';
&foreign_require("cron", "cron-lib.pl");
&ui_print_header(undef, $text{'sched_title'}, "");
$job = &find_cron_job();
print &ui_form_start("save_sched.cgi");
print &ui_table_start($text{'sched_header'}, "width=100%", 2);
print &ui_table_row($text{'sched_enabled'},
&ui_radio("enabled", $job ? 1 : 0,
[ [ 0, $text{'no'} ],
[ 1, $text{'sched_at'} ] ]));
print "<tr> <td colspan=2><table border width=100%>\n";
$job ||= { 'mins' => 0,
'hours' => 0,
'days' => '*',
'months' => '*',
'weekdays' => '*' };
&cron::show_times_input($job);
print "</table></td> </tr>\n";
print &ui_table_end();
print &ui_form_end([ [ "save", $text{'save'} ] ]);
&ui_print_footer("", $text{'index_return'});

Binary file not shown.

BIN
disk-usage/images/close.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

BIN
disk-usage/images/icon.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
disk-usage/images/open.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

65
disk-usage/index.cgi Executable file
View File

@@ -0,0 +1,65 @@
#!/usr/local/bin/perl
# Show the disk usage tree
require './disk-usage-lib.pl';
@dirs = split(/\t+/, $config{'dirs'});
$fors = &text(@dirs > 1 ? 'index_fors' : 'index_for',
join(" ", map { "<tt>$_</tt>" } @dirs));
&ui_print_header($fors, $module_info{'desc'}, "", undef, 1, 1);
$tree = &get_usage_tree();
if ($tree) {
# Show it
%open = map { $_, 1 } &get_heiropen();
$open{"/"} = 1;
print "<table width=100%>\n";
print "<tr>\n";
print "<td width=10%><b>$text{'index_total'}</b></td>\n";
print "<td width=10%><b>$text{'index_files'}</b></td>\n";
print "<td width=80%><b>$text{'index_dir'}</b></td>\n";
print "</tr>\n";
&traverse($tree, 0);
print "</table>\n";
}
else {
print "<b>$text{'index_none'}</b><p>\n";
}
print "<hr>\n";
print &ui_buttons_start();
print &ui_buttons_row("edit_sched.cgi",
$text{'index_sched'}, $text{'index_scheddesc'});
print &ui_buttons_row("run.cgi",
$text{'index_run'}, $text{'index_rundesc'});
print &ui_buttons_end();
&ui_print_footer("/", $text{'index'});
sub traverse
{
local ($node, $indent) = @_;
return if ($node->{'total'} < $config{'min'});
print "<tr>\n";
print "<td>",&nice_size($node->{'total'}, $config{'units'}),"</td>\n";
print "<td>",&nice_size($node->{'files'}, $config{'units'}),"</td>\n";
print "<td>", "&nbsp;" x ($indent*3);
if ($node->{'dir'} ne "/") {
print "<a name=\"$node->{'dir'}\">\n";
$act = $open{$node->{'dir'}} ? "close" : "open";
print "<a href=\"$act.cgi?what=",&urlize($node->{'dir'}),"\">";
print "<img border=0 src=images/$act.gif></a>\n";
}
else {
print "<img src=images/close.gif>\n";
}
print "<tt>$node->{'dir'}</tt></td>\n";
print "</tr>\n";
if ($open{$node->{'dir'}}) {
# Do sub-directories too
foreach my $subdir (sort { $b->{'total'} <=> $a->{'total'} }
@{$node->{'subs'}}) {
&traverse($subdir, $indent+1);
}
}
}

16
disk-usage/lang/de Normal file
View File

@@ -0,0 +1,16 @@
index_dir=Verzeichnis
index_files=Dateien
index_for=F&#252;r Verzeichnis &#167;1
index_fors=F&#252;r Verzeichnisse $1
index_none=Es ist noch kein Festplattenverbrauch analysiert. Erstellen Sie entweder eine geplante Analyse oder dr&#252;cken Sie auf den Button unten.
index_run=Analysiere jetzt
index_sched=Erstelle geplante Analyse
index_total=Gesamt
run_doing=Analysiere jetzt Festplattenplatz ...
run_done=... Fertig!
run_title=Analysiere Festplattenplatz
sched_at=Ja, zu den unten gew&#228;hlten Einstellungen.
sched_enabled=Geplante Analyse aktiviert?
sched_header=Optionen
sched_title=Geplante Analyse
shed_err=Fehler bei der Analyse

22
disk-usage/lang/en Normal file
View File

@@ -0,0 +1,22 @@
index_none=No disk usage data has been collected yet. Either set up scheduled collection, or use the button below to collect data now.
index_sched=Setup Scheduled Collection
index_scheddesc=Click this button to set up the automatic scheduled collection of disk usage data for the configured directories.
index_run=Collect Usage Now
index_rundesc=Click here to scan the configured directories immediately to compute their disk usage.
index_for=For directory $1
index_fors=For directories $1
index_return=usage tree
index_dir=Directory
index_total=Total
index_files=Files
run_title=Collect Usage
run_doing=Now collecting disk usage ..
run_done=.. done.
sched_title=Scheduled Collection
sched_header=Scheduled disk usage collection options
sched_enabled=Scheduled collection enabled?
sched_at=Yes, at times selected below ..
sched_err=Failed to save scheduled collection
__norefs=1

19
disk-usage/lang/es Normal file
View File

@@ -0,0 +1,19 @@
index_dir=Directorio
index_files=Archivos
index_for=Para directorio $1
index_fors=Para directorios $1
index_none=A&#250;n no se han recogido datos de uso de disco. Puede configurar una recogida de datos planificada, o utilizar el bot&#243;n inferior para recoger datos ahora.
index_return=arbol de uso
index_run=Recoger Uso Ahora
index_rundesc=Pulse aqu&#237; para recorrer los directorios configurados inmediatamente y calcular su uso de disco.
index_sched=Configurar Recogida Planificada
index_scheddesc=Pulse este bot&#243;n para configurar la recogida planificada autom&#225;tica de datos de uso de disco para los directorios configurados.
index_total=Total
run_doing=Recogiendo uso de disco ..
run_done=.. hecho
run_title=Recoger Uso
sched_at=Si, a las horas seleccionadas abajo ..
sched_enabled=&#191;Recogida planificada habilitada?
sched_err=Fallo al salvar recogida planificada
sched_header=Opciones de recogida planificada de datos de uso de disco
sched_title=Recogida Planificada

5
disk-usage/module.info Normal file
View File

@@ -0,0 +1,5 @@
desc=Disk Usage
depends=cron
version=1.1
desc_es=Uso de Disco
desc_de=Festplattenverbrauch

10
disk-usage/open.cgi Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/local/bin/perl
# Add some directory to the open list
require './disk-usage-lib.pl';
&ReadParse();
@heiropen = &get_heiropen();
push(@heiropen, $in{'what'});
&save_heiropen(\@heiropen);
&redirect("index.cgi#$in{'what'}");

13
disk-usage/run.cgi Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/local/bin/perl
# Build the usage tree now
require './disk-usage-lib.pl';
&ui_print_unbuffered_header(undef, $text{'run_title'}, "");
print $text{'run_doing'},"<br>\n";
$root = &build_root_usage_tree([ split(/\t+/, $config{'dirs'}) ]);
&save_usage_tree($root);
print $text{'run_done'},"<p>\n";
&ui_print_footer("", $text{'index_return'});

28
disk-usage/save_sched.cgi Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/local/bin/perl
# Create, update or edit the scheduled checking job
require './disk-usage-lib.pl';
&foreign_require("cron", "cron-lib.pl");
&error_setup($text{'sched_err'});
$oldjob = $job = &find_cron_job();
&ReadParse();
if ($in{'enabled'}) {
# Validate inputs
$job ||= { 'user' => 'root',
'command' => $cron_cmd,
'active' => 1 };
&cron::parse_times_input($job, \%in);
if ($oldjob) {
&cron::change_cron_job($job);
}
else {
&cron::create_cron_job($job);
}
&cron::create_wrapper($cron_cmd, $module_name, "usage.pl");
}
else {
&cron::delete_cron_job($job) if ($job);
}
&redirect("");

9
disk-usage/usage.pl Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/local/bin/perl
# Count up usage for selected directories
$no_acl_check = 1;
require './disk-usage-lib.pl';
$root = &build_root_usage_tree([ split(/\t+/, $config{'dirs'}) ]);
&save_usage_tree($root);