
<?php
require("../../inc/header.inc");
require("../serverStatusImprove/function.inc");
?>
<?php

function GetLabel($pn)
{
	switch($pn)
	{
		case '0':
		case 0:
			return '';
		case '1':
		case 1:
			return '쮤';
		case '2':
		case 2:
			return '쮤쮤';
		case '3':
		case 3:
			return '쮤쮤쮤';
		case '4':
		case 4:
			return '쮤쮤쮤쮤';
		case '5':
		case 5:
			return '쮤쮤쮤쮤쮤';
		case '6':
		case 6:
			return '쮤쮤쮤쮤쮤쮤';
		case '7':
		case 7:
			return '쮤쮤쮤쮤쮤쮤쮤';
		case '8':
		case 8:
			return '쮤쮤쮤쮤쮤쮤쮤쮤';
		case '9':
		case 9:
			return '쮤쮤쮤쮤쮤쮤쮤쮤쮤';
		case '10':
		case 10:
			return '쮤쮤쮤쮤쮤쮤쮤쮤쮤쮤';
	}
	return '';
}

  
function GetPlatInfo1($qq,$sysNo)
{
	
	$sql="select detailStat from OMC_PUB.sysStat where sysTypeNo=200 and sysNo={$qq} and subSysNo=$sysNo ";
	//echo "$sql<br>";
	$res=mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	if($num != 1)
	{
		return 0;
	}
	$row=@mysqli_fetch_array($res);
	$baseStat=$row[detailStat];
	$compStat=substr($baseStat,38);
	$compStatLen=strlen($compStat)-1;
	//echo "$compStat<br>";
	$index=0;
	$i=0;
	while($i<$compStatLen)
	{
		$tmp=substr($compStat,$i,4);
		$component[$index][ID]=$tmp+0;
		$i+=4;
		$tmp=substr($compStat,$i,4);
		$component[$index][Length]=hexdec($tmp);
		$i+=4;
		$component[$index][Content]=substr($compStat,$i,$component[$index][Length]*2);
		$i+=$component[$index][Length]*2;
		$index++;
	}
	
	//echo "<pre>";
	//print_r($component);
	//echo "</pre>";
	
	if($component[8][Length] > 0)
	{
		$snmp_hb=$component[8][Content];
		//echo "{$component[8][Length]}<br>$snmp_hb<br>";
		
		//Start Time
		$pos=0;
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$plat[StartTime][Value]=date("Y-m-d H:i:s",$tmpValue);
		$plat[StartTime][Color]="#0000ff";
		$plat[StartTime][Display]="block";
		$pos+=8;
		
		//CPU Use Rate
		$tmpValue=100-hexdec(substr($snmp_hb,$pos,2));
		$plat[CPURate][Value]="{$tmpValue}%";
		$plat[CPURate][Color]="#000000";
		$plat[CPURate][Display]="block";
		
		//藤속
	  $plat[CPU]=GetLabel(floor($tmpValue/10));
		
		//藤속
		
		//CPU Use Rate Process Num
		$plat[CPURatePN][Value]=floor($tmpValue/10);
		$plat[CPURatePN][Color]="#0000ff";
		$plat[CPURatePN][Display]="Rect";
		$pos+=2;
		
		//Physical Memory Used/Total
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$tmpValue1=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$tmpValue2=floor(($tmpValue/$tmpValue1)*100);

		$plat[PMTotalRate][Value]="{$tmpValue2}%";
		$plat[PMTotalRate][Color]="#000000";
		$plat[PMTotalRate][Display]="block";
    		
		$plat[PMTotalRateV][Value]=(floor($tmpValue/1024))."M/".(floor($tmpValue1/1024))."M";
		$plat[PMTotalRateV][Color]="#000000";
		$plat[PMTotalRateV][Display]="block";
		
		$plat[PMTotalRatePN][Value]=floor($tmpValue2/10);
		$plat[PMTotalRatePN][Color]="#0000ff";
		$plat[PMTotalRatePN][Display]="Rect";
		
		//Physical Memory Used/Swap
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$tmpValue1=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$tmpValue2=floor(($tmpValue/$tmpValue1)*100);
		
		$plat[PMSwapRate][Value]="{$tmpValue2}%";
		$plat[PMSwapRate][Color]="#000000";
		$plat[PMSwapRate][Display]="block";
		
		$plat[PMSwapRateV][Value]=(floor($tmpValue/1024))."M/".(floor($tmpValue1/1024))."M";
		$plat[PMSwapRateV][Color]="#000000";
		$plat[PMSwapRateV][Display]="block";
		
		$plat[PMSwapRatePN][Value]=floor($tmpValue2/10);
		$plat[PMSwapRatePN][Color]="#0000ff";
		$plat[PMSwapRatePN][Display]="Rect";
                      		
		//Physical Memory Buffers
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$plat[PMBuffers][Value]=(floor($tmpValue/1024))."M";
		$plat[PMBuffers][Color]="#000000";
		$plat[PMBuffers][Display]="block";
		                                        
		//Physical Memory Cached
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$plat[PMCached][Value]=(floor($tmpValue/1024))."M";
		$plat[PMCached][Color]="#000000";
		$plat[PMCached][Display]="block";
		
		//Harddisk
		$tmpValue=hexdec(substr($snmp_hb,$pos,2));
		$pos+=2;
		$plat[HDNum]=$tmpValue;
		for($i=0;$i<$plat[HDNum];$i++)
		{
			$tmpValue=hexdec(substr($snmp_hb,$pos,2));
			$pos+=2;
			$path_len=$tmpValue;
			$path="";
			for($j=0;$j<$path_len;$j++)
			{
				$path.=chr(hexdec(substr($snmp_hb,$pos,2)));
				$pos+=2;
			}
			$plat[HD][$i][Path][Value]="($path)";
			$plat[HD][$i][Path][Color]="#000000";
			$plat[HD][$i][Path][Display]="block";
			
			$tmpValue=hexdec(substr($snmp_hb,$pos,8));
			$pos+=8;
			$tmpValue1=hexdec(substr($snmp_hb,$pos,8));
			$pos+=8;
			
			$tmpValue2=floor(($tmpValue/$tmpValue1)*100);
			$plat[HD][$i][PN][Value]=floor($tmpValue2/10);
			$plat[HD][$i][PN][Color]="#0000ff";
			$plat[HD][$i][PN][Display]="Rect";
			
			$plat[HD][$i][V][Value]=(floor($tmpValue/1024))."M/".(floor($tmpValue1/1024))."M";
			$plat[HD][$i][V][Color]="#000000";
			$plat[HD][$i][V][Display]="block";
			
			$plat[HD][$i][Rate][Value]="{$tmpValue2}%";
			$plat[HD][$i][Rate][Color]="#000000";
			$plat[HD][$i][Rate][Display]="block";
		}
	}
	

	return $plat;
}
 
