forked from erikdubbelboer/phpRedisAdmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverview.php
84 lines (52 loc) · 2.06 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
<?php
require_once '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->close();
try {
$redis->connect($server['host'], $server['port']);
} catch (Exception $e) {
die('ERROR: Could not connect to Redis ('.$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();
}
$page['css'][] = 'frame';
$page['js'][] = 'frame';
require '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]['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]['used_memory'])?></div></td></tr>
<tr><td><div>Uptime:</div></td><td><div><?php echo format_ago($info[$i]['uptime_in_seconds'])?></div></td></tr>
<tr><td><div>Last save:</div></td><td><div><?php echo format_ago(time() - $info[$i]['last_save_time'], true)?> <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 'footer.inc.php';
?>