ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
memcachestat.php
Go to the documentation of this file.
1 <?php
2 
3 function tdate($input) {
4  return date(DATE_RFC822, $input);
5 }
6 
7 function 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 
16 function humanreadable($input) {
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 
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 
94 foreach($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' => $t->noop('{memcacheMonitor:memcachestat:accepting_conns}'),
107  'auth_cmds' => $t->noop('{memcacheMonitor:memcachestat:auth_cmds}'),
108  'auth_errors' => $t->noop('{memcacheMonitor:memcachestat:auth_errors}'),
109  'bytes' => $t->noop('{memcacheMonitor:memcachestat:bytes}'),
110  'bytes_read' => $t->noop('{memcacheMonitor:memcachestat:bytes_read}'),
111  'bytes_written' => $t->noop('{memcacheMonitor:memcachestat:bytes_written}'),
112  'cas_badval' => $t->noop('{memcacheMonitor:memcachestat:cas_badval}'),
113  'cas_hits' => $t->noop('{memcacheMonitor:memcachestat:cas_hits}'),
114  'cas_misses' => $t->noop('{memcacheMonitor:memcachestat:cas_misses}'),
115  'cmd_flush' => $t->noop('{memcacheMonitor:memcachestat:cmd_flush}'),
116  'cmd_get' => $t->noop('{memcacheMonitor:memcachestat:cmd_get}'),
117  'cmd_set' => $t->noop('{memcacheMonitor:memcachestat:cmd_set}'),
118  'cmd_touch' => $t->noop('{memcacheMonitor:memcachestat:cmd_touch}'),
119  'connection_structures' => $t->noop('{memcacheMonitor:memcachestat:connection_structures}'),
120  'conn_yields' => $t->noop('{memcacheMonitor:memcachestat:conn_yields}'),
121  'curr_connections' => $t->noop('{memcacheMonitor:memcachestat:curr_connections}'),
122  'curr_items' => $t->noop('{memcacheMonitor:memcachestat:curr_items}'),
123  'decr_hits' => $t->noop('{memcacheMonitor:memcachestat:decr_hits}'),
124  'decr_misses' => $t->noop('{memcacheMonitor:memcachestat:decr_misses}'),
125  'delete_hits' => $t->noop('{memcacheMonitor:memcachestat:delete_hits}'),
126  'delete_misses' => $t->noop('{memcacheMonitor:memcachestat:delete_misses}'),
127  'expired_unfetched' => $t->noop('{memcacheMonitor:memcachestat:expired_unfetched}'),
128  'evicted_unfetched' => $t->noop('{memcacheMonitor:memcachestat:evicted_unfetched}'),
129  'evictions' => $t->noop('{memcacheMonitor:memcachestat:evictions}'),
130  'get_hits' => $t->noop('{memcacheMonitor:memcachestat:get_hits}'),
131  'get_misses' => $t->noop('{memcacheMonitor:memcachestat:get_misses}'),
132  'hash_bytes' => $t->noop('{memcacheMonitor:memcachestat:hash_bytes}'),
133  'hash_is_expanding' => $t->noop('{memcacheMonitor:memcachestat:hash_is_expanding}'),
134  'hash_power_level' => $t->noop('{memcacheMonitor:memcachestat:hash_power_level}'),
135  'incr_hits' => $t->noop('{memcacheMonitor:memcachestat:incr_hits}'),
136  'incr_misses' => $t->noop('{memcacheMonitor:memcachestat:incr_misses}'),
137  'libevent' => $t->noop('{memcacheMonitor:memcachestat:libevent}'),
138  'limit_maxbytes' => $t->noop('{memcacheMonitor:memcachestat:limit_maxbytes}'),
139  'listen_disabled_num' => $t->noop('{memcacheMonitor:memcachestat:listen_disabled_num}'),
140  'pid' => $t->noop('{memcacheMonitor:memcachestat:pid}'),
141  'pointer_size' => $t->noop('{memcacheMonitor:memcachestat:pointer_size}'),
142  'reclaimed' => $t->noop('{memcacheMonitor:memcachestat:reclaimed}'),
143  'reserved_fds' => $t->noop('{memcacheMonitor:memcachestat:reserved_fds}'),
144  'rusage_system' => $t->noop('{memcacheMonitor:memcachestat:rusage_system}'),
145  'rusage_user' => $t->noop('{memcacheMonitor:memcachestat:rusage_user}'),
146  'threads' => $t->noop('{memcacheMonitor:memcachestat:threads}'),
147  'time' => $t->noop('{memcacheMonitor:memcachestat:time}'),
148  'total_connections' => $t->noop('{memcacheMonitor:memcachestat:total_connections}'),
149  'total_items' => $t->noop('{memcacheMonitor:memcachestat:total_items}'),
150  'touch_hits' => $t->noop('{memcacheMonitor:memcachestat:touch_hits}'),
151  'touch_misses' => $t->noop('{memcacheMonitor:memcachestat:touch_misses}'),
152  'uptime' => $t->noop('{memcacheMonitor:memcachestat:uptime}'),
153  'version' => $t->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();
foreach($stats AS $key=> &$entry) $t
static requireAdmin()
Require admin access to the current page.
Definition: Auth.php:60
$statsraw
tdate($input)
Definition: memcachestat.php:3
$formats
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
$config
hours($input)
Definition: memcachestat.php:7
humanreadable($input)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
$rowTitles
$key
Definition: croninfo.php:18
$stats
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:455