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
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
442
  
443
  
444
  
445
  
446
  
447
  
448
  
449
  
450
  
451
  
452
  
453
  
454
  
455
  
456
  
457
  
458
  
459
  
460
  
461
  
462
  
463
  
464
  
465
  
466
  
467
  
468
  
469
  
470
  
471
  
472
  
473
  
474
  
475
  
476
  
477
  
478
  
479
  
480
  
481
  
482
  
483
  
484
  
485
  
486
  
487
  
488
  
489
  
490
  
491
  
492
  
493
  
494
  
495
  
496
  
497
  
498
  
499
  
500
  
501
  
502
  
503
  
504
  
505
  
506
  
507
  
508
  
// $Id$ 
 
#include <roxen.h> 
//<locale-token project="admin_tasks">LOCALE</locale-token> 
#define LOCALE(X,Y)   _STR_LOCALE("admin_tasks",X,Y) 
 
constant action = "status"; 
 
string name= LOCALE(59, "Cache status"); 
string doc = LOCALE(60,  
                    "Show information about the main memory cache in Roxen"); 
 
#define VALUE_NA "<span class='dimtext'>n/a</span>" 
 
string format_hit_rate (int|float hits, int|float misses) 
{ 
  catch { 
    float res = hits * 100.0 / (hits + misses); 
    return sprintf ("%.1f%%", res); 
  }; 
  return VALUE_NA; 
} 
 
// Should use external css instead. I'm lazy.. 
#define TABLE_ATTRS                                                   \ 
  "style='font-size: 85%; border-collapse: collapse; white-space: nowrap; line-height: 1.3; background: #f4f6f8; border: 8px solid #f4f6f8;'" 
#define HDR_TR_ATTRS                                                        \ 
  "style='text-align: right; border-bottom: 1px solid #678;'" 
#define BODY_TR_ATTRS(ROW)                                          \ 
  "style='text-align: right; " +                                        \ 
    (ROW ? "border-top: 2px solid transparent;" : "") + "'" 
#define FTR_TR_ATTRS                                                        \ 
  "style='text-align: right; border-top: 1px solid #678;'" 
#define FIRST_CELL                                                  \ 
  "style='text-align: left; padding: 0;'" 
#define REST_CELLS                                                  \ 
  "style='white-space: nowrap; padding: 0 0 0 3ex;'" 
 
#define DESCR_ROW(ROW, DESCR, VALUE)                                  \ 
  "<tr " BODY_TR_ATTRS (ROW) ">"                                        \ 
    "<td " FIRST_CELL ">" + (DESCR) + "</td>"                           \ 
    "<td " REST_CELLS ">" + (VALUE) + "</td>"                           \ 
    "</tr>" 
 
