add log file support
[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 $subDb = new Subscriptions();
12 $subCount = $subDb->count();
13
14 /**
15  * @link http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
16  */
17 function human_filesize($bytes, $decimals = 2)
18 {
19     $size = array('B','kiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB');
20     $factor = floor((strlen($bytes) - 1) / 3);
21     return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor))
22         . ' ' . @$size[$factor];
23 }
24
25 $esStatus['size_human']      = human_filesize($esStatus['size']);
26 $esStatus['documents_human'] = number_format(
27     $esStatus['documents'], 0, '.', ' '
28 );
29
30 render(
31     'status',
32     array(
33         'esStatus'   => $esStatus,
34         'gearStatus' => $gearStatus,
35         'subCount'   => $subCount,
36         'subSum'     => array_sum($subCount),
37     )
38 );
39 ?>