initial commit of file from CVS for smeserver-durep on Sat Sep 7 20:21:52 AEST 2024
This commit is contained in:
67
root/usr/share/smanager/lib/SrvMngr/Controller/Durep.pm
Normal file
67
root/usr/share/smanager/lib/SrvMngr/Controller/Durep.pm
Normal file
@@ -0,0 +1,67 @@
|
||||
package SrvMngr::Controller::Durep;
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : System
|
||||
# description : Disk usage report
|
||||
# navigation : 4000 390
|
||||
# menu : A
|
||||
#
|
||||
# name : durep, method : get, url : /durep, ctlact : durep#main
|
||||
#
|
||||
# routes : end
|
||||
#----------------------------------------------------------------------
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Locale::gettext;
|
||||
use SrvMngr::I18N;
|
||||
use SrvMngr qw(theme_list init_session);
|
||||
|
||||
|
||||
sub main {
|
||||
|
||||
my $c = shift;
|
||||
$c->app->log->info($c->log_req);
|
||||
|
||||
my $modul = get_du( $c );
|
||||
|
||||
$c->stash( modul => $modul );
|
||||
$c->render(template => 'durep');
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub get_du {
|
||||
|
||||
my ($c) = @_;
|
||||
|
||||
my $tx = $c->tx;
|
||||
my $req = $tx->req;
|
||||
|
||||
# 3 env variables for durep.cgi
|
||||
$ENV{'SCRIPT_NAME'} = 'durep';
|
||||
$ENV{'REQUEST_METHOD'} = $req->method;
|
||||
$ENV{'QUERY_STRING'} = $req->url->query->to_string;
|
||||
|
||||
my $res = `/etc/e-smith/web/panels/manager/html/durep/durep.cgi`;
|
||||
$res =~ s|server-manager/durep|smanager/images|g;
|
||||
|
||||
my $step = 0; my $out;
|
||||
my @lines = split /\n/, $res;
|
||||
# remove except 'body'
|
||||
foreach my $line (@lines) {
|
||||
if ( $line =~ m|<body>| ) {
|
||||
$step = 1;
|
||||
} elsif ( $line =~ m|</body>| ) {
|
||||
$step = 2;
|
||||
} elsif ( $step == 1 ) {
|
||||
$out .= $line;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
1;
|
@@ -0,0 +1 @@
|
||||
'dur_FORM_TITLE' => 'Disk usage report',
|
Reference in New Issue
Block a user