improve status page
[phinde.git] / www / status.php
1 <?php
2 namespace phinde;
3 require 'www-header.php';
4
5 $es = new Elasticsearch($GLOBALS['phinde']['elasticsearch']);
6 $esStatus = $es->getIndexStatus();
7
8 $queue = new Queue();
9 $gearStatus = $queue->getServerStatus();
10
11 /**
12  * @link http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
13  */
14 function human_filesize($bytes, $decimals = 2)
15 {
16     $size = array('B','kiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB');
17     $factor = floor((strlen($bytes) - 1) / 3);
18     return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor))
19         . ' ' . @$size[$factor];
20 }
21
22 $esStatus['size_human'] = human_filesize($esStatus['size']);
23
24 render(
25     'status',
26     array(
27         'esStatus'   => $esStatus,
28         'gearStatus' => $gearStatus,
29     )
30 );
31 ?>