ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
memcachestat.php
Go to the documentation of this file.
1<?php
2
3function tdate($input) {
4 return date(DATE_RFC822, $input);
5}
6
7function hours($input) {
8 if ($input < 60) return number_format($input, 2) . ' sec';
9 if ($input < 60*60) return number_format(($input/60),2) . ' min';
10 if ($input < 24*60*60) return number_format(($input/(60*60)),2) . ' hours';
11 return number_format($input/(24*60*60),2) . ' days';
12
13}
14
15
17
18 $output = "";
19 $input = abs($input);
20
21 if ($input >= (1024*1024*1024*1024*1024*1024*1024*100)) {
22 $output = sprintf("%5ldEi", $input / (1024*1024*1024*1024*1024*1024) );
23 } else if ($input >= (1024*1024*1024*1024*1024*1024*10)) {
24 $output = sprintf("%5.1fEi", $input / (1024.0*1024.0*1024.0*1024.0*1024.0*1024.0) );
25 } else if ($input >= (1024*1024*1024*1024*1024*1024)) {
26 $output = sprintf("%5.2fEi", $input / (1024.0*1024.0*1024.0*1024.0*1024.0*1024.0) );
27
28
29 } else if ($input >= (1024*1024*1024*1024*1024*100)) {
30 $output = sprintf("%5ldPi", $input / (1024*1024*1024*1024*1024) );
31 } else if ($input >= (1024*1024*1024*1024*1024*10)) {
32 $output = sprintf("%5.1fPi", $input / (1024.0*1024.0*1024.0*1024.0*1024.0) );
33 } else if ($input >= (1024*1024*1024*1024*1024)) {
34 $output = sprintf("%5.2fPi", $input / (1024.0*1024.0*1024.0*1024.0*1024.0) );
35
36 } else if ($input >= (1024*1024*1024*1024*100)) {
37 $output = sprintf("%5ldTi", $input / (1024*1024*1024*1024) );
38 } else if ($input >= (1024*1024*1024*1024*10)) {
39 $output = sprintf("%5.1fTi", $input / (1024.0*1024.0*1024.0*1024.0) );
40 } else if ($input >= (1024*1024*1024*1024)) {
41 $output = sprintf("%5.2fTi", $input / (1024.0*1024.0*1024.0*1024.0) );
42
43
44 } else if ($input >= (1024*1024*1024*100)) {
45 $output = sprintf("%5ldGi", $input / (1024*1024*1024) );
46 } else if ($input >= (1024*1024*1024*10)) {
47 $output = sprintf("%5.1fGi", $input / (1024.0*1024.0*1024.0) );
48 } else if ($input >= (1024*1024*1024)) {
49 $output = sprintf("%5.2fGi", $input / (1024.0*1024.0*1024.0) );
50
51 } else if ($input >= (1024*1024*100)) {
52 $output = sprintf("%5ldMi", $input / (1024*1024) );
53 } else if ($input >= (1024*1024*10)) {
54 $output = sprintf("%5.1fM", $input / (1024.0*1024.0) );
55 } else if ($input >= (1024*1024)) {
56 $output = sprintf("%5.2fMi", $input / (1024.0*1024.0) );
57
58 } else if ($input >= (1024 * 100)) {
59 $output = sprintf("%5ldKi", $input / (1024) );
60 } else if ($input >= (1024 * 10)) {
61 $output = sprintf("%5.1fKi", $input / 1024.0 );
62 } else if ($input >= (1024)) {
63 $output = sprintf("%5.2fKi", $input / 1024.0 );
64
65 } else {
66 $output = sprintf("%5ld", $input );
67 }
68
69 return $output;
70}
71
72
73
74
76
77// Make sure that the user has admin access rights
79
80
81$formats = array(
82 'bytes' => 'humanreadable',
83 'bytes_read' => 'humanreadable',
84 'bytes_written' => 'humanreadable',
85 'limit_maxbytes' => 'humanreadable',
86 'time' => 'tdate',
87 'uptime' => 'hours',
88);
89
91
93
94foreach($stats AS $key => &$entry) {
95 if (array_key_exists($key, $formats)) {
96 $func = $formats[$key];
97 foreach($entry AS $k => $val) {
98 $entry[$k] = $func($val);
99 }
100 }
101
102}
103
104$t = new SimpleSAML_XHTML_Template($config, 'memcacheMonitor:memcachestat.tpl.php');
106 'accepting_conns' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:accepting_conns}'),
107 'auth_cmds' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:auth_cmds}'),
108 'auth_errors' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:auth_errors}'),
109 'bytes' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:bytes}'),
110 'bytes_read' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:bytes_read}'),
111 'bytes_written' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:bytes_written}'),
112 'cas_badval' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cas_badval}'),
113 'cas_hits' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cas_hits}'),
114 'cas_misses' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cas_misses}'),
115 'cmd_flush' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cmd_flush}'),
116 'cmd_get' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cmd_get}'),
117 'cmd_set' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cmd_set}'),
118 'cmd_touch' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cmd_touch}'),
119 'connection_structures' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:connection_structures}'),
120 'conn_yields' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:conn_yields}'),
121 'curr_connections' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:curr_connections}'),
122 'curr_items' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:curr_items}'),
123 'decr_hits' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:decr_hits}'),
124 'decr_misses' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:decr_misses}'),
125 'delete_hits' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:delete_hits}'),
126 'delete_misses' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:delete_misses}'),
127 'expired_unfetched' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:expired_unfetched}'),
128 'evicted_unfetched' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:evicted_unfetched}'),
129 'evictions' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:evictions}'),
130 'get_hits' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:get_hits}'),
131 'get_misses' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:get_misses}'),
132 'hash_bytes' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:hash_bytes}'),
133 'hash_is_expanding' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:hash_is_expanding}'),
134 'hash_power_level' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:hash_power_level}'),
135 'incr_hits' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:incr_hits}'),
136 'incr_misses' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:incr_misses}'),
137 'libevent' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:libevent}'),
138 'limit_maxbytes' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:limit_maxbytes}'),
139 'listen_disabled_num' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:listen_disabled_num}'),
140 'pid' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:pid}'),
141 'pointer_size' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:pointer_size}'),
142 'reclaimed' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:reclaimed}'),
143 'reserved_fds' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:reserved_fds}'),
144 'rusage_system' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:rusage_system}'),
145 'rusage_user' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:rusage_user}'),
146 'threads' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:threads}'),
147 'time' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:time}'),
148 'total_connections' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:total_connections}'),
149 'total_items' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:total_items}'),
150 'touch_hits' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:touch_hits}'),
151 'touch_misses' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:touch_misses}'),
152 'uptime' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:uptime}'),
153 'version' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:version}'),
154);
155$t->data['title'] = 'Memcache stats';
156$t->data['rowtitles'] = $rowTitles;
157$t->data['table'] = $stats;
158$t->data['statsraw'] = $statsraw;
159$t->show();
An exception for terminatinating execution or to throw for unit testing.
static requireAdmin()
Require admin access to the current page.
Definition: Auth.php:60
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static getStats()
This function retrieves statistics about all memcache server groups.
Definition: Memcache.php:454
$key
Definition: croninfo.php:18
humanreadable($input)
$formats
$rowTitles
$config
foreach($stats AS $key=> &$entry) $t
$statsraw
hours($input)
Definition: memcachestat.php:7
$stats
tdate($input)
Definition: memcachestat.php:3
Attribute-related utility methods.