forked from erikdubbelboer/phpRedisAdmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
overview.php
90 lines (58 loc) · 2.42 KB
/
overview.php
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
require_once 'includes/common.inc.php';
$info = array();
foreach ($config['servers'] as $i => $server) {
if (!isset($server['db'])) {
$server['db'] = 0;
}
// Setup a connection to this Redis server.
$redis = new Predis\Client('tcp://'.$server['host'].':'.$server['port']);
if (isset($server['auth'])) {
if (!$redis->auth($server['auth'])) {
die('ERROR: Authentication failed ('.$server['host'].':'.$server['port'].')');
}
}
if ($server['db'] != 0) {
if (!$redis->select($server['db'])) {
die('ERROR: Selecting database failed ('.$server['host'].':'.$server['port'].','.$server['db'].')');
}
}
$info[$i] = $redis->info();
$info[$i]['size'] = $redis->dbSize();
if (!isset($info[$i]['Server'])) {
$info[$i]['Server'] = array(
'redis_version' => $info[$i]['redis_version'],
'uptime_in_seconds' => $info[$i]['uptime_in_seconds']
);
}
if (!isset($info[$i]['Memory'])) {
$info[$i]['Memory'] = array(
'used_memory' => $info[$i]['used_memory']
);
}
}
$page['css'][] = 'frame';
$page['js'][] = 'frame';
require 'includes/header.inc.php';
?>
<?php foreach ($config['servers'] as $i => $server) { ?>
<div class="server">
<h2><?php echo isset($server['name']) ? $server['name'] : format_html($server['host'])?></h2>
<table>
<tr><td><div>Redis version:</div></td><td><div><?php echo $info[$i]['Server']['redis_version']?></div></td></tr>
<tr><td><div>Keys:</div></td><td><div><?php echo $info[$i]['size']?></div></td></tr>
<tr><td><div>Memory used:</div></td><td><div><?php echo format_size($info[$i]['Memory']['used_memory'])?></div></td></tr>
<tr><td><div>Uptime:</div></td><td><div><?php echo format_ago($info[$i]['Server']['uptime_in_seconds'])?></div></td></tr>
<tr><td><div>Last save:</div></td><td><div><?php if (isset($info[$i]['Persistence']['rdb_last_save_time'])) { echo format_ago(time() - $info[$i]['Persistence']['rdb_last_save_time'], true); } else { echo 'never'; } ?> <a href="save.php?s=<?php echo $i?>"><img src="images/save.png" width="16" height="16" title="Save Now" alt="[S]" class="imgbut"></a></div></td></tr>
</table>
</div>
<?php } ?>
<p class="clear">
<a href="https://github.com/ErikDubbelboer/phpRedisAdmin" target="_blank">phpRedisAdmin on GitHub</a>
</p>
<p>
<a href="http://redis.io/documentation" target="_blank">Redis Documentation</a>
</p>
<?php
require 'includes/footer.inc.php';
?>