Menu="Dashboard"
Title="Statistics"
---
<?PHP
/* Copyright 2005-2016, Lime Technology
 * Copyright 2012-2016, Bergware International.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2,
 * as published by the Free Software Foundation.
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
*/
?>
<?
exec('cat /sys/devices/system/cpu/*/topology/thread_siblings_list|sort -nu', $cpus);
$fans  = exec("sensors -uA 2>/dev/null|grep -c 'fan[0-9]_input'");
$group = $var['shareSMBEnabled']=='yes' | $var['shareAFPEnabled']=='yes' | $var['shareNFSEnabled']=='yes';
$names = "";
$url   = "/webGui/include/DashUpdate.php";

foreach ($shares as $share) {
  if ($names) $names .= ',';
  $names .= $share['name'];
}

$total = exec("awk '/^MemTotal/{print $2*1024/1.048576}' /proc/meminfo");
exec("ls /sys/class/net|grep -Po '^(lo|(bond|eth)\d+)$'",$ports);

$memory_installed = exec("dmidecode -t 17 | awk -F: '/^\tSize: [0-9]+ MB$/{t+=$2} /^\tSize: [0-9]+ GB$/{t+=$2*1024} END{print t}'")/1024;
$memory_maximum = exec("dmidecode -t 16 | awk -F: '/^\tMaximum Capacity: [0-9]+ GB$/{t+=$2} END{print t}'");
// If maximum < installed then roundup maximum to the next power of 2 size of installed. E.g. 6 -> 8 or 12 -> 16
if ($memory_maximum < $memory_installed) $memory_maximum = pow(2,ceil(log($memory_installed)/log(2)));

