%PDF- %PDF-
| Direktori : /usr/share/l.v.e-manager/interworx/lvemanager/Ctrl/Nodeworx/ |
| Current File : //usr/share/l.v.e-manager/interworx/lvemanager/Ctrl/Nodeworx/LveStats.php |
<?php
/**
* Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved
*
* Licensed under CLOUD LINUX LICENSE AGREEMENT
* http://cloudlinux.com/docs/LICENSE.TXT
*/
include('nav.php');
include('veParser.php');
include('roundMem.php');
include('veProcParser.php');
include('checkInput.php');
class Ctrl_Nodeworx_LveStats extends Ctrl_Nodeworx_Plugin {
protected function _init()
{
if( IW::NW()->isReseller() )
{
throw new IWorx_Exception_ActionBlocked( '##LG_ACTION_BLOCKED##' );
}
}
public function indexAction()
{
if(isset($_POST['st']))
{
$period = checkPeriod($_POST['timeframe']);
$st = checkSt($_POST['st']);
$orderBy = checkOrder($_POST['order-by']);
$byUsage = checkOrder($_POST['by-usage']);
$limit = checkNumber($_POST['limit']);
$percentage = checkNumber($_POST['percentage']);
$treshold = checkNumber($_POST['threshold']);
$byFault = checkFault($_POST['by-fault']);
if($st == 'order-by')
{
ob_start();
passthru("/usr/sbin/lveinfo --csv --period=$period --order-by=$orderBy --limit=$limit");
$lveInfoTmp = ob_get_contents();
ob_end_clean();
}
elseif($st == 'by-usage')
{
ob_start();
passthru("/usr/sbin/lveinfo --csv --period=$period --by-usage=$byUsage --percentage=$percentage");
$lveInfoTmp = ob_get_contents();
ob_end_clean();
}
elseif($st == 'by-fault')
{
ob_start();
passthru("/usr/sbin/lveinfo --csv --period=$period --by-fault=$byFault --threshold=$treshold");
$lveInfoTmp = ob_get_contents();
ob_end_clean();
}
$lveInfoAr = explode(chr(10), $lveInfoTmp);
$lveInfo = array();
$start = 0;
foreach ($lveInfoAr as $lveInfoVal)
{
if($start > 0)
{
$lveInfoDet = explode(',', $lveInfoVal);
if(strlen($lveInfoDet[0]) > 0)
{
if($lveInfoDet[3] == 0)
{
$lveInfoDet[3] = 100;
}
$apcpu = ceil(( $lveInfoDet[1] * 100 / $lveInfoDet[3]));
$mpcpu = ceil(( $lveInfoDet[2] * 100 / $lveInfoDet[3]));
$uname = exec("/usr/bin/getent passwd $lveInfoDet[0] | cut -d: -f1");
$lveInfoDet[1] = $apcpu;
$lveInfoDet[2] = $mpcpu;
$lveInfoDet[7] = roundMemB($lveInfoDet[7]);
$lveInfoDet[8] = roundMemB($lveInfoDet[8]);
$lveInfoDet[9] = roundMemB($lveInfoDet[9]);
$lveInfoDet[12] = $uname;
$lveInfo[] = $lveInfoDet;
}
}
$start++;
}
$this->getView()->assign( 'orderBy', $orderBy );
$this->getView()->assign( 'byUsage', $byUsage );
$this->getView()->assign( 'limit', $limit );
$this->getView()->assign( 'percentage', $percentage );
$this->getView()->assign( 'treshold', $treshold );
$this->getView()->assign( 'byFault', $byFault );
$this->getView()->assign( 'lveInfo', $lveInfo );
}
else
{
$st = 'order-by';
$period = 'today';
}
$this->getView()->assign( 'title', 'CloudLinux Manager' );
$this->getView()->assign( 'template', 'admin/stats' );
$this->getView()->assign( 'st', $st );
$this->getView()->assign( 'period', $period );
$this->getView()->assign( 'nav', nav('stats') );
}
}
?>