autofocus input field if there is no query
[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 $esStatus['documents_human'] = number_format(
24     $esStatus['documents'], 0, '.', ' '
25 );
26
27 render(
28     'status',
29     array(
30         'esStatus'   => $esStatus,
31         'gearStatus' => $gearStatus,
32     )
33 );
34 ?>