function init_row($label) {
  echo "<tr><td>$label</td>".str_repeat("<td></td>",30)."</tr>";
}
function parity_status() {
  global $var,$disks;

  $parity_num_slots = 0;
  $parity_disabled = [];
  $parity_invalid = [];
  foreach ($disks as $disk) {
    if ($disk['type']=='Parity') {
      $parity_num_slots++;
      if (strpos($disk['status'],"DISK_NP")===0) {
        $parity_disabled[] = trim('Parity ' . filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT));
      }
      if (strpos($disk['status'],"DISK_INVALID")===0) {
        $parity_invalid[] = trim('Parity ' . filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT));
      }
    }
  }

  if ($parity_num_slots == count($parity_disabled)) {
    echo "<tr style='vertical-align:top'><td><span class='red p0'><strong>Parity disk".($parity_num_slots>1?'s':'')." not present</strong></span></td><td id='parity'></td></tr>";
    return;
  }
  if ($parity_num_slots > count($parity_invalid)) {
    if (count($parity_invalid)==0) {
      echo "<tr><td colspan='2'><span class='green p0'><strong>Parity is valid</strong></span></td></tr>";
    } else {
      echo "<tr><td colspan='2'><span class='orange p0'><strong>Degraded parity: </strong></span><span class='red p0'><strong>".implode(' and ',$parity_invalid)." ".(count($parity_invalid)>1?'are':'is')." invalid</strong></span></td></tr>";
    }
    if ($var['sbSyncExit']!=0) {
      echo "<tr><td>Last check incomplete on <strong>".my_time($var['sbSynced2']).day_count($var['sbSynced2'])."</strong>, finding <strong>{$var['sbSyncErrs']}</strong> error".($var['sbSyncErrs']==1?'.':'s.');
      echo "<br><i class='fa fa-dot-circle-o icon'></i><em>Error code: ".my_error($var['sbSyncExit'])."</em></td><td id='parity'></td></tr>";
      return;
    }
    if ($var['sbSynced']==0) {
      echo "<tr><td><em>Parity has not been checked yet.<em></td><td id='parity'></td></tr>";
      return;
    }
    if ($var['sbSynced2']==0) {
      $idle = $var['mdResync']==0;
      list($entry,$duration,$speed,$status,$error) = explode('|', read_parity_log($var['sbSynced'],!$idle));
      if ($status==0) {
        echo "<tr><td>".($idle ? "Last checked on " : "Activity started on ")."<strong>".my_time($var['sbSynced']).day_count($var['sbSynced'])."</strong>, finding <strong>$error</strong> error".($error==1?'.':'s.');
        echo "<br><i class='fa fa-clock-o icon'></i><em>".($idle ? "Duration: " : "Last result: ").my_check($duration,$speed)."</em></td><td id='parity'></td></tr>";
      } else {
        echo "<tr><td>Last check incomplete on <strong>".my_time($var['sbSynced']).day_count($var['sbSynced'])."</strong>, finding <strong>$error</strong> error".($error==1?'.':'s.');
        echo "<br><i class='fa fa-dot-circle-o icon'></i><em>Error code: $status</em></td><td id='parity'></td></tr>";
      }
    } else {
      $status = 0;
      $duration = $var['sbSynced2']-$var['sbSynced'];
      $speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":'';
      echo "<tr><td>Last checked on <strong>".my_time($var['sbSynced2']).day_count($var['sbSynced2'])."</strong>, finding <strong>{$var['sbSyncErrs']}</strong> error".($var['sbSyncErrs']==1?'.':'s.');
      echo "<br><i class='fa fa-clock-o icon'></i><em>Duration: ".my_check($duration,$speed)."</em></td><td id='parity'></td></tr>";
    }
  } else {
    if (empty($var['mdInvalidDisk'])) {
      echo "<tr><td colspan='2'><span class='red p0'><strong>Parity is invalid</strong></span></td></tr>";
    } else {
      echo "<tr><td colspan='2'><span class='red p0'><strong>Data is invalid</strong></span></td></tr>";
    }
  }
}
function truncate($string,$len) {
  return strlen($string) < $len ? $string : substr($string,0,$len-3).'...';
}
function export_settings($protocol,$share) {
  if ($protocol!='yes' || $share['export']=='-') return "-";
  if ($share['export']=='e') return ucfirst($share['security']);
  return '<em>'.ucfirst($share['security']).'</em>';
}
function active_disks($disk) {
  return substr($disk['status'],0,7)!='DISK_NP' && preg_match('/^(Parity|Data|Cache)$/',$disk['type']);
}
$disks = array_filter($disks,'active_disks');
$slots = count($disks) + count($devs);
?>
<table class='share_status fixed'>
<thead><tr>
<?
$row0 = array_fill(0,30,"<td>-</td>"); $i = 0;
foreach ($disks as $disk) if ($disk['type']=='Parity') $row0[$i++] = "<td>Parity<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
foreach ($disks as $disk) if ($disk['type']=='Data') $row0[$i++] = "<td>Disk<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
if ($slots <= 30) {
  foreach ($disks as $disk) if ($disk['type']=='Cache') $row0[$i++] = "<td>Cache<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
  foreach ($devs as $dev) $row0[$i++] = "<td>{$dev['device']}</td>";
}
echo "<td>Array Status</td>".implode('',$row0);
?>
</tr></thead>
<tbody id='dash0'>
<?init_row('Active')?>
<?init_row('Inactive')?>
<?init_row('Unassigned')?>
<?init_row('Faulty')?>
<?init_row('Heat alarm')?>
<?init_row('SMART status')?>
<?init_row('Utilization')?>
</tbody>
</table>
<?if ($slots > 30):?>
<br>
<table class='share_status fixed'>
<thead><tr>
<?
$row0 = array_fill(0,30,"<td>-</td>"); $i = 0;
foreach ($disks as $disk) if ($disk['type']=='Cache') $row0[$i++] = "<td>Cache<br>&nbsp;".filter_var($disk['name'],FILTER_SANITIZE_NUMBER_INT)."&nbsp;</td>";
foreach ($devs as $dev) $row0[$i++] = "<td>{$dev['device']}</td>";
echo "<td>Array Status</td>".implode('',$row0);
?>
</tr></thead>
<tbody id='dash1'>
<?init_row('Active')?>
<?init_row('Inactive')?>
<?init_row('Unassigned')?>
<?init_row('Faulty')?>
<?init_row('Heat alarm')?>
<?init_row('SMART status')?>
<?init_row('Utilization')?>
</tbody>
</table>
<?endif;?>

