aboutsummaryrefslogtreecommitdiff
path: root/www/status.php
blob: a57c121a2ae1d42bd9340a549dc2bd44c8ae1170 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace phinde;
require 'www-header.php';

$es = new Elasticsearch($GLOBALS['phinde']['elasticsearch']);
$esStatus = $es->getIndexStatus();

$queue = new Queue();
$gearStatus = $queue->getServerStatus();

$subDb = new Subscriptions();
$subCount = $subDb->count();

/**
 * @link http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
 */
function human_filesize($bytes, $decimals = 2)
{
    $size = array('B','kiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB');
    $factor = floor((strlen($bytes) - 1) / 3);
    return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor))
        . ' ' . @$size[$factor];
}

$esStatus['size_human']      = human_filesize($esStatus['size']);
$esStatus['documents_human'] = number_format(
    $esStatus['documents'], 0, '.', ' '
);

render(
    'status',
    array(
        'esStatus'   => $esStatus,
        'gearStatus' => $gearStatus,
        'subCount'   => $subCount,
        'subSum'     => array_sum($subCount),
    )
);
?>