Merge maintenance-work branch:
[lhc/web/wiklou.git] / maintenance / stats.php
1 <?php
2 /**
3 * Show statistics from memcached
4 * @ingroup Maintenance
5 */
6
7 require_once( "Maintenance.php" );
8
9 class MemcachedStats extends Maintenance {
10
11 public function __construct() {
12 $this->mDescription = "Show statistics from memcached";
13 }
14
15 public function execute() {
16 global $wgMemc;
17
18 // Can't do stats if
19 if( get_class( $wgMemc ) == 'FakeMemCachedClient' ) {
20 $this->error( "You are running FakeMemCachedClient, I can not provide any statistics.\n", true );
21 }
22 $session = intval($wgMemc->get(wfMemcKey('stats','request_with_session')));
23 $noSession = intval($wgMemc->get(wfMemcKey('stats','request_without_session')));
24 $total = $session + $noSession;
25 if ( $total == 0 ) {
26 $this->error( "You either have no stats or memcached isn't running. Aborting.\n", true );
27 }
28 $this->output( "Requests\n" );
29 $this->output( sprintf( "with session: %-10d %6.2f%%\n", $session, $session/$total*100 );
30 $this->output( sprintf( "without session: %-10d %6.2f%%\n", $noSession, $noSession/$total*100 );
31 $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 );
32
33
34 $this->output( "\nParser cache\n" );
35 $hits = intval($wgMemc->get(wfMemcKey('stats','pcache_hit')));
36 $invalid = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_invalid')));
37 $expired = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_expired')));
38 $absent = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_absent')));
39 $stub = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_stub')));
40 $total = $hits + $invalid + $expired + $absent + $stub;
41 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ) );
42 $this->output( sprintf( "invalid: %-10d %6.2f%%\n", $invalid, $invalid/$total*100 ) );
43 $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired/$total*100 ) );
44 $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent/$total*100 ) );
45 $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub/$total*100 ) );
46 $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
47
48 $hits = intval($wgMemc->get(wfMemcKey('stats','image_cache_hit')));
49 $misses = intval($wgMemc->get(wfMemcKey('stats','image_cache_miss')));
50 $updates = intval($wgMemc->get(wfMemcKey('stats','image_cache_update')));
51 $total = $hits + $misses;
52 $this->output("\nImage cache\n");
53 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ) );
54 $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses/$total*100 ) );
55 $this->output( sprintf( "updates: %-10d\n", $updates ) );
56
57 $hits = intval($wgMemc->get(wfMemcKey('stats','diff_cache_hit')));
58 $misses = intval($wgMemc->get(wfMemcKey('stats','diff_cache_miss')));
59 $uncacheable = intval($wgMemc->get(wfMemcKey('stats','diff_uncacheable')));
60 $total = $hits + $misses + $uncacheable;
61 $this->output("\nDiff cache\n");
62 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 );
63 $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses/$total*100 );
64 $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable/$total*100 );
65 }
66 }
67
68 $maintClass = "MemcachedStats";
69 require_once( DO_MAINTENANCE );
70
71
72
73