<table class='share_status table'>
<thead><tr><td colspan='2'>Parity Status</td></tr></thead>
<tbody><?=parity_status()?></tbody>
</table>
<table class='share_status dash line'>
<thead><tr><td colspan='3'>System Status</td><td>
<select name="enter_view" size="1" class="auto" onchange="changeView(this.value)">
<?=mk_option("", "0", "General")?>
<?=mk_option("", "1", "Counters")?>
<?=mk_option("", "2", "Errors")?>
</select>
</td></tr><tr><td colspan='4' style='text-align:center'>Load Statistics</td></tr></thead>
<tbody>
<tr class='wide'><td>Avg. CPU load</td><td colspan='3'><div class='usage-disk sys'><span id='cpu' style='width:0'></span></div></td></tr>
</tbody>
<tbody class='cpu_open' style='display:none'>
<?if (count($cpus)>1):?><tr><td rowspan='<?=count($cpus)?>'><?else:?><tr class='wide'><td><?endif;?><a href='#' onclick='toggle_CPU()' title='Click to hide details' class='none'>Per CPU load</a><span class='red-text'> *</span></td>
<?
$tr = false;
foreach ($cpus as $pair):
  list($cpu1, $cpu2) = preg_split('/[,-]/',$pair);
  if ($tr) echo "<tr>";
  if (isset($cpu2))
    echo "<td>cpu $cpu1 / $cpu2</td><td><div class='usage-disk sys'><span id='cpu$cpu1' style='width:0'></span></div></td><td><div class='usage-disk sys'><span id='cpu$cpu2' style='width:0'></span></div></td>";
  else
    echo "<td>cpu $cpu1</td><td colspan='2'><div class='usage-disk sys'><span id='cpu$cpu1' style='width:0'></span></div></td>";
  echo "</tr>";
  $tr = true;
endforeach;
?>
</tbody>
<tbody class='cpu_closed' style='display:none'>
<?
$text = '';
foreach ($cpus as $pair):
  list($cpu1, $cpu2) = preg_split('/[,-]/',$pair);
  if ($text) $text .= ", ";
  $text .= isset($cpu2) ? "[$cpu1/$cpu2]" : $cpu1;
endforeach;
?>
<tr class='wide'><td><a href='#' onclick='toggle_CPU()' title='Click to show details' class='none'>Per CPU load</a><span class='red-text'> *</span></td><td colspan='3' style='text-align:center'><?=$text?></td></tr>
</tbody>
<tbody>
<?
if ($fans>0):
  echo $fans>2 ? "<tr><td rowspan='".ceil($fans/2)."'>" : "<tr class='wide'><td>";
  echo "FAN speed</td>";
  for ($f=0; $f<$fans; $f+=2):
    if ($f) echo "<tr>";
    if ($f+1<$fans)
      echo "<td>fan ".($f)." / ".($f+1)."</td><td class='blue' id='fan{$f}'>"."</td><td class='blue' id='fan".($f+1)."'></td>";
    else
      echo "<td>fan ".($f)."</td><td colspan='2' class='blue' id='fan{$f}'>";
    echo "</tr>";
  endfor;
