Vector extension (and possibly disable its features using config settings if
you don't want them).
* Experimental IBM DB2 support was removed due to lack of interest and maintainership
+* BREAKING CHANGE: Filenames of maintenance scripts were standardized into lowerCamelCase
+ format, and made more explicit: clear_stats.php -> clearCacheStats.php;
+ clear_interwiki_cache.php -> clearInterwikiCache.php; initStats.php -> initSiteStats.php;
+ proxy_check.php -> proxyCheck.php; stats.php -> showCacheStats.php;
+ showStats.php -> showSiteStats.php. Class names were renamed accordingly:
+ clear_stats -> ClearCacheStats; InitStats -> InitSiteStats; CacheStats -> ShowCacheStats
+ ShowStats -> ShowSiteStats.
== Compatibility ==
level /maintenance directory.
Example:
- php clear_stats.php
+ php clearCacheStats.php
The following parameters are available to all maintenance scripts
--help : Print a help message
controlled by: $wgStatsMethod
key: $wgDBname:stats:$key
ex: wikibd:stats:request_with_session
- stores: counter for statistics (see maintenance/stats.php script)
+ stores: counter for statistics (see maintenance/showCacheStats.php script)
expiry: none (?)
- cleared by: maintenance/clear_stats.php script
+ cleared by: maintenance/clearCacheStats.php script
User:
key: $wgDBname:user:id:$sId
/** Port we want to scan for a proxy */
$wgProxyPorts = array( 80, 81, 1080, 3128, 6588, 8000, 8080, 8888, 65506 );
/** Script used to scan */
-$wgProxyScriptPath = "$IP/maintenance/proxy_check.php";
+$wgProxyScriptPath = "$IP/maintenance/proxyCheck.php";
/** */
$wgProxyMemcExpiry = 86400;
/** This should always be customised in LocalSettings.php */
*/
/**
- * A special page called by proxy_check.php to block open proxies
+ * A special page called by proxyCheck.php to block open proxies
*
* @ingroup SpecialPage
*/
runJobs.php
Immediately complete all jobs in the job queue
- stats.php
+ showCacheStats.php
Show all statistics stored in the cache
undelete.php
Update pages restriction to the new schema
userOptions.php
- Change user options
\ No newline at end of file
+ Change user options
--- /dev/null
+<?php
+/**
+ * Removes all statistics tracking from the cache.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once( __DIR__ . '/Maintenance.php' );
+
+/**
+ * Maintenance script to remove all statistics tracking from the cache.
+ *
+ * @ingroup Maintenance
+ */
+class ClearCacheStats extends Maintenance {
+
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = "Remove all statistics tracking from the cache";
+ }
+
+ public function execute() {
+ global $wgLocalDatabases, $wgMemc;
+ foreach ( $wgLocalDatabases as $db ) {
+ $wgMemc->delete( "$db:stats:request_with_session" );
+ $wgMemc->delete( "$db:stats:request_without_session" );
+ $wgMemc->delete( "$db:stats:pcache_hit" );
+ $wgMemc->delete( "$db:stats:pcache_miss_expired" );
+ $wgMemc->delete( "$db:stats:pcache_miss_absent" );
+ $wgMemc->delete( "$db:stats:pcache_miss_stub" );
+ $wgMemc->delete( "$db:stats:image_cache_hit" );
+ $wgMemc->delete( "$db:stats:image_cache_miss" );
+ $wgMemc->delete( "$db:stats:image_cache_update" );
+ $wgMemc->delete( "$db:stats:diff_cache_hit" );
+ $wgMemc->delete( "$db:stats:diff_cache_miss" );
+ $wgMemc->delete( "$db:stats:diff_uncacheable" );
+ $wgMemc->delete( "$db:stats:job-insert" );
+ $wgMemc->delete( "$db:stats:job-pop" );
+ }
+ }
+}
+
+$maintClass = "ClearCacheStats";
+require_once( RUN_MAINTENANCE_IF_MAIN );
--- /dev/null
+<?php
+/**
+ * Clear the cache of interwiki prefixes for all local wikis.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once( __DIR__ . '/Maintenance.php' );
+
+/**
+ * Maintenance script to clear the cache of interwiki prefixes for all local wikis.
+ *
+ * @ingroup Maintenance
+ */
+class ClearInterwikiCache extends Maintenance {
+
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = "Clear all interwiki links for all languages from the cache";
+ }
+
+ public function execute() {
+ global $wgLocalDatabases, $wgMemc;
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( 'interwiki', array( 'iw_prefix' ), false );
+ $prefixes = array();
+ foreach ( $res as $row ) {
+ $prefixes[] = $row->iw_prefix;
+ }
+
+ foreach ( $wgLocalDatabases as $db ) {
+ $this->output( "$db..." );
+ foreach ( $prefixes as $prefix ) {
+ $wgMemc->delete( "$db:interwiki:$prefix" );
+ }
+ $this->output( "done\n" );
+ }
+ }
+}
+
+$maintClass = "ClearInterwikiCache";
+require_once( RUN_MAINTENANCE_IF_MAIN );
+++ /dev/null
-<?php
-/**
- * Clear the cache of interwiki prefixes for all local wikis.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- */
-
-require_once( __DIR__ . '/Maintenance.php' );
-
-/**
- * Maintenance script to clear the cache of interwiki prefixes for all local wikis.
- *
- * @ingroup Maintenance
- */
-class ClearInterwikiCache extends Maintenance {
-
- public function __construct() {
- parent::__construct();
- $this->mDescription = "Clear all interwiki links for all languages from the cache";
- }
-
- public function execute() {
- global $wgLocalDatabases, $wgMemc;
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'interwiki', array( 'iw_prefix' ), false );
- $prefixes = array();
- foreach ( $res as $row ) {
- $prefixes[] = $row->iw_prefix;
- }
-
- foreach ( $wgLocalDatabases as $db ) {
- $this->output( "$db..." );
- foreach ( $prefixes as $prefix ) {
- $wgMemc->delete( "$db:interwiki:$prefix" );
- }
- $this->output( "done\n" );
- }
- }
-}
-
-$maintClass = "ClearInterwikiCache";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+++ /dev/null
-<?php
-/**
- * Removes all statistics tracking from the cache.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- */
-
-require_once( __DIR__ . '/Maintenance.php' );
-
-/**
- * Maintenance script to remove all statistics tracking from the cache.
- *
- * @ingroup Maintenance
- */
-class clear_stats extends Maintenance {
-
- public function __construct() {
- parent::__construct();
- $this->mDescription = "Remove all statistics tracking from the cache";
- }
-
- public function execute() {
- global $wgLocalDatabases, $wgMemc;
- foreach ( $wgLocalDatabases as $db ) {
- $wgMemc->delete( "$db:stats:request_with_session" );
- $wgMemc->delete( "$db:stats:request_without_session" );
- $wgMemc->delete( "$db:stats:pcache_hit" );
- $wgMemc->delete( "$db:stats:pcache_miss_expired" );
- $wgMemc->delete( "$db:stats:pcache_miss_absent" );
- $wgMemc->delete( "$db:stats:pcache_miss_stub" );
- $wgMemc->delete( "$db:stats:image_cache_hit" );
- $wgMemc->delete( "$db:stats:image_cache_miss" );
- $wgMemc->delete( "$db:stats:image_cache_update" );
- $wgMemc->delete( "$db:stats:diff_cache_hit" );
- $wgMemc->delete( "$db:stats:diff_cache_miss" );
- $wgMemc->delete( "$db:stats:diff_uncacheable" );
- $wgMemc->delete( "$db:stats:job-insert" );
- $wgMemc->delete( "$db:stats:job-pop" );
- }
- }
-}
-
-$maintClass = "clear_stats";
-require_once( RUN_MAINTENANCE_IF_MAIN );
--- /dev/null
+<?php
+/**
+ * Re-initialise or update the site statistics table.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ * @author Brion Vibber
+ * @author Rob Church <robchur@gmail.com>
+ */
+
+require_once( __DIR__ . '/Maintenance.php' );
+
+/**
+ * Maintenance script to re-initialise or update the site statistics table
+ *
+ * @ingroup Maintenance
+ */
+class InitSiteStats extends Maintenance {
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = "Re-initialise the site statistics tables";
+ $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' );
+ $this->addOption( 'noviews', "Don't update the page view counter" );
+ $this->addOption( 'active', 'Also update active users count' );
+ $this->addOption( 'use-master', 'Count using the master database' );
+ }
+
+ public function execute() {
+ $this->output( "Refresh Site Statistics\n\n" );
+ $counter = new SiteStatsInit( $this->hasOption( 'use-master' ) );
+
+ $this->output( "Counting total edits..." );
+ $edits = $counter->edits();
+ $this->output( "{$edits}\nCounting number of articles..." );
+
+ $good = $counter->articles();
+ $this->output( "{$good}\nCounting total pages..." );
+
+ $pages = $counter->pages();
+ $this->output( "{$pages}\nCounting number of users..." );
+
+ $users = $counter->users();
+ $this->output( "{$users}\nCounting number of images..." );
+
+ $image = $counter->files();
+ $this->output( "{$image}\n" );
+
+ if ( !$this->hasOption( 'noviews' ) ) {
+ $this->output( "Counting total page views..." );
+ $views = $counter->views();
+ $this->output( "{$views}\n" );
+ }
+
+ if ( $this->hasOption( 'active' ) ) {
+ $this->output( "Counting active users..." );
+ $active = SiteStatsUpdate::cacheUpdate( wfGetDB( DB_MASTER ) );
+ $this->output( "{$active}\n" );
+ }
+
+ $this->output( "\nUpdating site statistics..." );
+
+ if ( $this->hasOption( 'update' ) ) {
+ $counter->update();
+ } else {
+ $counter->refresh();
+ }
+
+ $this->output( "done.\n" );
+ }
+}
+
+$maintClass = "InitSiteStats";
+require_once( RUN_MAINTENANCE_IF_MAIN );
+++ /dev/null
-<?php
-/**
- * Re-initialise or update the site statistics table.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- * @author Brion Vibber
- * @author Rob Church <robchur@gmail.com>
- */
-
-require_once( __DIR__ . '/Maintenance.php' );
-
-/**
- * Maintenance script to re-initialise or update the site statistics table
- *
- * @ingroup Maintenance
- */
-class InitStats extends Maintenance {
- public function __construct() {
- parent::__construct();
- $this->mDescription = "Re-initialise the site statistics tables";
- $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' );
- $this->addOption( 'noviews', "Don't update the page view counter" );
- $this->addOption( 'active', 'Also update active users count' );
- $this->addOption( 'use-master', 'Count using the master database' );
- }
-
- public function execute() {
- $this->output( "Refresh Site Statistics\n\n" );
- $counter = new SiteStatsInit( $this->hasOption( 'use-master' ) );
-
- $this->output( "Counting total edits..." );
- $edits = $counter->edits();
- $this->output( "{$edits}\nCounting number of articles..." );
-
- $good = $counter->articles();
- $this->output( "{$good}\nCounting total pages..." );
-
- $pages = $counter->pages();
- $this->output( "{$pages}\nCounting number of users..." );
-
- $users = $counter->users();
- $this->output( "{$users}\nCounting number of images..." );
-
- $image = $counter->files();
- $this->output( "{$image}\n" );
-
- if ( !$this->hasOption( 'noviews' ) ) {
- $this->output( "Counting total page views..." );
- $views = $counter->views();
- $this->output( "{$views}\n" );
- }
-
- if ( $this->hasOption( 'active' ) ) {
- $this->output( "Counting active users..." );
- $active = SiteStatsUpdate::cacheUpdate( wfGetDB( DB_MASTER ) );
- $this->output( "{$active}\n" );
- }
-
- $this->output( "\nUpdating site statistics..." );
-
- if ( $this->hasOption( 'update' ) ) {
- $counter->update();
- } else {
- $counter->refresh();
- }
-
- $this->output( "done.\n" );
- }
-}
-
-$maintClass = "InitStats";
-require_once( RUN_MAINTENANCE_IF_MAIN );
--- /dev/null
+<?php
+/**
+ * Command line script to check for an open proxy at a specified location.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+if( PHP_SAPI != 'cli' ) {
+ die( 1 );
+}
+
+/**
+ *
+ */
+$output = '';
+
+/**
+ * Exit if there are not enough parameters, or if it's not command line mode
+ */
+if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
+ $output .= "Incorrect parameters\n";
+} else {
+ /**
+ * Get parameters
+ */
+ $ip = $argv[1];
+ $port = $argv[2];
+ $url = $argv[3];
+ $host = trim(`hostname`);
+ $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
+
+ # Open socket
+ $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
+ if ($errno == 0 ) {
+ $output .= "Connected\n";
+ # Send payload
+ $request = "GET $url HTTP/1.0\r\n";
+# $request .= "Proxy-Connection: Keep-Alive\r\n";
+# $request .= "Pragma: no-cache\r\n";
+# $request .= "Host: ".$url."\r\n";
+# $request .= "User-Agent: MediaWiki open proxy check\r\n";
+ $request .= "\r\n";
+ @fputs($sock, $request);
+ $response = fgets($sock, 65536);
+ $output .= $response;
+ @fclose($sock);
+ } else {
+ $output .= "No connection\n";
+ }
+}
+
+$output = escapeshellarg( $output );
+
+#`echo $output >> /home/tstarling/open/proxy.log`;
+++ /dev/null
-<?php
-/**
- * Command line script to check for an open proxy at a specified location.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- */
-
-if( PHP_SAPI != 'cli' ) {
- die( 1 );
-}
-
-/**
- *
- */
-$output = '';
-
-/**
- * Exit if there are not enough parameters, or if it's not command line mode
- */
-if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $argv ) < 4 ) {
- $output .= "Incorrect parameters\n";
-} else {
- /**
- * Get parameters
- */
- $ip = $argv[1];
- $port = $argv[2];
- $url = $argv[3];
- $host = trim(`hostname`);
- $output = "Connecting to $ip:$port, target $url, this hostname $host\n";
-
- # Open socket
- $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
- if ($errno == 0 ) {
- $output .= "Connected\n";
- # Send payload
- $request = "GET $url HTTP/1.0\r\n";
-# $request .= "Proxy-Connection: Keep-Alive\r\n";
-# $request .= "Pragma: no-cache\r\n";
-# $request .= "Host: ".$url."\r\n";
-# $request .= "User-Agent: MediaWiki open proxy check\r\n";
- $request .= "\r\n";
- @fputs($sock, $request);
- $response = fgets($sock, 65536);
- $output .= $response;
- @fclose($sock);
- } else {
- $output .= "No connection\n";
- }
-}
-
-$output = escapeshellarg( $output );
-
-#`echo $output >> /home/tstarling/open/proxy.log`;
--- /dev/null
+<?php
+/**
+ * Show statistics from the cache.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once( __DIR__ . '/Maintenance.php' );
+
+/**
+ * Maintenance script that shows statistics from the cache.
+ *
+ * @ingroup Maintenance
+ */
+class ShowCacheStats extends Maintenance {
+
+ public function __construct() {
+ $this->mDescription = "Show statistics from the cache";
+ parent::__construct();
+ }
+
+ public function getDbType() {
+ return Maintenance::DB_NONE;
+ }
+
+ public function execute() {
+ global $wgMemc;
+
+ // Can't do stats if
+ if ( get_class( $wgMemc ) == 'EmptyBagOStuff' ) {
+ $this->error( "You are running EmptyBagOStuff, I can not provide any statistics.", true );
+ }
+ $session = intval( $wgMemc->get( wfMemcKey( 'stats', 'request_with_session' ) ) );
+ $noSession = intval( $wgMemc->get( wfMemcKey( 'stats', 'request_without_session' ) ) );
+ $total = $session + $noSession;
+ if ( $total == 0 ) {
+ $this->error( "You either have no stats or the cache isn't running. Aborting.", true );
+ }
+ $this->output( "Requests\n" );
+ $this->output( sprintf( "with session: %-10d %6.2f%%\n", $session, $session / $total * 100 ) );
+ $this->output( sprintf( "without session: %-10d %6.2f%%\n", $noSession, $noSession / $total * 100 ) );
+ $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
+
+
+ $this->output( "\nParser cache\n" );
+ $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_hit' ) ) );
+ $expired = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_expired' ) ) );
+ $absent = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_absent' ) ) );
+ $stub = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_stub' ) ) );
+ $total = $hits + $expired + $absent + $stub;
+ if ( $total ) {
+ $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
+ $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired / $total * 100 ) );
+ $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent / $total * 100 ) );
+ $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) );
+ $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
+ } else {
+ $this->output( "no statistics available\n" );
+ }
+
+ $this->output( "\nImage cache\n" );
+ $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_hit' ) ) );
+ $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_miss' ) ) );
+ $updates = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_update' ) ) );
+ $total = $hits + $misses;
+ if ( $total ) {
+ $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
+ $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
+ $this->output( sprintf( "updates: %-10d\n", $updates ) );
+ } else {
+ $this->output( "no statistics available\n" );
+ }
+
+ $this->output( "\nDiff cache\n" );
+ $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_hit' ) ) );
+ $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_miss' ) ) );
+ $uncacheable = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_uncacheable' ) ) );
+ $total = $hits + $misses + $uncacheable;
+ if ( $total ) {
+ $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
+ $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
+ $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable / $total * 100 ) );
+ } else {
+ $this->output( "no statistics available\n" );
+ }
+ }
+}
+
+$maintClass = "ShowCacheStats";
+require_once( RUN_MAINTENANCE_IF_MAIN );
--- /dev/null
+<?php
+
+/**
+ * Show the cached statistics.
+ * Give out the same output as [[Special:Statistics]]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ * @author Antoine Musso <hashar at free dot fr>
+ * Based on initSiteStats.php by:
+ * @author Brion Vibber
+ * @author Rob Church <robchur@gmail.com>
+ *
+ * @license GNU General Public License 2.0 or later
+ */
+
+require_once( __DIR__ . '/Maintenance.php' );
+
+/**
+ * Maintenance script to show the cached statistics.
+ *
+ * @ingroup Maintenance
+ */
+class ShowSiteStats extends Maintenance {
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = "Show the cached statistics";
+ }
+ public function execute() {
+ $fields = array(
+ 'ss_total_views' => 'Total views',
+ 'ss_total_edits' => 'Total edits',
+ 'ss_good_articles' => 'Number of articles',
+ 'ss_total_pages' => 'Total pages',
+ 'ss_users' => 'Number of users',
+ 'ss_images' => 'Number of images',
+ );
+
+ // Get cached stats from slave database
+ $dbr = wfGetDB( DB_SLAVE );
+ $stats = $dbr->selectRow( 'site_stats', '*', '', __METHOD__ );
+
+ // Get maximum size for each column
+ $max_length_value = $max_length_desc = 0;
+ foreach ( $fields as $field => $desc ) {
+ $max_length_value = max( $max_length_value, strlen( $stats->$field ) );
+ $max_length_desc = max( $max_length_desc, strlen( $desc ) ) ;
+ }
+
+ // Show them
+ foreach ( $fields as $field => $desc ) {
+ $this->output( sprintf( "%-{$max_length_desc}s: %{$max_length_value}d\n", $desc, $stats->$field ) );
+ }
+ }
+}
+
+$maintClass = "ShowSiteStats";
+require_once( RUN_MAINTENANCE_IF_MAIN );
+++ /dev/null
-<?php
-
-/**
- * Show the cached statistics.
- * Give out the same output as [[Special:Statistics]]
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- * @author Antoine Musso <hashar at free dot fr>
- * Based on initStats.php by:
- * @author Brion Vibber
- * @author Rob Church <robchur@gmail.com>
- *
- * @license GNU General Public License 2.0 or later
- */
-
-require_once( __DIR__ . '/Maintenance.php' );
-
-/**
- * Maintenance script to show the cached statistics.
- *
- * @ingroup Maintenance
- */
-class ShowStats extends Maintenance {
- public function __construct() {
- parent::__construct();
- $this->mDescription = "Show the cached statistics";
- }
- public function execute() {
- $fields = array(
- 'ss_total_views' => 'Total views',
- 'ss_total_edits' => 'Total edits',
- 'ss_good_articles' => 'Number of articles',
- 'ss_total_pages' => 'Total pages',
- 'ss_users' => 'Number of users',
- 'ss_images' => 'Number of images',
- );
-
- // Get cached stats from slave database
- $dbr = wfGetDB( DB_SLAVE );
- $stats = $dbr->selectRow( 'site_stats', '*', '', __METHOD__ );
-
- // Get maximum size for each column
- $max_length_value = $max_length_desc = 0;
- foreach ( $fields as $field => $desc ) {
- $max_length_value = max( $max_length_value, strlen( $stats->$field ) );
- $max_length_desc = max( $max_length_desc, strlen( $desc ) ) ;
- }
-
- // Show them
- foreach ( $fields as $field => $desc ) {
- $this->output( sprintf( "%-{$max_length_desc}s: %{$max_length_value}d\n", $desc, $stats->$field ) );
- }
- }
-}
-
-$maintClass = "ShowStats";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+++ /dev/null
-<?php
-/**
- * Show statistics from the cache.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- */
-
-require_once( __DIR__ . '/Maintenance.php' );
-
-/**
- * Maintenance script that shows statistics from the cache.
- *
- * @ingroup Maintenance
- */
-class CacheStats extends Maintenance {
-
- public function __construct() {
- $this->mDescription = "Show statistics from the cache";
- parent::__construct();
- }
-
- public function getDbType() {
- return Maintenance::DB_NONE;
- }
-
- public function execute() {
- global $wgMemc;
-
- // Can't do stats if
- if ( get_class( $wgMemc ) == 'EmptyBagOStuff' ) {
- $this->error( "You are running EmptyBagOStuff, I can not provide any statistics.", true );
- }
- $session = intval( $wgMemc->get( wfMemcKey( 'stats', 'request_with_session' ) ) );
- $noSession = intval( $wgMemc->get( wfMemcKey( 'stats', 'request_without_session' ) ) );
- $total = $session + $noSession;
- if ( $total == 0 ) {
- $this->error( "You either have no stats or the cache isn't running. Aborting.", true );
- }
- $this->output( "Requests\n" );
- $this->output( sprintf( "with session: %-10d %6.2f%%\n", $session, $session / $total * 100 ) );
- $this->output( sprintf( "without session: %-10d %6.2f%%\n", $noSession, $noSession / $total * 100 ) );
- $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
-
-
- $this->output( "\nParser cache\n" );
- $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_hit' ) ) );
- $expired = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_expired' ) ) );
- $absent = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_absent' ) ) );
- $stub = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_stub' ) ) );
- $total = $hits + $expired + $absent + $stub;
- if ( $total ) {
- $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
- $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired / $total * 100 ) );
- $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent / $total * 100 ) );
- $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) );
- $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
- } else {
- $this->output( "no statistics available\n" );
- }
-
- $this->output( "\nImage cache\n" );
- $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_hit' ) ) );
- $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_miss' ) ) );
- $updates = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_update' ) ) );
- $total = $hits + $misses;
- if ( $total ) {
- $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
- $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
- $this->output( sprintf( "updates: %-10d\n", $updates ) );
- } else {
- $this->output( "no statistics available\n" );
- }
-
- $this->output( "\nDiff cache\n" );
- $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_hit' ) ) );
- $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_miss' ) ) );
- $uncacheable = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_uncacheable' ) ) );
- $total = $hits + $misses + $uncacheable;
- if ( $total ) {
- $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
- $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
- $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable / $total * 100 ) );
- } else {
- $this->output( "no statistics available\n" );
- }
- }
-}
-
-$maintClass = "CacheStats";
-require_once( RUN_MAINTENANCE_IF_MAIN );