<?php
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
?>

<?php
  //Gold => 5100
  //Silver => 5030

  $GB = 1024*1024*1024;
  $TB = $GB * 1024;
  //get full data
  $json = json_decode(PostJson("$bdnuss/Storage/SVC/SVC_INVENTORY.php",''),true);
  
  // Sum LUN Size by Bay
  $lunsGold = 0 ; $lunsSilver = 0 ;
  foreach($json['Data']['VolumeCopies'] as $data){
    if(strpos($data['mdisk_grp_name'],"5100") !== false){
      $lunsGold += $data['capacity'] ;
    }else{
      $lunsSilver += $data['capacity'] ;
    }
  }

  // Get Full Capacity
  $goldCapacity = 0 ; $silverCapacity = 0 ;
  foreach($json['Data']['Pools'] as $data){
    if(strpos($data['name'],"5100") !== false){
      $goldCapacity += $data['capacity'] ;
    }else{
      $silverCapacity += $data['capacity'] ;
    }
  }

  // Datas
  $goldCapacity =  $goldCapacity / 2;
  $silverCapacity = $silverCapacity / 2 ;
  $GoldFree = $goldCapacity - $lunsGold ;
  $SilverFree = $silverCapacity - $lunsSilver ;
  $goldPercentUsed = round($lunsGold / $goldCapacity * 100 ,2) ;
  $silverPercentUsed = round($lunsSilver / $silverCapacity * 100 ,2) ;
?>