endif;
$dck = exec("df /var/lib/docker|grep -om1 '^/'");
?>
<tr class='wide'><td>Memory usage</td><td colspan='3'><div class='usage-disk sys'><span id='sys0' style='width:0'></span></div></td></tr>
<tr class='wide'><td>flash log docker</td><td><div class='usage-disk sys'><span id='sys1' style='width:0'></span></div></td><td><div class='usage-disk sys'><span id='sys2' style='width:0'></span></div></td>
<td><?if ($dck):?><div class='usage-disk sys'><span id='sys3' style='width:0'></span></div><?else:?>Not available<?endif;?></td></tr>
<tr><td rowspan='2'>Memory size</td><td>allocated</td><td colspan='2' class='blue'><?=my_scale($total,$unit,3)." $unit"?></td></tr>
<tr><td>installed</td><td colspan='2' class='blue'><?="$memory_installed GB (max. capacity $memory_maximum GB)"?></td></tr>
</tbody>
<tbody class='net_open' style='display:none'>
<?if (count($ports)>1):?><tr class='view1'><td rowspan='<?=count($ports)?>'><?else:?><tr class='view1 wide'><td><?endif;?><a href='#' onclick='toggle_net()' title='Click to hide details' class='none'>Network</a><span class='red-text'> *</span></td>
<?
$c = 0;
foreach ($ports as $port):
  if ($c) echo "<tr class='view1'>";
  echo "<td>$port</td><td colspan='2' class='blue' id='main".($c++)."'></td></tr>";
endforeach;
?>
<tr class='view2' style='display:none'><td rowspan='<?=count($ports)+1?>'><a href='#' onclick='toggle_net()' title='Click to hide details' class='none'>Network</a><span class='red-text'> *</span></td><td><i>Interface</i></td><td><i>Receive pkts</i></td><td><i>Transmit pkts</i></td></tr>
<?
$c = 0;
foreach ($ports as $port):
  echo "<tr class='view2' style='display:none'><td>$port</td><td class='blue' id='port{$c}'></td><td id='port".($c+1)."' class='blue'></td></tr>";
  $c += 2;
endforeach;
?>
<tr class='view3' style='display:none'><td rowspan='<?=count($ports)+1?>'><a href='#' onclick='toggle_net()' title='Click to hide details' class='none'>Network</a><span class='red-text'> *</span></td><td><i>Interface</i></td><td><i>Receive</i></td><td><i>Transmit</i></td></tr>
<?
$c = 0;
foreach ($ports as $port):
  echo "<tr class='view3' style='display:none'><td>$port</td><td class='blue' id='link{$c}'></td><td id='link".($c+1)."' class='blue'></td></tr>";
  $c += 2;
endforeach;
?>
</tbody>
<tbody class='net_closed' style='display:none'>
<?
$text = '';
foreach ($ports as $port):
  if ($text) $text .= ", ";
  $text .= $port;
endforeach;
?>
<tr class='wide'><td><a href='#' onclick='toggle_net()' title='Click to show details' class='none'>Network</a><span class='red-text'> *</span></td><td colspan='3' style='text-align:center'><?=$text?></td></tr>
</tbody>
</table>
<table class='share_status dash m0'>
<thead><tr><td colspan='4'>Users List</td></tr><tr><td>Name</td><td>Description</td><td>Write</td><td>Read</td></tr></thead>
<?if ($var['shareSMBEnabled']=='yes'):?>
<tbody class='smb'>
<?
foreach ($users as $user):
  $list = truncate($user['name'],12);
  $desc = truncate($user['desc'],28);
  if ($list=='root'):
    $write = '-'; $read = '-';
  else:
    $write = 0; $read = 0;
    foreach ($shares as $share):
      if (strpos($sec[$share['name']]['writeList'],$list)!==false) $write++;
      if (strpos($sec[$share['name']]['readList'],$list)!==false) $read++;
    endforeach;
  endif;
  echo "<tr><td>$list</td><td>$desc</td><td>$write</td><td>$read</td></tr>";
endforeach;
?>
</tbody>
<?endif;?>
<?if ($var['shareAFPEnabled']=='yes'):?>
<tbody class='afp'<?if ($var['shareSMBEnabled']=='yes'):?> style='display:none'<?endif;?>>
<?
foreach ($users as $user):
  $list = truncate($user['name'],12);
  $desc = truncate($user['desc'],28);
  if ($list=='root'):
    $write = '-'; $read = '-';
  else:
    $write = 0; $read = 0;
    foreach ($shares as $share):
      if (strpos($sec_afp[$share['name']]['writeList'],$list)!==false) $write++;
      if (strpos($sec_afp[$share['name']]['readList'],$list)!==false) $read++;
    endforeach;
  endif;
  echo "<tr><td>$list</td><td>$desc</td><td>$write</td><td>$read</td></tr>";