?>


<?php
adjust_head();
adjust_title_head();


echo "<FORM NAME=\"downForm\" action=\"./server_status.php\" method=\"post\">";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "Advanced > PLAT Status";
		echo "</td>";

		echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
		showHelp($helpId);
		echo "</td>";
	echo "</tr>";
	
	
	echo "<tr>";
		/*
		echo "<td width=\"50%\">";
		echo "&nbsp;";
		echo "</td>";
		*/
		
		echo "<td width=\"50%\" align=\"right\" title=\"back\">";
		//echo "<a href=# onClick=\"javascript:clearAll();\"><img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">$strBlack</a>";
		echo "<a target=\"back\" href=\"./plat_test_status.php?\"><img src=\"../../images/left.gif\" border=0></img>back</a>";
		
		echo "</td>";
	echo "</tr>";
echo "</table>";


adjust_title_tail();
adjust_content_head();

?>


<?php

$config=parse_ini_file("../platStatus/config.ini",true);
$config_count=sizeof($config);

$platDetailInfo=GetDetailPlatInfo($sysNo,$subSysNo,0);
$plat_status=GetPlatInfo1($sysNo,$subSysNo);

$table_title="<font color=\"#0000FF\">PLAT STATUS information</font>( Version:";
$table_title.="<font color=\"{$platDetailInfo[version][Status][Color]}\">{$platDetailInfo[version][Status][Value]}</font>";
$table_title.=")";


  echo "<br><b><center>$table_title</center></b><br>";
  echo "<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
	
	echo "<tr >";
	
	echo "<td align=\"left\" bgcolor=\"#E6E6E6\" width=\"50%\" >Status</td>";
	echo "<td align=\"left\"  >Y</td>";
	//echo "<td>--</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td align=\"left\" bgcolor=\"#E6E6E6\" width=\"50%\">Dual server mode</td>";
	echo "<td align=\"left\" color=\"#0000FF\">Single</td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td align=\"left\" bgcolor=\"#E6E6E6\" width=\"50%\">Reflash time</td>";
	echo "<td align=\"left\" color=\"{$platDetailInfo[RefreshTime][color]}\">{$platDetailInfo[RefreshTime][Value]}</td>";
	//echo "<td>--</td>";
	echo "</tr>";
	
	//Start Time
	echo "<tr>";
	echo "<td align=\"left\" bgcolor=\"#E6E6E6\"  width=\"50%\">Start time</td>";
	echo "<td align=\"left\" color=\"{$plat_status[StartTime][Value]}\">{$plat_status[StartTime][Value]}</td>";
  //echo "<td>--</td>";
  echo "</tr>";
 
  //CPU Use Rate
  echo "<tr>";
	echo "<td align=\"left\"  bgcolor=\"#E6E6E6\"  width=\"50%\">CPU use rate/Process Num</td>";
	echo "<td>";
	echo "{$plat_status[CPU]}";
	echo "{$plat_status[CPURate][Value]}/{$plat_status[CPURatePN][Value]}</td>";
  
  //echo "<td>--/--</td>";
  echo "</tr>";
  
  
  
  //CPU Use Rate Process Num
  echo "<tr>";
	echo "<td align=\"left\"  bgcolor=\"#E6E6E6\" width=\"50%\">Physical Memory Used/Total</td>";
	echo "<td align=\"left\" color=\"{$plat_status[PMTotalRate][Color]}\">{$plat_status[PMTotalRate][Value]}/ {$plat_status[PMTotalRateV][Value]} / {$plat_status[PMTotalRatePN][Value]}</td>";
  //echo "<td>--/--/--</td>";
  echo "</tr>";
  
  
  //Physical Memory Used/Total
  echo "<tr>";
	echo "<td align=\"left\"  bgcolor=\"#E6E6E6\" width=\"50%\">Physical Memory Used/Swap</td>";
	echo "<td align=\"left\" color=\"{$plat_status[PMSwapRate][Color]}\">{$plat_status[PMSwapRate][Value]}/{$plat_status[PMSwapRateV][Value]}/{$plat_status[PMSwapRatePN][Value]}</td>";
  //echo "<td>--/--/--</td>";
  echo "</tr>";
  
  
  //Physical Memory Used/Swap
  echo "<tr>";
	echo "<td align=\"left\"  bgcolor=\"#E6E6E6\" width=\"50%\">Physical Memory Buffers/Cached</td>";
	echo "<td align=\"left\" color=\"{$plat_status[PMBuffers][Color]}\">{$plat_status[PMBuffers][Value]}/{$plat_status[PMCached][Value]}</td>";
  //echo "<td>--/--/--</td>";
  echo "</tr>";
  
  
  //Harddisk
  echo "<tr >";
	echo "<td align=\"left\" bgcolor=\"#E6E6E6\" width=\"50%\">Harddisk</td>";
	echo "<td align=\"left\" color=\"{$plat_status[PMBuffers][Color]}\">{$plat_status[PMBuffers][Value]}/{$plat_status[PMCached][Value]}</td>";
  //echo "<td>--/--/--</td>";
  echo "</tr>";
  
	
  
  
  echo "</table>";
?>

<?php
echo "<table border=\"0\" width=\"78%\">";
	echo "<tr>";		
		//echo "<a target=\"_parent\" href=\"./plat_test_status.php?\"><img src=\"../../images/left.gif\" border=0></img>back</a>";
    echo "<td width=\"50%\" align=\"right\" title=\"back\">";
    echo "<a target=\"Back\" href=\"./plat_test_status.php?\"><img src=\"../../images/left.gif\" border=0></img>back</a>";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
?>
