%PDF- %PDF-
| Direktori : /usr/share/l.v.e-manager/interworx/lvemanager/Ctrl/Siteworx/ |
| Current File : //usr/share/l.v.e-manager/interworx/lvemanager/Ctrl/Siteworx/ResourceUsage.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
*/
/**
* @package Mijn-Sleutel
* @author Mike Hoffs <m.hoffs@mijn-sleutel.com>
* @date jun 06, 2011
*/
include('roundMemB.php');
class Ctrl_Siteworx_ResourceUsage extends Ctrl_Siteworx_Plugin {
/**
* Default action
*/
public function indexAction()
{
$uid = IW::SW()->getuid();
$cpu_limited_flag = 0;
$memf_total = 0;
$mepf_total = 0;
$cpu_max = 0;
$mem_max = 0;
$lmem_max = 0;
$ep_max = 0;
$lep_max = 0;
ob_start();
passthru("/usr/sbin/lveinfo --csv --period=1d --id=$uid");
$lveInfoTmp = ob_get_contents();
ob_end_clean();
$lveInfoAr = explode(chr(10), $lveInfoTmp);
$start = 0;
foreach ($lveInfoAr as $lveInfoValString)
{
$lveInfoVal = explode(',', $lveInfoValString);
if($start > 0)
{
if(strlen($lveInfoVal[0]) > 1)
{
$lveInfoVal[2] = ( $lveInfoVal[2] * 100 / $lveInfoVal[4]);
$lveInfoVal[3] = ( $lveInfoVal[3] * 100 / $lveInfoVal[4]);
//if($lveInfoVal[3] >= $lveInfoVal[4])
if($lveInfoVal[3] >= 100)
{
$cpu_limited_flag = 1;
}
$memf_total += $lveInfoVal[11];
$mepf_total += $lveInfoVal[12];
if($lveInfoVal[3] > $cpu_max)
{
$cpu_max = $lveInfoVal[3];
}
if($lveInfoVal[9] > $mem_max)
{
$mem_max = $lveInfoVal[9];
}
if($lveInfoVal[10] > $lmem_max)
{
$lmem_max = $lveInfoVal[10];
}
if($lveInfoVal[6] > $ep_max)
{
$ep_max = $lveInfoVal[6];
}
if($lveInfoVal[7] > $lep_max)
{
$lep_max = $lveInfoVal[7];
}
}
}
$start++;
}
if ( ( ( !$cpu_limited_flag ) && ( $cpu_max > 90 ) ) || ( ( $memf_total == 0 ) && ( $lmem_max > 0 ) && ( $mem_max > $lmem_max * 0.9 ) ) || ( ( $mepf_total == 0 ) && ( $lep_max > 0 ) && ($ep_max > $lep_max * 0.9 ) ) )
{
$this->getView()->assign( 'nearLimit', 1 );
}
else
{
$this->getView()->assign( 'nearLimit', 0 );
}
if ( ($cpu_limited_flag) || ( $memf_total > 0 ) || ( $mepf_total > 0 ) )
{
$this->getView()->assign( 'limit', 1 );
}
else
{
$this->getView()->assign( 'limit', 0 );
}
if ( ( !$cpu_limited_flag ) && ( $cpu_max > 90 ) )
{
$this->getView()->assign( 'nearCpu', 1 );
}
else
{
$this->getView()->assign( 'nearCpu', 0 );
}
if ( ( $memf_total == 0 ) && ( $lmem_max > 0 ) && ( $mem_max > $lmem_max * 0.9 ) )
{
$this->getView()->assign( 'nearMem', 1 );
}
else
{
$this->getView()->assign( 'nearMem', 0 );
}
if ( ( $mepf_total == 0 ) && ( $lep_max > 0 ) && ( $ep_max > $lep_max * 0.9 ) )
{
$this->getView()->assign( 'nearEp', 1 );
}
else
{
$this->getView()->assign( 'nearEp', 0 );
}
$this->getView()->assign( 'title', 'Resource Usage Overview' );
$this->getView()->assign( 'template', 'user/resourceusage' );
$this->getView()->assign( 'cpu_limited_flag', $cpu_limited_flag );
$this->getView()->assign( 'memf_total', $memf_total );
$this->getView()->assign( 'mepf_total', $mepf_total );
$this->getView()->assign( 'cpu_max', $cpu_max );
$this->getView()->assign( 'mem_max', $mem_max );
$this->getView()->assign( 'lmem_max', $lmem_max );
$this->getView()->assign( 'ep_max', $ep_max );
$this->getView()->assign( 'lep_max', $lep_max );
$this->getView()->assign( 'roundMem_max', roundMemB($mem_max) );
$this->getView()->assign( 'roundLmem_max', roundMemB($lmem_max) );
}
}
class Ctrl_Siteworx_ResourceUsageImage extends Ctrl_Siteworx_Plugin
{
public function displayImageAction() {
echo 1234;
exit();
$this->_displaySuccess( 'index', 'Settings Saved' );
}
}
?>