initial commit of file from CVS for smeserver-diskusage on Sat Sep 7 19:52:13 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 19:52:13 +10:00
parent 308b8ed1b1
commit ec6fa3a2bb
34 changed files with 1140 additions and 2 deletions

View File

@@ -0,0 +1,116 @@
#!/usr/bin/perl -w
package esmith::FormMagick::Panel::diskusage;
use strict;
use warnings;
use esmith::FormMagick;
use esmith::AccountsDB;
use esmith::ConfigDB;
use esmith::cgi;
use esmith::util;
use File::Basename;
use Exporter;
use Carp qw(verbose);
our @ISA = qw(esmith::FormMagick Exporter);
our @EXPORT = qw();
our $VERSION = sprintf '%d.%03d', q$Revision: 1.1 $ =~ /: (\d+).(\d+)/;
our $accountdb = esmith::AccountsDB->open();
our $configdb = esmith::ConfigDB->open();
sub print_filesystem_usage {
my $self = shift;
my $q = $self->{cgi};
print $q->p ("&nbsp\n");
print $q->p (`/bin/date`);
my $FileSystemUsage = `/bin/df -h`;
print $q->p ($q->pre ("$FileSystemUsage"));
return "";
}
sub print_ibay_table {
my $self = shift;
my $q = $self->{cgi};
my $name = $self->localise('IBAYS');
my $usage = $self->localise('USAGE');
my $path = $self->localise('PATH');
my @ibays = $accountdb->ibays();
print $q->start_table({-CLASS => "sme-border"}),"\n";
print $q->Tr (
esmith::cgi::genSmallCell($q, $name,"header"),
esmith::cgi::genSmallCell($q, $usage,"header"),
esmith::cgi::genSmallCell($q, $path,"header")),"\n";
my $scriptname = basename($0);
foreach my $i (@ibays)
{
my $ibayname = $i->key();
my @ibayusage = split(/\s/, (`/usr/bin/du -hs /home/e-smith/files/ibays/$ibayname`));
print $q->Tr (
esmith::cgi::genSmallCell($q, $ibayname,"normal"),
esmith::cgi::genSmallCell($q, $ibayusage[0],"normal"),
esmith::cgi::genSmallCell($q, $ibayusage[1],"normal"));
}
# opt
{
my @optusage = split(/\s/, (`/usr/bin/du -hs /opt`));
print $q->Tr (
esmith::cgi::genSmallCell($q, 'opt',"normal"),
esmith::cgi::genSmallCell($q, $optusage[0],"normal"),
esmith::cgi::genSmallCell($q, $optusage[1],"normal"));
}
print $q->end_table,"\n";
return "";
}
sub print_user_table {
my $self = shift;
my $q = $self->{cgi};
my $name = $self->localise('USERS');
my $usage = $self->localise('USAGE');
my $path = $self->localise('PATH');
my @users = $accountdb->users();
print $q->p ("&nbsp\n");
print $q->start_table({-CLASS => "sme-border"}),"\n";
print $q->Tr (
esmith::cgi::genSmallCell($q, $name,"header"),
esmith::cgi::genSmallCell($q, $usage,"header"),
esmith::cgi::genSmallCell($q, $path,"header")),"\n";
my $scriptname = basename($0);
# root
{
my @rootusage = split(/\s/, (`/usr/bin/du -hs /root`));
print $q->Tr (
esmith::cgi::genSmallCell($q, 'root',"normal"),
esmith::cgi::genSmallCell($q, $rootusage[0],"normal"),
esmith::cgi::genSmallCell($q, $rootusage[1],"normal"));
}
foreach my $i (@users)
{
my $username = $i->key();
my @userusage = split(/\s/, (`/usr/bin/du -hs /home/e-smith/files/users/$username`));
print $q->Tr (
esmith::cgi::genSmallCell($q, $username,"normal"),
esmith::cgi::genSmallCell($q, $userusage[0],"normal"),
esmith::cgi::genSmallCell($q, $userusage[1],"normal"));
}
print $q->end_table,"\n";
return "";
}
1;