<?php
/**
 * ThunderSnarf
 *
 * @author Ricardo H.F. Sette P. <ricardohfsp@gmail.com>
 * @link http://www.freebsdbrasil.com.br/
 * @copyright Copyright &copy; 2010 - FreeBSD Brasil LTDA
 * @license licença GNU/GPL v2.0 http://www.gnu.org/licenses/gpl-2.0.html
 */
?>
<?php $this->pageTitle=Yii::app()->name . ' - Estatísticas'; ?>
<?php
$os = strtolower(getenv('OSTYPE'));
$cache_dir = "/usr/home";

function sizeFormat($size){
    if($size<1024)
    {
        return $size." bytes";
    }
    else if($size<(1024*1024))
    {
        $size=round($size/1024,1);
        return $size." KB";
    }
    else if($size<(1024*1024*1024))
    {
        $size=round($size/(1024*1024),1);
        return $size." MB";
    }
    else
    {
        $size=round($size/(1024*1024*1024),1);
        return $size." GB";
    }

} 
 ?>
<table >
	<tr>
		<td style='width:50%;vertical-align:top'>
			<div style="float:right;z-index:10;margin-right:5px;margin-top:5px">
				<?php echo CHtml::ajaxLink ( "<img src='".Yii::app()->request->baseUrl."/images/ajax-loader.png' alt='Recarregar' />",
				                              CController::createUrl('estatisticas/UpdateAjaxProcessador'), 
				                              array('update' => '#dataProcessador'));
				?>			
			</div>
	    	<div id="dataProcessador">
			   <?php $this->renderPartial('_ajaxProcessadorContent',$dataProcessador); ?>
			</div>
		</td>
		<td style='width:50%;vertical-align:top'>
			<div style="float:right;z-index:10;margin-right:5px;margin-top:5px">
				<?php echo CHtml::ajaxLink ( "<img src='".Yii::app()->request->baseUrl."/images/ajax-loader.png' alt='Recarregar' />",
				                              CController::createUrl('estatisticas/UpdateAjaxMemoria'), 
				                              array('update' => '#dataMemoria'));
				?>			
			</div>
	    	<div id="dataMemoria">
			   <?php $this->renderPartial('_ajaxMemoriaContent',$dataMemoria); ?>
			</div>
		</td>
	</tr>
</table>

<?php $this->beginWidget('application.extensions.jui.ETabs', array('name'=>'tabpanel1')); ?>
   <?php $this->beginWidget('application.extensions.jui.ETab', array('name'=>'tab1', 'title'=>'Disco/Cache')); ?>
		<div style="float:right;z-index:10;margin-right:-10px">
			<?php echo CHtml::ajaxLink ( "<img src='".Yii::app()->request->baseUrl."/images/ajax-loader.png' alt='Recarregar Disco/Cache' />",
			                              CController::createUrl('estatisticas/UpdateAjaxDiscoCache'), 
			                              array('update' => '#dataDiscoCache'));
			?>			
		</div>
    	<div id="dataDiscoCache">
		   <?php $this->renderPartial('_ajaxDiscoCacheContent'); ?>
		</div>
   <?php $this->endWidget('application.extensions.jui.ETab'); ?>
    <?php $this->beginWidget('application.extensions.jui.ETab', array('name'=>'tab2', 'title'=>'Tráfego Geral')); ?>
		<div style="float:right;z-index:10;margin-right:-10px">
			<?php echo CHtml::ajaxLink ( "<img src='".Yii::app()->request->baseUrl."/images/ajax-loader.png' alt='Recarregar Tráfego Geral' />",
			                              CController::createUrl('estatisticas/UpdateAjaxTrafegoGeral'), 
			                              array('update' => '#dataTrafegoGeral'));
			?>			
		</div>
    	<div id="dataTrafegoGeral">
		   <?php $this->renderPartial('_ajaxTrafegoGeralContent',$data); ?>
		</div>
    <?php $this->endWidget('application.extensions.jui.ETab'); ?>
    <?php $this->beginWidget('application.extensions.jui.ETab', array('name'=>'tab3', 'title'=>'Tráfego Dinâmico')); ?>
		<div style="float:right;z-index:10;margin-right:-10px">
			<?php echo CHtml::ajaxLink ( "<img src='".Yii::app()->request->baseUrl."/images/ajax-loader.png' alt='Recarregar Tráfego Dinâmico' />",
			                              CController::createUrl('estatisticas/UpdateAjaxTrafegoDinamico'), 
			                              array('update' => '#dataTrafegoDinamico'));
			?>			
		</div>
    	<div id="dataTrafegoDinamico">
		   <?php $this->renderPartial('_ajaxTrafegoDinamicoContent',$data); ?>
		</div>
    <?php $this->endWidget('application.extensions.jui.ETab'); ?>
    <?php $this->beginWidget('application.extensions.jui.ETab', array('name'=>'tab4', 'title'=>'Tráfego Estático')); ?>
		<div style="float:right;z-index:10;margin-right:-10px">
			<?php echo CHtml::ajaxLink ( "<img src='".Yii::app()->request->baseUrl."/images/ajax-loader.png' alt='Recarregar Tráfego Estático' />",
			                              CController::createUrl('estatisticas/UpdateAjaxTrafegoEstatico'), 
			                              array('update' => '#dataTrafegoEstatico'));
			?>			
		</div>
    	<div id="dataTrafegoEstatico">
		   <?php $this->renderPartial('_ajaxTrafegoEstaticoContent',$data); ?>
		</div>
    <?php $this->endWidget('application.extensions.jui.ETab'); ?>
    <?php $this->beginWidget('application.extensions.jui.ETab', array('name'=>'tab5', 'title'=>'I/O Disco')); ?>
    	<div style="float:right;z-index:10;margin-right:-10px">
			<?php 
			echo CHtml::dropDownList(
						"tipoIO",
						'0',
						array(
							"0"=>"Resumido",
							"1"=>"Completo",
						),
			            array("class"=>"change-tipoIO")
					);
			?>
			<script type="text/javascript">
				var var_tipo_IO = 0;
				var interval = setInterval("refreshList(var_tipo_IO)", 5000);
				function refreshList(tipo){
					jQuery.ajax({	
						'data':'IOFull='+tipo,
						'type':'GET',
						'url':'<?php echo Yii::app()->request->baseUrl;?>/index.php/estatisticas/UpdateAjaxIODisco',
						'cache':false,
						'success':function(html){
							jQuery("#dataIODisco").html(html)
						}
					});
				}				
			</script>
		</div>
		<div id="dataIODisco">
		   <?php $this->renderPartial('_ajaxIODiscoContent'); ?>
		</div>
    <?php $this->endWidget('application.extensions.jui.ETab'); ?>
<?php $this->endWidget('application.extensions.jui.ETabs'); ?>
<?php Yii::app()->clientScript->registerScript('tipoIO','
    $(".change-tipoIO").bind("change", function() {
		var_tipo_IO = $(this).val();
		jQuery.ajax({
			"data":"IOFull="+var_tipo_IO,
			"type":"GET",
			"url":"'.Yii::app()->request->baseUrl.'/index.php/estatisticas/UpdateAjaxIODisco",
			"cache":false,
			"success":function(html){
				jQuery("#dataIODisco").html(html)
			}
		});       
    });
'
,CClientScript::POS_READY); ?>