endforeach;
?>
</tbody>
<?endif;?>
<?if ($var['shareNFSEnabled']=='yes'):?>
<tbody class='nfs'<?if ($var['shareSMBEnabled']=='yes'||$var['shareAFPEnabled']=='yes'):?> style='display:none'<?endif;?>>
<?
foreach ($users as $user):
  $list = truncate($user['name'],12);
  $desc = truncate($user['desc'],28);
  $write = '-'; $read = '-';
  echo "<tr><td>$list</td><td>$desc</td><td>$write</td><td>$read</td></tr>";
endforeach;
?>
</tbody>
<?endif;?>
<?if (!$group):?>
<tbody>
<?
foreach ($users as $user):
  $list = truncate($user['name'],12);
  $desc = truncate($user['desc'],28);
  echo "<tr><td>$list</td><td>$desc</td><td>-</td><td>-</td></tr>";
endforeach;
?>
</tbody>
<?endif;?>
</table>
<table class='share_status dash m36'>
<thead><tr><td colspan='3'>Shares List</td><td>
<?if ($group):?>
<select name="enter_share" size="1" class="auto" onchange="changeMode(this.value)">
<?if ($var['shareSMBEnabled']=='yes'):?>
<?=mk_option("", "0", "SMB")?>
<?endif;?>
<?if ($var['shareAFPEnabled']=='yes'):?>
<?=mk_option("", "1", "AFP")?>
<?endif;?>
<?if ($var['shareNFSEnabled']=='yes'):?>
<?=mk_option("", "2", "NFS")?>
<?endif;?>
</select>
<?endif;?>
</td></tr><tr><td>Name</td><td>Description</td><td>Security</td><td>Streams</td></tr></thead>
<?if ($var['shareSMBEnabled']=='yes'):?>
<tbody class='smb'>
<?
$i = 0;
foreach ($shares as $name => $share):
  $i++;
  $list = truncate($name,12);
  $comment = truncate($share['comment'],28);
  $security = export_settings($var['shareSMBEnabled'], $sec[$name]);
  echo "<tr><td>$list</td><td>$comment</td><td>$security</td><td class='blue' id='share{$i}'>0</td></tr>";
endforeach;
if (!count($shares)) echo "<tr><td colspan='4' style='text-align:center;padding-top:12px'>No shares present</td></tr>";
?>
</tbody>
<?endif;?>
<?if ($var['shareAFPEnabled']=='yes'):?>
<tbody class='afp'<?if ($var['shareSMBEnabled']=='yes'):?> style='display:none'<?endif;?>>
<?
foreach ($shares as $name => $share):
  $list = truncate($name,12);
  $comment = truncate($share['comment'],28);
  $security = export_settings($var['shareAFPEnabled'], $sec_afp[$name]);
  echo "<tr><td>$list</td><td>$comment</td><td>$security</td><td>-</td></tr>";
endforeach;
if (!count($shares)) echo "<tr><td colspan='4' style='text-align:center;padding-top:12px'>No shares present</td></tr>";
?>
</tbody>
<?endif;?>
<?if ($var['shareNFSEnabled']=='yes'):?>
<tbody class='nfs'<?if ($var['shareSMBEnabled']=='yes'||$var['shareAFPEnabled']=='yes'):?> style='display:none'<?endif;?>>
<?
foreach ($shares as $name => $share):
  $list = truncate($name,12);
  $comment = truncate($share['comment'],28);
  $security = export_settings($var['shareNFSEnabled'], $sec_nfs[$name]);
  echo "<tr><td>$list</td><td>$comment</td><td>$security</td><td>-</td></tr>";
