smeserver-durep/root/usr/share/smanager/lib/SrvMngr/Controller/Durep.pm

68 lines
1.3 KiB
Perl

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;