#!/usr/local/bin/php -c/usr/local/directadmin/plugins/new_lvemanager/php.ini ReturnLveStatsVersion ( ); // find cur uid $uid = exec('/usr/bin/getent passwd '.$_SERVER['USER'].' | cut -d: -f3'); // Get lveinfo data for user $lveinfo_data = $LVE->GetLVEStats ( $period, $uid ); $cpu_limited_flag = 0; $cpuf_total = 0; $memf_total = 0; $mepf_total = 0; $iof_total = 0; $iopsf_total = 0; $cpu_max = 0; $lcpu_max = 0; $mem_max = 0; $lmem_max = 0; $ep_max = 0; $lep_max = 0; $pmem_max = 0; $lpmem_max = 0; $pmemf_total = 0; $nproc_max = 0; $lnproc_max = 0; $nprocf_total = 0; $iousage_max = 0; $iolimit_max = 0; $iopsusage_max = 0; $iopslimit_max = 0; foreach ( $lveinfo_data as $item ) { # use this algorithm detecting cpu limit overflow for old lvestats $cpu_limited_flag = $cpu_limited_flag || ($lve_stats_version == 0 && isset ( $item['mCPU'] ) && $item['mCPU'] >= $item['lCPU']); $cpuf_total += arrGet ( $item, 'CPUf' ); $memf_total += arrGet ( $item, 'VMemF'); $mepf_total += arrGet ( $item, 'EPf' ); $pmemf_total += arrGet ( $item, 'PMemF' ); $nprocf_total += arrGet ( $item, 'NprocF' ); $iof_total += arrGet ( $item, 'IOf' ); $iopsf_total += arrGet ( $item, 'IOPSf' ); if ( arrGet ( $item, 'mCPU' ) > $cpu_max ) $cpu_max = $item [ 'mCPU' ]; if ( arrGet ( $item, 'lCPU' ) > $lcpu_max ) $lcpu_max = $item [ 'lCPU' ]; if ( arrGet ( $item, 'mVMem' ) > $mem_max) $mem_max = $item [ 'mVMem' ]; if ( arrGet ( $item, 'lVMem' ) > $lmem_max ) $lmem_max = $item [ 'lVMem' ]; if ( arrGet ( $item, 'mEP' ) > $ep_max ) $ep_max = $item [ 'mEP' ]; if ( arrGet ( $item, 'lEP' ) > $lep_max ) $lep_max = $item [ 'lEP' ]; if ( arrGet ( $item, 'lPMem' ) > $lpmem_max ) $lpmem_max = $item [ 'lPMem' ]; if ( arrGet ( $item, 'mPMem' ) > $pmem_max ) $pmem_max = $item [ 'mPMem' ]; if ( arrGet ( $item, 'mNproc' ) > $nproc_max ) $nproc_max = $item [ 'mNproc' ]; if ( arrGet ( $item, 'lNproc' ) > $lnproc_max ) $lnproc_max = $item [ 'lNproc' ]; if ( arrGet ( $item, 'mIO' ) > $iousage_max ) $iousage_max = $item [ 'mIO' ]; if ( arrGet ( $item, 'lIO' ) > $iolimit_max ) $iolimit_max = $item [ 'lIO' ]; if ( arrGet ( $item, 'mIOPS' ) > $iopsusage_max ) $iopsusage_max = $item [ 'mIOPS' ]; if ( arrGet ( $item, 'lIOPS' ) > $iopslimit_max ) $iopslimit_max = $item [ 'lIOPS' ]; } // foreach ?>
| translate('Resource Usage Overview');?> | ||||
|
0 || $pmemf_total > 0 ||
$mepf_total > 0 || $nprocf_total > 0 || $iof_total > 0 || $iopsf_total > 0 )
{
echo ''.$LANG->translate("Your site has been limited within the past 24 hours").' '; if ( $cpu_limited_flag || $cpuf_total ) echo $LANG->translate('CPU resources were limited for your site').' '; if ( $memf_total > 0 ) echo $LANG->translate('Virtual memory resources were limited for your site').' '; if ( $pmemf_total > 0 ) echo $LANG->translate('Physical memory resources were limited for your site').' '; if ( $mepf_total > 0 ) echo $LANG->translate('You have reached entry processes (number of simultaneously running php and cgi scripts, as well as cron jobs and shell sessions) limit [_1] times', array($mepf_total)).' '; if ( $nprocf_total > 0 ) echo $LANG->translate('You have reached processes number limit [_1] times', array($nprocf_total)).' '; if ( $iof_total > 0 ) echo $LANG->translate('I/O usage resources were limited for your site').' '; if ( $iopsf_total > 0 ) echo $LANG->translate('I/O operations per second (IOPS) were limited for your site').' '; } // if else { echo ''.$LANG->translate("Your site had no issues in the past 24 hours").' '; } // else // print warnings - 90% usage of each limit $cpu_warn = ( !$cpu_limited_flag ) && ( $cpuf_total == 0 ) && ( $cpu_max > $lcpu_max * 0.9 ); $mem_warn = ( $memf_total == 0 ) && ( $lmem_max > 0 ) && ( $mem_max > $lmem_max * 0.9 ); $pmem_warn = ( $pmemf_total == 0 ) && ( $lpmem_max > 0 ) && ( $pmem_max > $lpmem_max * 0.9 ); $mep_warn = ( $mepf_total == 0 ) && ( $lep_max > 0 ) && ( $ep_max > $lep_max * 0.9 ); $nproc_warn = ( $nprocf_total == 0 ) && ( $lnproc_max > 0 ) && ( $nproc_max > $lnproc_max * 0.9 ); $io_warn = ( $iolimit_max > 0 ) && ( $iousage_max > $iolimit_max * 0.9 ) && !$iof_total; $iops_warn = ( $iopslimit_max > 0 ) && ( $iopsusage_max > $iopslimit_max * 0.9 ) && !$iopsf_total; if ( $cpu_warn || $mem_warn || $pmem_warn || $mep_warn || $nproc_warn || $io_warn || $iops_warn ) { echo "".$LANG->translate('Your site might hit resource limits soon')." "; if ( $cpu_warn ) echo $LANG->translate('Your CPU usage was at [_1]% out of [_2]%', array($cpu_max, $lcpu_max)).' '; if ( $mem_warn ) echo $LANG->translate('Your Virtual Memory usage was at [_1] out of [_2]', array(roundMemB($mem_max), roundMemB($lmem_max))).' '; if ( $pmem_warn ) echo $LANG->translate('Your Physical Memory usage was at [_1] out of [_2]', array(roundMemB($pmem_max), roundMemB($lpmem_max))).' '; if ( $mep_warn ) echo $LANG->translate('You had [_1] entry processes (number of simultaneously running php and cgi scripts, as well as cron jobs and shell sessions) out of [_2] max entry processes allowed', array($ep_max, $lep_max)).' '; if ( $nproc_warn ) echo $LANG->translate('You had [_1] processes out of [_2] max processes allowed', array($nproc_max, $lnproc_max)).' '; if ( $io_warn ) echo $LANG->translate('You had [_1] I/O usage out of [_2] max I/O usage allowed', array(roundMemB($iousage_max), roundMemB($iolimit_max))).' '; if ( $iops_warn ) echo $LANG->translate('You had [_1] I/O operations per second out of [_2] max I/O operations per second allowed', array($iopsusage_max, $iopslimit_max)).' '; } // if ?> [translate('Details');?>] |