endforeach;
if (!count($shares)) echo "<tr><td colspan='4' style='text-align:center;padding-top:12px'>No shares present</td></tr>";
?>
</tbody>
<?endif;?>
<?if (!$group):?>
<tbody>
<?
foreach ($shares as $name => $share):
  $list = truncate($name,12);
  $comment = truncate($share['comment'],28);
  echo "<tr><td>$list</td><td>$comment</td><td>-</td><td>-</td></tr>";
endforeach;
if (!count($shares)) echo "<tr><td colspan='4' style='text-align:center;padding-top:12px'>No shares present</td></tr>";
?>
</tbody>
<?endif;?>
</table>

<script>
var timer2,timer30;

function changeMode(item) {
  if (item==0) $.removeCookie('enter_share',{path:'/'}); else $.cookie('enter_share',item,{path:'/',expires:3650});
<?if ($var['shareSMBEnabled']=='yes'):?>
  if (item==0) $('.smb').show(); else $('.smb').hide();
<?endif;?>
<?if ($var['shareAFPEnabled']=='yes'):?>
  if (item==1) $('.afp').show(); else $('.afp').hide();
<?endif;?>
<?if ($var['shareNFSEnabled']=='yes'):?>
  if (item==2) $('.nfs').show(); else $('.nfs').hide();
<?endif;?>
}
function changeView(item) {
  if (item==0) $.removeCookie('enter_view',{path:'/'}); else $.cookie('enter_view',item,{path:'/',expires:3650});
  if (item==0) $('.view1').show(); else $('.view1').hide();
  if (item==1) $('.view2').show(); else $('.view2').hide();
  if (item==2) $('.view3').show(); else $('.view3').hide();
  clearTimeout(timer30);
  update30();
}
function update3() {
<?if ($fans>0):?>
  $.post('<?=$url?>',{cmd:'fan'},function(data) {
    if (data) $.each(data.split('#'),function(k,v) {$('#fan'+k).html(v);});
  });
<?endif;?>
  $.post('<?=$url?>',{cmd:'cpu'},function(data) {
    if (data) $.each(data.split('#'),function(k,v) {
      var c = k==0 ? '' : k-1;
      $('#cpu'+c).animate({width:v},{step:function(){$('#cpu'+c).css('overflow','visible');}}).text(v);
    });
    setTimeout(update3,3000);
  });
}
function update15() {
<?if ($var['fsState']=='Started'):?>
  var tag = $('.smb').is(':visible') ? 'smb' : $('.afp').is(':visible') ? 'afp' : $('.nfs').is(':visible') ? 'nfs' : '';
  $.post('<?=$url?>',{cmd:'shares',com:tag,names:'<?=addslashes(htmlspecialchars($names))?>'},function(data) {
    if (data) $.each(data.split('#'),function(k,v) {$('#share'+(k+1)).html(v);});
    setTimeout(update15,15000);
  });
<?endif;?>
}
function update30() {
  var tag = $('.view1').css('display')!='none' ? 'main' : $('.view2').css('display')!='none' ? 'port' : $('.view3').css('display')!='none' ? 'link' : '';
  $.post('<?=$url?>',{cmd:'port',view:tag,ports:'<?=implode(',',$ports)?>'},function(data) {
    if (data) $.each(data.split('#'),function(k,v) {$('#'+tag+k).html(v);});
  });
  $.post('<?=$url?>',{cmd:'disk',hot:'<?=$display['hot']?>',max:'<?=$display['max']?>',unit:'<?=$display['unit']?>',slots:<?=$slots?>},function(data) {
<?if ($slots <= 30):?>
    if (data) $('#dash0').html(data);
<?else:?>
    if (data) $.each(data.split('#'),function(k,v) {$('#dash'+k).html(v);});
<?endif;?>
    clearTimeout(timer2);
    timer2 = setTimeout(heatAlarm,2000);
    $('[id^="smart-"]').each(function() {
      var opts = [{header:$(this).attr('id'), image:'/webGui/icons/smart.png'}];
      var id = '#'+$(this).attr('id');
      var page = $(this).attr('name');
      var view = $(this).attr('class');
      var disk = id.substr(id.indexOf('-')+1);
      opts.push({text:'Attributes',icon:'fa-sitemap',action:function(e){e.preventDefault();attributes(page,disk);}});
      opts.push({divider:true});
      opts.push({text:'Capabilities',icon:'fa-user',action:function(e){e.preventDefault();capabilities(page,disk);}});
      opts.push({divider:true});
      opts.push({text:'Identity',icon:'fa-home',action:function(e){e.preventDefault();identity(page,disk);}});
      if (view == 'alert') {
        opts.push({divider:true});
        opts.push({text:'Acknowledge',icon:'fa-check-square-o',action:function(e){e.preventDefault();acknowledge(disk);}});
      }
      context.attach(id,opts);
    });
    timer30 = setTimeout(update30,30000);
  });
}
function update60() {
<?if ($var['mdNumInvalid']==0 && $var['mdResync']>0):?>
  $.post('<?=$url?>',{cmd:'parity'},function(data) {
    if (data) $('#parity').html(data);
  });
<?endif;?>
  $.post('<?=$url?>',{cmd:'sys'},function(data) {
    if (data) $.each(data.split('#'),function(k,v) {$('#sys'+k).animate({width:v},{step:function(){$('#sys'+k).css('overflow','visible');}}).text(v);});
    setTimeout(update60,60000);
  });
}
function heatAlarm() {
  if ($('.heat-img').length) {
    if ($('.heat-text').is(':visible')) {$('.heat-text').hide(); $('.heat-img').show();} else {$('.heat-img').hide(); $('.heat-text').show();}
  }
  timer2 = setTimeout(heatAlarm,2000);
}
function attributes(page,disk) {
  var tab = page=='New' ? 'tab2' : 'tab3';
  $.cookie('one',tab,{path:'/'});
  location.replace('/Dashboard/'+page+'?name='+disk);
}
function capabilities(page,disk) {
  var tab = page=='New' ? 'tab3' : 'tab4';
  $.cookie('one',tab,{path:'/'});
  location.replace('/Dashboard/'+page+'?name='+disk);
}
function identity(page,disk) {
  var tab = page=='New' ? 'tab4' : 'tab5';
  $.cookie('one',tab,{path:'/'});
  location.replace('/Dashboard/'+page+'?name='+disk);
}
function acknowledge(disk) {
  $.post('/webGui/include/Acknowledge.php',{disk:disk},function(data){clearTimeout(timer30);update30();});
}
function dropdown(menu) {
  var select = 'select[name="'+menu+'"]';
  if ($.cookie(menu) == null || $.cookie(menu) >= $(select+' option').length) return;
  $(select+' option')[$.cookie(menu)].selected = true;
  $(select).change();
}
function toggle_CPU(init) {
  if (!init) {
    if ($.cookie('cpu')===undefined) $.cookie('cpu','close',{path:'/',expires:3650}); else $.removeCookie('cpu',{path:'/'});
  }
  if ($.cookie('cpu')===undefined) {
    $('.cpu_open').show();
    $('.cpu_closed').hide();
  } else {
    $('.cpu_open').hide();
    $('.cpu_closed').show();
  }
}
function toggle_net(init) {
  if (!init) {
    if ($.cookie('net')===undefined) $.cookie('net','close',{path:'/',expires:3650}); else $.removeCookie('net',{path:'/'});
  }
  if ($.cookie('net')===undefined) {
    $('.net_open').show();
    $('.net_closed').hide();
  } else {
    $('.net_open').hide();
    $('.net_closed').show();
  }
}
$(function() {
  dropdown('enter_share');
  dropdown('enter_view');
  toggle_CPU(true);
  toggle_net(true);
  update3();
  update60();
  update30();
  update15();
<?if ($display['refresh']==0 || ($display['refresh']<0 && $var['mdResync']>0)):?>
  $('.tabs').append("<span class='status vhshift'><input type='button' value='Refresh' onclick='refresh()'></span>");
<?endif;?>
  context.init({preventDoubleContext:false});
});
</script>
