-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mediawikI: Add a way to view opcache/apcu stats
This is from wikimedias puppet repo [0] with minor tweeks to conform to how we do things. [0] https://github.com/wikimedia/operations-puppet/blob/bd7cbb36d87e147da028c3c51b583f93f5851957/modules/profile/manifests/mediawiki/php/monitoring.pp
- Loading branch information
Showing
6 changed files
with
727 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/* | ||
Admin cli interface for php-fpm. It supports a /metrics endpoint where we expose data | ||
in a format prometheus likes. | ||
*/ | ||
require('lib.php'); | ||
|
||
$usage = <<<'EOD' | ||
Supported urls: | ||
/metrics Metrics about APCu and OPcache usage | ||
/apcu-info Show basic APCu stats | ||
/apcu-meta Dump meta information for all objects in APCu to /tmp/apcu_dump_meta | ||
/apcu-free Clear all data from APCu | ||
/apcu-frag APCu fragmentation percentage | ||
/opcache-info Show basic opcache stats | ||
/opcache-meta Dump meta information for all objects in opcache to /tmp/opcache_dump_meta | ||
/opcache-free Clear all data from opcache | ||
/ini-get Get the ini values for the running daemon. Add a key parameter if you want just one. | ||
|
||
EOD; | ||
|
||
ob_start(); | ||
|
||
switch ($_SERVER['SCRIPT_NAME']) { | ||
case '/metrics': | ||
# This will make requests to the other php admin ports for /local-metrics, and combine them all | ||
# in a single output. | ||
show_all_prometheus_metrics(); | ||
break; | ||
case '/local-metrics': | ||
show_prometheus_metrics(); | ||
break; | ||
case '/apcu-info': | ||
show_apcu_info(); | ||
break; | ||
case '/apcu-meta': | ||
dump_apcu_full(); | ||
break; | ||
case '/apcu-free': | ||
// this is an administrative action | ||
clear_apcu(); | ||
break; | ||
case '/apcu-frag': | ||
show_apcu_frag(); | ||
break; | ||
case '/opcache-info': | ||
show_opcache_info(); | ||
break; | ||
case '/opcache-meta': | ||
dump_opcache_meta(); | ||
break; | ||
case '/opcache-free': | ||
clear_opcache(); | ||
break; | ||
case '/ini-get': | ||
ini_value(); | ||
break; | ||
default: | ||
header("Content-Type: text/plain"); | ||
echo $usage; | ||
} | ||
|
||
ob_flush(); |
Oops, something went wrong.