string parse( RequestID id ) 
{ 
  string res = 
    "<input type='hidden' name='action' value='cachestatus.pike' />" 
    "<p><cf-refresh/> <cf-cancel href='?class=&form.class;&amp;&usr.set-wiz-id;'/></p>\n" 
    "<h3>"+ 
    LOCALE(61, "WebServer Memory Cache")+ 
    "</h3>\n" 
    "<p><a href='/global_settings/?section=Cache&amp;&usr.set-wiz-id;'>" + 
    LOCALE(380, "Configure Cache Settings") + "</a></p>\n"; 
 
  mapping(cache.CacheManager:mapping(string:cache.CacheStats)) stats = 
    cache.cache_stats(); 
 
  mapping trans = ([ 
    "supports":LOCALE(68,"Supports database"), 
    "fonts":LOCALE(69,"Fonts"), 
    "hosts":LOCALE(70,"DNS"), 
  ]); 
 
  string mgr_summary = "<p>" + 
    sprintf (LOCALE(381, #"\ 
The configured maximum size %s is divided dynamically between the 
cache managers based on the usage for the last half hour. If the 
caches are not full then all free space is assigned to each one of 
them. They will shrink to the configured maximum size as they fill up."), 
             "<b>" + Roxen.sizetostring (cache->total_size_limit) + "</b>") + 
    "</p>\n" 
    "<table " TABLE_ATTRS ">\n" 
    "<tr " HDR_TR_ATTRS ">" 
    "<th " FIRST_CELL ">" + LOCALE(382, "Cache manager") + "</th>" 
    "<th " REST_CELLS ">" + LOCALE(64, "Size") + "</th>" 
    "<th " REST_CELLS ">" + LOCALE(383, "Size limit") + "</th>" 
    "<th " REST_CELLS ">" + LOCALE(384, "Input rate") + "</th>" 
    "<th " REST_CELLS ">" + LOCALE(67, "Hit rate") + "</th>" 
    "<th " REST_CELLS ">" + LOCALE(385, "Cost HR") + "</th>" 
#ifdef DEBUG_CACHE_MANAGER 
    "<th " REST_CELLS " colspan='2'>Entry size</th>" 
    "<th " REST_CELLS " colspan='2'>Entry cost</th>" 
    "<th " REST_CELLS " colspan='2'>Entry value</th>" 
    "<th " REST_CELLS " colspan='2'>Entry pri val</th>" 
#endif 
    "</tr>\n"; 
 
  string mgr_stats = ""; 
 
  foreach (cache.cache_managers; int mgr_idx; cache.CacheManager mgr) 
    if (mapping(string:cache.CacheStats) caches = stats[mgr]) { 
      mgr_stats += 
        "<p><b>" + (LOCALE(386, "Cache manager: ") + 
                    Roxen.html_encode_string (mgr->name)) + "</b></p>\n" 
        "<p>" + mgr->doc + "</p>\n"; 
 
      string table = 
        "<table " TABLE_ATTRS ">\n" 
        "<tr " HDR_TR_ATTRS ">" 
        "<th " FIRST_CELL ">"+LOCALE(402, "Cache")+"</th>" 
        "<th " REST_CELLS ">"+LOCALE(295, "Entries")+"</th>" 
        "<th " REST_CELLS ">"+LOCALE(387, "Lookups")+"</th>" 
        "<th " REST_CELLS ">"+LOCALE(67, "Hit rate")+"</th>" 
        "<th " REST_CELLS ">"+LOCALE(64, "Size")+"</th>" 
        "<th " REST_CELLS ">"+LOCALE(388, "Size/entry")+"</th>" 
#ifdef CACHE_BYTE_HR_STATS 
      "<th " REST_CELLS ">"+LOCALE(389, "Byte HR")+"</th>" 
#endif 
      "<th " REST_CELLS ">"+LOCALE(390, "Create cost")+"</th>" 
        "<th " REST_CELLS ">"+LOCALE(391, "Cost/entry")+"</th>" 
        "<th " REST_CELLS ">"+LOCALE(385, "Cost HR")+"</th>" 
        "</tr>\n"; 
 
      int num_caches; 
      int tot_count, tot_size; 
      int tot_hits, tot_misses; 
#ifdef CACHE_BYTE_HR_STATS 
      int tot_byte_hits, tot_byte_misses; 
#endif 
      int|float tot_cost_hits, tot_cost_misses, tot_cost; 
#ifdef DEBUG_CACHE_MANAGER 
      int min_size = Int.NATIVE_MAX, max_size; 
      int|float min_cost = Float.MAX, max_cost; 
      int|float min_value = Float.MAX, max_value; 
      int|float min_pval = Float.MAX, max_pval; 
#endif 
 
      mapping(string:array(string)) cache_groups = ([]); 
      // FIXME: The following should be redundant given the 
      //        integrated grouping of CacheStats. 
      foreach (caches; string cache_name;) { 
        sscanf (cache_name, "%[^:]", string group_name); 
        cache_groups[group_name] += ({cache_name}); 
      } 
 
      // FIXME: The following looks broken. 
      mapping(string:string) name_trans = 
        mkmapping (indices (cache_groups), indices (cache_groups)); 
      foreach (trans; string name; string trans) 
        if (m_delete (name_trans, name)) 
          name_trans[trans] = name; 
 
      foreach (sort (indices (name_trans)); int row; string trans_name) { 
        string group_name = name_trans[trans_name]; 
 
        num_caches++; 
 
        int grp_count, grp_size; 
        int grp_hits, grp_misses; 
#ifdef CACHE_BYTE_HR_STATS 
      int grp_byte_hits, grp_byte_misses; 
#endif 
      int|float grp_cost_hits, grp_cost_misses, grp_cost; 
 
        foreach (cache_groups[group_name], string cache_name) { 
          cache.CacheStats st = caches[cache_name]; 
 
          grp_count += st->count; 
          grp_hits += st->hits; 
          grp_misses += st->misses; 
          grp_size += st->size; 
#ifdef CACHE_BYTE_HR_STATS 
        grp_byte_hits += st->byte_hits; 
          grp_byte_misses += st->byte_misses; 
#endif 
        grp_cost_hits += st->cost_hits; 
          grp_cost_misses += st->cost_misses; 
 
          int|float cost; 
          foreach (cache.cache_entries (cache_name);; cache.CacheEntry entry) { 
            int|float c = entry->cost; 
            cost += c; 
#ifdef DEBUG_CACHE_MANAGER 
          if (c > max_cost) max_cost = c; 
            if (c < min_cost) min_cost = c; 
            int s = entry->size; 
            if (s > max_size) max_size = s; 
            if (s < min_size) min_size = s; 
            int|float v = entry->value; 
            if (v > max_value) max_value = v; 
            if (v < min_value) min_value = v; 
            v = entry->pval; 
            if (v > max_pval) max_pval = v; 
            if (v < min_pval) min_pval = v; 
#endif 
        } 
          grp_cost += cost; 
        } 
 
        table += 
          "<tr " BODY_TR_ATTRS (row) ">" 
          "<td " FIRST_CELL ">" + 
          Roxen.html_encode_string (trans[group_name] || group_name) + "</td>" 
          "<td " REST_CELLS ">" + grp_count + "</td>" 
          "<td " REST_CELLS ">" + (grp_hits + grp_misses) + "</td>" 
          "<td " REST_CELLS ">" + 
          format_hit_rate (grp_hits, grp_misses) + "</td>" 
          "<td " REST_CELLS ">" + 
          Roxen.sizetostring (grp_size) + "</td>" 
          "<td " REST_CELLS ">" + 
          Roxen.sizetostring (grp_count && (float) grp_size / grp_count) + 
          "</td>" 
#ifdef CACHE_BYTE_HR_STATS 
        "<td " REST_CELLS ">" + 
          format_hit_rate (grp_byte_hits, grp_byte_misses) + "</td>" 
#endif 
        "<td " REST_CELLS ">" + 
          (mgr->has_cost ? mgr->format_cost (grp_cost) : VALUE_NA) + "</td>" 
          "<td " REST_CELLS ">" + 
          (mgr->has_cost ? 
           mgr->format_cost (grp_count && grp_cost / grp_count) : VALUE_NA) + 
          "</td>" 
          "<td " REST_CELLS ">" + 
          (mgr->has_cost ? 
           format_hit_rate (grp_cost_hits, grp_cost_misses) : VALUE_NA) + "</td>" 
          "</tr>\n"; 
 
        tot_count += grp_count; 
        tot_hits += grp_hits; 
        tot_misses += grp_misses; 
        tot_size += grp_size; 
#ifdef CACHE_BYTE_HR_STATS 
      tot_byte_hits += grp_byte_hits; 
        tot_byte_misses += grp_byte_misses; 
#endif 
      tot_cost_hits += grp_cost_hits; 
        tot_cost_misses += grp_cost_misses; 
        tot_cost += grp_cost; 
      } 
 
      mgr_summary += "<tr " BODY_TR_ATTRS (mgr_idx) ">" 
        "<td " FIRST_CELL ">" + Roxen.html_encode_string (mgr->name) + "</td>" 
        "<td " REST_CELLS ">" + 
        Roxen.sizetostring (tot_size) + "</td>" 
        "<td " REST_CELLS ">" + 
        Roxen.sizetostring (mgr->total_size_limit) + "</td>" 
        "<td " REST_CELLS ">" + 
        Roxen.sizetostring (mgr->add_rate) + "/s</td>" 
        "<td " REST_CELLS ">" + 
        format_hit_rate (mgr->hits, mgr->misses) + "</td>" 
        "<td " REST_CELLS ">" + 
        (mgr->has_cost ? 
         format_hit_rate (mgr->cost_hits, mgr->cost_misses) : 
         format_hit_rate (mgr->hits, mgr->misses)) + "</td>" 
#ifdef DEBUG_CACHE_MANAGER 
      + (tot_count ? 
           "<td " REST_CELLS ">" + 
           Roxen.sizetostring (min_size) + " ..</td>" 
           "<td " REST_CELLS " align='left'>" + 
           Roxen.sizetostring (max_size) + "</td>" + 
           (mgr->has_cost ? 
            "<td " REST_CELLS ">" + 
            (floatp (min_cost) ? sprintf ("%.3g", min_cost) : min_cost) + 
            " ..</td>" + 
            "<td " REST_CELLS " align='left'>" + 
            (floatp (max_cost) ? sprintf ("%.3g", max_cost) : max_cost) + 
            "</td>" : 
            "<td " REST_CELLS " colspan='2' align='center'>" VALUE_NA "</td>") + 
           "<td " REST_CELLS ">" + 
           (floatp (min_value) ? sprintf ("%.3g", min_value) : min_value) + 
           " ..</td>" + 
           "<td " REST_CELLS " align='left'>" + 
           (floatp (max_value) ? sprintf ("%.3g", max_value) : max_value) + 
           "</td>" 
           "<td " REST_CELLS ">" + 
           (floatp (min_pval) ? sprintf ("%.3g", min_pval) : min_pval) + 
           " ..</td>" + 
           "<td " REST_CELLS " align='left'>" + 
           (floatp (max_pval) ? sprintf ("%.3g", max_pval) : max_pval) + 
           "</td>" : 
           "<td " REST_CELLS " colspan='8'></td>") + 
#endif 
      "</tr>\n"; 
 
      if (num_caches) { 
        mgr_stats += table; 
        if (num_caches > 1) 
          mgr_stats += 
            "<tr " FTR_TR_ATTRS ">" 
            "<td " FIRST_CELL "><b>"+LOCALE(178, "Total")+"</b></td>" 
            "<td " REST_CELLS ">" + tot_count + "</td>" 
            "<td " REST_CELLS ">" + (tot_hits + tot_misses) + "</td>" 
            "<td " REST_CELLS ">" + 
            format_hit_rate (tot_hits, tot_misses) + "</td>" 
            "<td " REST_CELLS ">" + 
            Roxen.sizetostring (tot_size) + "</td>" 
            "<td " REST_CELLS ">" + 
            Roxen.sizetostring (tot_count && (float) tot_size / tot_count) + 
            "</td>" 
#ifdef CACHE_BYTE_HR_STATS 
          "<td " REST_CELLS ">" + 
            format_hit_rate (tot_byte_hits, tot_byte_misses) + "</td>" 
#endif 
          "<td " REST_CELLS ">" + 
            (mgr->has_cost ? mgr->format_cost (tot_cost) : VALUE_NA) + "</td>" 
            "<td " REST_CELLS ">" + 
            (mgr->has_cost ? 
             mgr->format_cost (tot_count && tot_cost / tot_count) : VALUE_NA) + 
            "</td>" 
            "<td " REST_CELLS ">" + 
            (mgr->has_cost ? 
             format_hit_rate (tot_cost_hits, tot_cost_misses) : VALUE_NA) + "</td>" 
            "</tr>\n"; 
        mgr_stats += "</table>\n"; 
      } 
    } 
 
  mgr_stats += "<div style='font-size: smaller;'><p>" + 
    LOCALE(392, #"\ 
<i>Cost HR</i> is the cost hit rate, i.e. every hit and miss is 
weighted with the cost for each entry according to the cost metric of 
the cache manager. Note that it uses the approximation that every 
cache miss is followed by the addition of a new cache entry.") + 
    "</p></div>\n"; 
 
  mgr_summary += "</table>\n"; 
 
  res += mgr_summary + mgr_stats; 
 
  res += "<p><b>" + LOCALE(393, "Garbage Collector") + "</b></p>\n"; 
  if (!cache->last_gc_run) 
    res += "<p>" + 
      LOCALE(394, "The garbage collector has not run yet.") + "</p>\n"; 
  else { 
    res += "<p>" + 
      sprintf (LOCALE(395, "%d seconds since the last garbage collection. " 
                      "The following statistics are over approximately " 
                      "the last hour."), 
               time() - cache->last_gc_run) + "</p>\n" 
      "<table " TABLE_ATTRS ">\n" 
      "<tr " BODY_TR_ATTRS (0) ">" 
      "<td " FIRST_CELL ">" + 
      LOCALE(396, "Time spent in the garbage collector:") + "</td>" 
      "<td " REST_CELLS " colspan='3'>" + 
      Roxen.format_hrtime ((int) cache->sum_gc_time) + "</td>" 
      "</tr>" 
      "<tr " BODY_TR_ATTRS (1) ">" 
      "<td " FIRST_CELL ">" + 
      LOCALE(397, "Size of garbage collected entries:") + "</td>" 
      "<td " REST_CELLS ">" + 
      Roxen.sizetostring (cache->sum_destruct_garbage_size) + " " + 
      LOCALE(398, "stale") + " +</td>" 
      "<td " REST_CELLS ">" + 
      Roxen.sizetostring (cache->sum_timeout_garbage_size) + " " + 
      LOCALE(399, "timed out") + " =</td>" 
      "<td " REST_CELLS ">" + 
      Roxen.sizetostring (cache->sum_destruct_garbage_size + 
                          cache->sum_timeout_garbage_size) + "</td>" 
      "</tr>" 
      "<tr " BODY_TR_ATTRS (1) ">" 
      "<td " FIRST_CELL ">" + 
      LOCALE(400, "Garbage collection ratio:") + "</td>" 
      "<td " REST_CELLS ">" + 
      sprintf ("%.2f%%", cache->avg_destruct_garbage_ratio * 100.0) + " " + 
      LOCALE(398, "stale") + " +</td>" 
      "<td " REST_CELLS ">" + 
      sprintf ("%.2f%%", cache->avg_timeout_garbage_ratio * 100.0) + " " + 
      LOCALE(399, "timed out") + " =</td>" 
      "<td " REST_CELLS ">" + 
      sprintf ("%.2f%%", (cache->avg_destruct_garbage_ratio + 
                          cache->avg_timeout_garbage_ratio) * 100.0) + "</td>" 
      "</tr>" 
      "</table>\n"; 
  } 
 
  res += (roxen->query("cache")? "<br />" + roxen->get_garb_info():""); 
 
 
  // --- 
 
  mapping ngc = cache->ngc_status(); 
 
  if(sizeof(ngc)) { 
    res += "<br/><h3>"+ 
      LOCALE(87, "Non-garbing Memory Cache")+"</h3>\n" 
      "<table " TABLE_ATTRS ">\n" 
      "<tr " HDR_TR_ATTRS ">" 
      "<th " FIRST_CELL ">"+LOCALE(62, "Class")+"</th>" 
      "<th " REST_CELLS ">"+LOCALE(295, "Entries")+"</th>" 
      "<th " REST_CELLS ">"+LOCALE(64, "Size")+"</th></tr>"; 
 
    int row, totale, totalm; 
    foreach(sort(indices(ngc)); row; string name) { 
      array ent = ngc[name]; 
      res += "<tr " BODY_TR_ATTRS (row) ">" 
        "<td " FIRST_CELL ">"+ name +"</td>" 
        "<td " REST_CELLS ">"+ ent[0] + "</td>" 
        "<td " REST_CELLS ">" + Roxen.sizetostring(ent[1]) + "</td></tr>"; 
      totale += ent[0]; 
      totalm += ent[1]; 
    } 
 
    if (row >= 1) 
      res += "<tr " FTR_TR_ATTRS ">" 
        "<td " FIRST_CELL "><b>"+LOCALE(178, "Total")+"</b></td>" 
        "<td " REST_CELLS ">" + totale + "</td>" 
        "<td " REST_CELLS ">" + Roxen.sizetostring(totalm) + "</td></tr>\n"; 
    res += "</table>\n"; 
  } 
 
  // --- 
 
  { 
    int tot_entries = 0; 
    int tot_hits = 0; 
    int tot_misses = 0; 
    int tot_current_size = 0; 
    int tot_max_size = 0; 
 
    string prot_cache_desc = 
      "<p>" + 
      LOCALE(422, "RAM-based cache per configuration that stores " 
             "commonly requested files. Note that entries here don't " 
             "count toward the aforementioned size limit for RAM caches in " 
             "general, but instead is bound by a specific setting in each " 
             "configuration.") + 
      "</p>"; 
     
    res += 
      "<br/><h3>" + LOCALE(423, "Protocol Cache") + "</h3>" + 
      prot_cache_desc + 
      "<table " TABLE_ATTRS ">\n" 
      "<tr " HDR_TR_ATTRS ">" 
      "<th " FIRST_CELL ">" + LOCALE(424, "Configuration") + "</th>" 
      "<th " REST_CELLS ">" + LOCALE(295, "Entries") + "</th>" 
      "<th " REST_CELLS ">" + LOCALE(387, "Lookups") + "</th>" 
      "<th " REST_CELLS ">" + LOCALE(67, "Hit rate") + "</th>" 
      "<th " REST_CELLS ">" + LOCALE(64, "Size") + "</th>" 
      "<th " REST_CELLS ">" + LOCALE(388, "Size/entry") + "</th>" 
      "<th " REST_CELLS ">" + LOCALE(425, "Max file size") + "</th>" 
      "<th " REST_CELLS ">" + LOCALE(426, "Max size") + "</th>" 
      "</tr>"; 
     
    array(Configuration) configs = roxen->configurations; 
    string wiz_id = 
      (id->real_variables->_roxen_wizard_id || ({ "" }) )[0]; 
    string wiz_quoted = Roxen.html_encode_string(wiz_id || ""); 
    sort(configs->name, configs); 
    foreach (configs; int row; Configuration c) { 
      string conf_link = 
        "<a href='../sites/site.html/" + 
        Roxen.http_encode_url(c->name) + 
        "/?section=Cache&_roxen_wizard_id=" + wiz_quoted + "'>" + 
        Roxen.html_encode_string(c->query_name()) + 
        "</a>"; 
      mapping stats = c->datacache && c->datacache->get_cache_stats(); 
      if (!stats) 
        continue; 
      int lookups = stats->hits + stats->misses; 
      string hit_rate = format_hit_rate(stats->hits, stats->misses); 
      string entry_size = 
        stats->entries ? 
        Roxen.sizetostring(1.0 * stats->current_size / stats->entries) : 
        VALUE_NA; 
      res += 
        "<tr " BODY_TR_ATTRS (row) ">" 
        "<td " FIRST_CELL ">" + conf_link + "</td>" 
        "<td " REST_CELLS ">" + stats->entries + "</td>" 
        "<td " REST_CELLS ">" + lookups + "</td>" 
        "<td " REST_CELLS ">" + hit_rate + "</td>" 
        "<td " REST_CELLS ">" + Roxen.sizetostring(stats->current_size) + "</td>" 
        "<td " REST_CELLS ">" + entry_size + "</td>" 
        "<td " REST_CELLS ">" + Roxen.sizetostring(stats->max_file_size) + "</td>" 
        "<td " REST_CELLS ">" + Roxen.sizetostring(stats->max_size) + "</td>" 
        "</tr>"; 
 
      //  Aggregate stats 
      tot_entries += stats->entries; 
      tot_hits += stats->hits; 
      tot_misses += stats->misses; 
      tot_current_size += stats->current_size; 
      tot_max_size += stats->max_size; 
    } 
     
    res += 
      "<tr " FTR_TR_ATTRS ">" 
      "<td " FIRST_CELL "><b>" + LOCALE(178, "Total") + "</b></td>" 
      "<td " REST_CELLS ">" + tot_entries + "</td>" 
      "<td " REST_CELLS ">" + (tot_hits + tot_misses) + "</td>" 
      "<td " REST_CELLS ">" + format_hit_rate(tot_hits, tot_misses) + "</td>" 
      "<td " REST_CELLS ">" + Roxen.sizetostring(tot_current_size) + "</td>" 
      "<td " REST_CELLS ">" + 
      (tot_entries ? 
       Roxen.sizetostring((float) tot_current_size / tot_entries) : VALUE_NA) + 
      "</td>" 
      "<td " REST_CELLS ">" VALUE_NA "</td>" 
      "<td " REST_CELLS ">" + Roxen.sizetostring(tot_max_size) + "</td>" 
      "</tr>" 
      "</table>"; 
  } 
 
  // --- 
 
  mapping l=Locale.cache_status(); 
  res += "<br/><h3>"+LOCALE(71, "Locale Cache")+"</h3>" 
    "<table " TABLE_ATTRS ">\n" 
    DESCR_ROW (0, LOCALE(72, "Used languages:"), l->languages) 
    DESCR_ROW (1, LOCALE(73, "Registered projects:"), l->reg_proj) 
    DESCR_ROW (2, LOCALE(74, "Loaded project files:"), l->load_proj) 
    DESCR_ROW (3, LOCALE(75, "Current cache size:"), 
               Roxen.sizetostring(l->bytes)) 
    "</table>\n"; 
 
  return res; 
}