├── .gitignore ├── screenshot.png ├── composer.json ├── README.md ├── data-sample.php └── opcache.php /.gitignore: -------------------------------------------------------------------------------- 1 | composer.lock 2 | composer.phar 3 | atlassian-ide-plugin.xml 4 | .idea/ -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cviebrock/opcache-status/master/screenshot.png -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rlerdorf/opcache-status", 3 | "description": "A one-page opcache status page", 4 | "license": "PHP-3.0", 5 | "authors": [ 6 | { 7 | "name": "The contributors", 8 | "homepage": "https://github.com/rlerdorf/opcache-status/graphs/contributors" 9 | } 10 | ], 11 | "require": { 12 | "PHP": ">=5.5.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OPcache Status [![Packagist](http://img.shields.io/packagist/v/rlerdorf/opcache-status.svg)](https://packagist.org/packages/rlerdorf/opcache-status) 2 | --------------- 3 | 4 | A one-page opcache status page for the PHP 5.5 opcode cache. 5 | 6 | You don't need the opcode cache installed to help out with this. 7 | See the data-sample.php file for a dump of the data. 8 | 9 | I know it is rather ugly, so please spruce it up. But I would like 10 | to keep it relatively small and to a single file so it is easy to 11 | drop into a directory anywhere without worrying about separate css/js/php 12 | files. 13 | 14 | [![Screenshot](https://raw.githubusercontent.com/jamesrwhite/opcache-status/improve-readme/screenshot.png)](https://raw.githubusercontent.com/jamesrwhite/opcache-status/improve-readme/screenshot.png) 15 | 16 | ### TODO 17 | 18 | - The ability to sort the list of cached scripts by the various columns 19 | - A better layout that can accommodate more of the script data without looking cluttered 20 | - A tuning suggestion tab (need to add a couple of things to the opcache output first though) 21 | 22 | -------------------------------------------------------------------------------- /data-sample.php: -------------------------------------------------------------------------------- 1 | true, 5 | 'cache_full' => false, 6 | 'memory_usage' => 7 | array ( 8 | 'used_memory' => 12028872, 9 | 'free_memory' => 4235696, 10 | 'wasted_memory' => 512648, 11 | 'current_wasted_percentage' => 3.0556201934814, 12 | ), 13 | 'opcache_statistics' => 14 | array ( 15 | 'num_cached_scripts' => 59, 16 | 'num_cached_keys' => 78, 17 | 'max_cached_keys' => 223, 18 | 'hits' => 66817, 19 | 'last_restart_time' => 0, 20 | 'misses' => 126, 21 | 'blacklist_misses' => 0, 22 | 'blacklist_miss_ratio' => 0, 23 | 'opcache_hit_rate' => 99.81178017119, 24 | 'oom_restarts' => 0, 25 | 'manual_restarts' => 0, 26 | 'hash_restarts' => 0, 27 | ), 28 | 'scripts' => 29 | array ( 30 | '/var/www/phpweb/manual/en/toc/faq.inc' => 31 | array ( 32 | 'full_path' => '/var/www/phpweb/manual/en/toc/faq.inc', 33 | 'hits' => 9, 34 | 'memory_consumption' => 5680, 35 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 36 | 'last_used_timestamp' => 1363461391, 37 | 'timestamp' => 1363345905, 38 | ), 39 | '/var/www/phpweb/downloads.php' => 40 | array ( 41 | 'full_path' => '/var/www/phpweb/downloads.php', 42 | 'hits' => 86, 43 | 'memory_consumption' => 9488, 44 | 'last_used' => 'Sat Mar 16 12:03:47 2013', 45 | 'last_used_timestamp' => 1363460627, 46 | 'timestamp' => 1355102402, 47 | ), 48 | '/var/www/phpweb/include/languages.inc' => 49 | array ( 50 | 'full_path' => '/var/www/phpweb/include/languages.inc', 51 | 'hits' => 5605, 52 | 'memory_consumption' => 16984, 53 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 54 | 'last_used_timestamp' => 1363461391, 55 | 'timestamp' => 1362994804, 56 | ), 57 | '/var/www/phpweb/include/header.inc' => 58 | array ( 59 | 'full_path' => '/var/www/phpweb/include/header.inc', 60 | 'hits' => 9, 61 | 'memory_consumption' => 20352, 62 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 63 | 'last_used_timestamp' => 1363461391, 64 | 'timestamp' => 1357938001, 65 | ), 66 | '/var/www/phpweb/manual/en/toc/getting-started.inc' => 67 | array ( 68 | 'full_path' => '/var/www/phpweb/manual/en/toc/getting-started.inc', 69 | 'hits' => 9, 70 | 'memory_consumption' => 1936, 71 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 72 | 'last_used_timestamp' => 1363461391, 73 | 'timestamp' => 1363345409, 74 | ), 75 | '/var/www/phpweb/manual/en/faq.php' => 76 | array ( 77 | 'full_path' => '/var/www/phpweb/manual/en/faq.php', 78 | 'hits' => 122, 79 | 'memory_consumption' => 5152, 80 | 'last_used' => 'Sat Mar 16 12:06:15 2013', 81 | 'last_used_timestamp' => 1363460775, 82 | 'timestamp' => 1363345906, 83 | ), 84 | '/var/www/phpweb/include/footer.inc' => 85 | array ( 86 | 'full_path' => '/var/www/phpweb/include/footer.inc', 87 | 'hits' => 9, 88 | 'memory_consumption' => 1976, 89 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 90 | 'last_used_timestamp' => 1363461391, 91 | 'timestamp' => 1347648001, 92 | ), 93 | '/var/www/phpweb/include/site.inc' => 94 | array ( 95 | 'full_path' => '/var/www/phpweb/include/site.inc', 96 | 'hits' => 5605, 97 | 'memory_consumption' => 63488, 98 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 99 | 'last_used_timestamp' => 1363461391, 100 | 'timestamp' => 1354724402, 101 | ), 102 | '/var/www/phpweb/include/mirrors.inc' => 103 | array ( 104 | 'full_path' => '/var/www/phpweb/include/mirrors.inc', 105 | 'hits' => 5605, 106 | 'memory_consumption' => 96160, 107 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 108 | 'last_used_timestamp' => 1363461391, 109 | 'timestamp' => 1363419613, 110 | ), 111 | '/var/www/phpweb/manual/en/toc/refs.basic.vartype.inc' => 112 | array ( 113 | 'full_path' => '/var/www/phpweb/manual/en/toc/refs.basic.vartype.inc', 114 | 'hits' => 9, 115 | 'memory_consumption' => 5032, 116 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 117 | 'last_used_timestamp' => 1363461391, 118 | 'timestamp' => 1363345844, 119 | ), 120 | '/var/www/phpweb/include/layout.inc' => 121 | array ( 122 | 'full_path' => '/var/www/phpweb/include/layout.inc', 123 | 'hits' => 5605, 124 | 'memory_consumption' => 145704, 125 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 126 | 'last_used_timestamp' => 1363461391, 127 | 'timestamp' => 1356610801, 128 | ), 129 | '/var/www/phpweb/sites.php' => 130 | array ( 131 | 'full_path' => '/var/www/phpweb/sites.php', 132 | 'hits' => 73, 133 | 'memory_consumption' => 2024, 134 | 'last_used' => 'Sat Mar 16 12:10:10 2013', 135 | 'last_used_timestamp' => 1363461010, 136 | 'timestamp' => 1354724402, 137 | ), 138 | '/var/www/phpweb/search.php' => 139 | array ( 140 | 'full_path' => '/var/www/phpweb/search.php', 141 | 'hits' => 3083, 142 | 'memory_consumption' => 19728, 143 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 144 | 'last_used_timestamp' => 1363461391, 145 | 'timestamp' => 1347648005, 146 | ), 147 | '/var/www/phpweb/manual/en/toc/langref.inc' => 148 | array ( 149 | 'full_path' => '/var/www/phpweb/manual/en/toc/langref.inc', 150 | 'hits' => 49, 151 | 'memory_consumption' => 7416, 152 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 153 | 'last_used_timestamp' => 1363461391, 154 | 'timestamp' => 1363345411, 155 | ), 156 | '/var/www/phpweb/manual/en/toc/index.inc' => 157 | array ( 158 | 'full_path' => '/var/www/phpweb/manual/en/toc/index.inc', 159 | 'hits' => 132, 160 | 'memory_consumption' => 4680, 161 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 162 | 'last_used_timestamp' => 1363461391, 163 | 'timestamp' => 1363345409, 164 | ), 165 | '/var/www/phpweb/docs.php' => 166 | array ( 167 | 'full_path' => '/var/www/phpweb/docs.php', 168 | 'hits' => 73, 169 | 'memory_consumption' => 4536, 170 | 'last_used' => 'Sat Mar 16 12:04:36 2013', 171 | 'last_used_timestamp' => 1363460676, 172 | 'timestamp' => 1347648000, 173 | ), 174 | '/var/www/phpweb/include/shared-manual.inc' => 175 | array ( 176 | 'full_path' => '/var/www/phpweb/include/shared-manual.inc', 177 | 'hits' => 122, 178 | 'memory_consumption' => 107688, 179 | 'last_used' => 'Sat Mar 16 12:06:15 2013', 180 | 'last_used_timestamp' => 1363460775, 181 | 'timestamp' => 1357938001, 182 | ), 183 | '/var/www/phpweb/include/mozopensearch.inc' => 184 | array ( 185 | 'full_path' => '/var/www/phpweb/include/mozopensearch.inc', 186 | 'hits' => 14, 187 | 'memory_consumption' => 1232, 188 | 'last_used' => 'Sat Mar 16 12:00:34 2013', 189 | 'last_used_timestamp' => 1363460434, 190 | 'timestamp' => 1347648001, 191 | ), 192 | '/var/www/phpweb/include/ip-to-country.inc' => 193 | array ( 194 | 'full_path' => '/var/www/phpweb/include/ip-to-country.inc', 195 | 'hits' => 5605, 196 | 'memory_consumption' => 21840, 197 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 198 | 'last_used_timestamp' => 1363461391, 199 | 'timestamp' => 1347648001, 200 | ), 201 | '/var/www/phpweb/include/version.inc' => 202 | array ( 203 | 'full_path' => '/var/www/phpweb/include/version.inc', 204 | 'hits' => 775, 205 | 'memory_consumption' => 7880, 206 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 207 | 'last_used_timestamp' => 1363461391, 208 | 'timestamp' => 1363321202, 209 | ), 210 | '/var/www/phpweb/include/errors.inc' => 211 | array ( 212 | 'full_path' => '/var/www/phpweb/include/errors.inc', 213 | 'hits' => 691, 214 | 'memory_consumption' => 59888, 215 | 'last_used' => 'Sat Mar 16 12:10:33 2013', 216 | 'last_used_timestamp' => 1363461033, 217 | 'timestamp' => 1347648001, 218 | ), 219 | '/var/www/phpweb/include/countries.inc' => 220 | array ( 221 | 'full_path' => '/var/www/phpweb/include/countries.inc', 222 | 'hits' => 5605, 223 | 'memory_consumption' => 31184, 224 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 225 | 'last_used_timestamp' => 1363461391, 226 | 'timestamp' => 1363419614, 227 | ), 228 | '/var/www/phpweb/error.php' => 229 | array ( 230 | 'full_path' => '/var/www/phpweb/error.php', 231 | 'hits' => 691, 232 | 'memory_consumption' => 61952, 233 | 'last_used' => 'Sat Mar 16 12:10:33 2013', 234 | 'last_used_timestamp' => 1363461033, 235 | 'timestamp' => 1347648000, 236 | ), 237 | '/var/www/phpweb/manual/en/toc/refs.basic.text.inc' => 238 | array ( 239 | 'full_path' => '/var/www/phpweb/manual/en/toc/refs.basic.text.inc', 240 | 'hits' => 9, 241 | 'memory_consumption' => 3312, 242 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 243 | 'last_used_timestamp' => 1363461391, 244 | 'timestamp' => 1363345831, 245 | ), 246 | '/var/www/phpweb/include/loadavg.inc' => 247 | array ( 248 | 'full_path' => '/var/www/phpweb/include/loadavg.inc', 249 | 'hits' => 3775, 250 | 'memory_consumption' => 12184, 251 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 252 | 'last_used_timestamp' => 1363461391, 253 | 'timestamp' => 1354738801, 254 | ), 255 | '/var/www/phpweb/include/prepend.inc' => 256 | array ( 257 | 'full_path' => '/var/www/phpweb/include/prepend.inc', 258 | 'hits' => 5605, 259 | 'memory_consumption' => 23432, 260 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 261 | 'last_used_timestamp' => 1363461391, 262 | 'timestamp' => 1347648001, 263 | ), 264 | '/var/www/phpweb/o.php' => 265 | array ( 266 | 'full_path' => '/var/www/phpweb/o.php', 267 | 'hits' => 1, 268 | 'memory_consumption' => 13424, 269 | 'last_used' => 'Sat Mar 16 18:11:21 2013', 270 | 'last_used_timestamp' => 1363482681, 271 | 'timestamp' => 1363482654, 272 | ), 273 | '/var/www/phpweb/include/pregen-events.inc' => 274 | array ( 275 | 'full_path' => '/var/www/phpweb/include/pregen-events.inc', 276 | 'hits' => 1141, 277 | 'memory_consumption' => 840, 278 | 'last_used' => 'Sat Mar 16 12:15:07 2013', 279 | 'last_used_timestamp' => 1363461307, 280 | 'timestamp' => 1363419615, 281 | ), 282 | '/var/www/phpweb/opcache.php' => 283 | array ( 284 | 'full_path' => '/var/www/phpweb/opcache.php', 285 | 'hits' => 0, 286 | 'memory_consumption' => 13944, 287 | 'last_used' => 'Sun Mar 17 01:22:31 2013', 288 | 'last_used_timestamp' => 1363508551, 289 | 'timestamp' => 1363508542, 290 | ), 291 | '/var/www/phpweb/manual/en/toc/refs.calendar.inc' => 292 | array ( 293 | 'full_path' => '/var/www/phpweb/manual/en/toc/refs.calendar.inc', 294 | 'hits' => 9, 295 | 'memory_consumption' => 2264, 296 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 297 | 'last_used_timestamp' => 1363461391, 298 | 'timestamp' => 1363345437, 299 | ), 300 | '/var/www/phpweb/manual/en/toc/security.inc' => 301 | array ( 302 | 'full_path' => '/var/www/phpweb/manual/en/toc/security.inc', 303 | 'hits' => 19, 304 | 'memory_consumption' => 5352, 305 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 306 | 'last_used_timestamp' => 1363461391, 307 | 'timestamp' => 1363345419, 308 | ), 309 | '/var/www/phpweb/include/pregen-news.inc' => 310 | array ( 311 | 'full_path' => '/var/www/phpweb/include/pregen-news.inc', 312 | 'hits' => 1161, 313 | 'memory_consumption' => 57896, 314 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 315 | 'last_used_timestamp' => 1363461391, 316 | 'timestamp' => 1363419615, 317 | ), 318 | '/var/www/phpweb/my.php' => 319 | array ( 320 | 'full_path' => '/var/www/phpweb/my.php', 321 | 'hits' => 34, 322 | 'memory_consumption' => 22640, 323 | 'last_used' => 'Sat Mar 16 12:15:15 2013', 324 | 'last_used_timestamp' => 1363461315, 325 | 'timestamp' => 1354724402, 326 | ), 327 | '/var/www/phpweb/include/pregen-confs.inc' => 328 | array ( 329 | 'full_path' => '/var/www/phpweb/include/pregen-confs.inc', 330 | 'hits' => 678, 331 | 'memory_consumption' => 1400, 332 | 'last_used' => 'Sat Mar 16 12:02:49 2013', 333 | 'last_used_timestamp' => 1363460569, 334 | 'timestamp' => 1363419615, 335 | ), 336 | '/var/www/index.php' => 337 | array ( 338 | 'full_path' => '/var/www/index.php', 339 | 'hits' => 1, 340 | 'memory_consumption' => 744, 341 | 'last_used' => 'Sat Mar 16 12:01:20 2013', 342 | 'last_used_timestamp' => 1363460480, 343 | 'timestamp' => 1358644238, 344 | ), 345 | '/var/www/phpweb/index-stable.php' => 346 | array ( 347 | 'full_path' => '/var/www/phpweb/index-stable.php', 348 | 'hits' => 679, 349 | 'memory_consumption' => 22208, 350 | 'last_used' => 'Sat Mar 16 12:02:49 2013', 351 | 'last_used_timestamp' => 1363460569, 352 | 'timestamp' => 1347648003, 353 | ), 354 | '/var/www/phpweb/conferences/index.php' => 355 | array ( 356 | 'full_path' => '/var/www/phpweb/conferences/index.php', 357 | 'hits' => 462, 358 | 'memory_consumption' => 3872, 359 | 'last_used' => 'Sat Mar 16 12:15:07 2013', 360 | 'last_used_timestamp' => 1363461307, 361 | 'timestamp' => 1347648000, 362 | ), 363 | '/var/www/phpweb/support.php' => 364 | array ( 365 | 'full_path' => '/var/www/phpweb/support.php', 366 | 'hits' => 73, 367 | 'memory_consumption' => 1912, 368 | 'last_used' => 'Sat Mar 16 12:06:40 2013', 369 | 'last_used_timestamp' => 1363460800, 370 | 'timestamp' => 1347648005, 371 | ), 372 | '/var/www/phpweb/op.php' => 373 | array ( 374 | 'full_path' => '/var/www/phpweb/op.php', 375 | 'hits' => 0, 376 | 'memory_consumption' => 1448, 377 | 'last_used' => 'Sun Mar 17 01:34:33 2013', 378 | 'last_used_timestamp' => 1363509273, 379 | 'timestamp' => 1363509263, 380 | ), 381 | '/var/www/phpweb/include/posttohost.inc' => 382 | array ( 383 | 'full_path' => '/var/www/phpweb/include/posttohost.inc', 384 | 'hits' => 342, 385 | 'memory_consumption' => 3824, 386 | 'last_used' => 'Sat Mar 16 12:09:18 2013', 387 | 'last_used_timestamp' => 1363460958, 388 | 'timestamp' => 1347648001, 389 | ), 390 | '/var/www/phpweb/include/langchooser.inc' => 391 | array ( 392 | 'full_path' => '/var/www/phpweb/include/langchooser.inc', 393 | 'hits' => 5605, 394 | 'memory_consumption' => 23784, 395 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 396 | 'last_used_timestamp' => 1363461391, 397 | 'timestamp' => 1347648001, 398 | ), 399 | '/var/www/phpweb/include/manual-lookup.inc' => 400 | array ( 401 | 'full_path' => '/var/www/phpweb/include/manual-lookup.inc', 402 | 'hits' => 624, 403 | 'memory_consumption' => 26648, 404 | 'last_used' => 'Sat Mar 16 12:10:33 2013', 405 | 'last_used_timestamp' => 1363461033, 406 | 'timestamp' => 1354750802, 407 | ), 408 | '/var/www/phpweb/mailing-lists.php' => 409 | array ( 410 | 'full_path' => '/var/www/phpweb/mailing-lists.php', 411 | 'hits' => 342, 412 | 'memory_consumption' => 31576, 413 | 'last_used' => 'Sat Mar 16 12:09:18 2013', 414 | 'last_used_timestamp' => 1363460958, 415 | 'timestamp' => 1361200802, 416 | ), 417 | '/var/www/phpweb/include/last_updated.inc' => 418 | array ( 419 | 'full_path' => '/var/www/phpweb/include/last_updated.inc', 420 | 'hits' => 5605, 421 | 'memory_consumption' => 840, 422 | 'last_used' => 'Sat Mar 16 12:16:31 2013', 423 | 'last_used_timestamp' => 1363461391, 424 | 'timestamp' => 1363419675, 425 | ), 426 | '/var/www/phpweb/include/email-validation.inc' => 427 | array ( 428 | 'full_path' => '/var/www/phpweb/include/email-validation.inc', 429 | 'hits' => 342, 430 | 'memory_consumption' => 9168, 431 | 'last_used' => 'Sat Mar 16 12:09:18 2013', 432 | 'last_used_timestamp' => 1363460958, 433 | 'timestamp' => 1362175205, 434 | ), 435 | '/var/www/phpweb/index.php' => 436 | array ( 437 | 'full_path' => '/var/www/phpweb/index.php', 438 | 'hits' => 679, 439 | 'memory_consumption' => 1840, 440 | 'last_used' => 'Sat Mar 16 12:02:49 2013', 441 | 'last_used_timestamp' => 1363460569, 442 | 'timestamp' => 1347648003, 443 | ), 444 | ), 445 | ); 446 | } 447 | 448 | function opcache_get_configuration() { 449 | return array ( 450 | 'directives' => 451 | array ( 452 | 'opcache.enable' => true, 453 | 'opcache.enable_cli' => false, 454 | 'opcache.use_cwd' => true, 455 | 'opcache.validate_timestamps' => true, 456 | 'opcache.inherited_hack' => true, 457 | 'opcache.dups_fix' => false, 458 | 'opcache.revalidate_path' => false, 459 | 'opcache.log_verbosity_level' => 4, 460 | 'opcache.memory_consumption' => 16777216, 461 | 'opcache.interned_strings_buffer' => 8, 462 | 'opcache.max_accelerated_files' => 200, 463 | 'opcache.max_wasted_percentage' => 0.05, 464 | 'opcache.consistency_checks' => 0, 465 | 'opcache.force_restart_timeout' => 180, 466 | 'opcache.revalidate_freq' => 0, 467 | 'opcache.preferred_memory_model' => '', 468 | 'opcache.blacklist_filename' => '/etc/zo_blacklist.txt', 469 | 'opcache.max_file_size' => 0, 470 | 'opcache.error_log' => '', 471 | 'opcache.protect_memory' => false, 472 | 'opcache.save_comments' => true, 473 | 'opcache.load_comments' => true, 474 | 'opcache.fast_shutdown' => true, 475 | 'opcache.enable_file_override' => false, 476 | 'opcache.optimization_level' => 4294967295, 477 | ), 478 | 'version' => 479 | array ( 480 | 'version' => '7.0.1-dev', 481 | 'opcache_product_name' => 'Zend Optimizer+', 482 | ), 483 | 'blacklist' => 484 | array ( 485 | 0 => '/var/www/www.php.net/manual/es', 486 | 1 => '/var/www/www.php.net/manual/it', 487 | 2 => '/var/www/www.php.net/manual/bg', 488 | 3 => '/var/www/www.php.net/manual/fa', 489 | 4 => '/var/www/www.php.net/manual/fr', 490 | 5 => '/var/www/www.php.net/manual/kr', 491 | 6 => '/var/www/www.php.net/manual/pt_BR', 492 | 7 => '/var/www/www.php.net/manual/tr', 493 | 8 => '/var/www/www.php.net/manual/de', 494 | 9 => '/var/www/www.php.net/manual/ro', 495 | 10 => '/var/www/www.php.net/manual/ru', 496 | 11 => '/var/www/www.php.net/manual/zh', 497 | 12 => '/var/www/www.php.net/manual/ja', 498 | 13 => '/var/www/www.php.net/manual/pl', 499 | 14 => '/var/www/www.php.net/manual/sr', 500 | ), 501 | ); 502 | } 503 | -------------------------------------------------------------------------------- /opcache.php: -------------------------------------------------------------------------------- 1 | You do not have the Zend OPcache extension loaded, sample data is being shown instead.'; 7 | require 'data-sample.php'; 8 | } 9 | 10 | class OpCacheDataModel 11 | { 12 | private $_configuration; 13 | private $_status; 14 | private $_d3Scripts = array(); 15 | 16 | public function __construct() 17 | { 18 | $this->_configuration = opcache_get_configuration(); 19 | $this->_status = opcache_get_status(); 20 | } 21 | 22 | public function getPageTitle() 23 | { 24 | return 'PHP ' . phpversion() . " with OpCache {$this->_configuration['version']['version']}"; 25 | } 26 | 27 | public function getStatusDataRows() 28 | { 29 | $rows = array(); 30 | foreach ($this->_status as $key => $value) { 31 | if ($key === 'scripts') { 32 | continue; 33 | } 34 | 35 | if (is_array($value)) { 36 | foreach ($value as $k => $v) { 37 | if ($v === false) { 38 | $value = 'false'; 39 | } 40 | if ($v === true) { 41 | $value = 'true'; 42 | } 43 | if ($k === 'used_memory' || $k === 'free_memory' || $k === 'wasted_memory') { 44 | $v = $this->_size_for_humans( 45 | $v 46 | ); 47 | } 48 | if ($k === 'current_wasted_percentage' || $k === 'opcache_hit_rate') { 49 | $v = number_format( 50 | $v, 51 | 2 52 | ) . '%'; 53 | } 54 | if ($k === 'blacklist_miss_ratio') { 55 | $v = number_format($v, 2) . '%'; 56 | } 57 | if ($k === 'start_time' || $k === 'last_restart_time') { 58 | $v = ($v ? date(DATE_RFC822, $v) : 'never'); 59 | } 60 | if (THOUSAND_SEPARATOR === true && is_int($v)) { 61 | $v = number_format($v); 62 | } 63 | 64 | $rows[] = "$k$v\n"; 65 | } 66 | continue; 67 | } 68 | if ($value === false) { 69 | $value = 'false'; 70 | } 71 | if ($value === true) { 72 | $value = 'true'; 73 | } 74 | $rows[] = "$key$value\n"; 75 | } 76 | 77 | return implode("\n", $rows); 78 | } 79 | 80 | public function getConfigDataRows() 81 | { 82 | $rows = array(); 83 | foreach ($this->_configuration['directives'] as $key => $value) { 84 | if ($value === false) { 85 | $value = 'false'; 86 | } 87 | if ($value === true) { 88 | $value = 'true'; 89 | } 90 | if ($key == 'opcache.memory_consumption') { 91 | $value = $this->_size_for_humans($value); 92 | } 93 | $rows[] = "$key$value\n"; 94 | } 95 | 96 | return implode("\n", $rows); 97 | } 98 | 99 | public function getScriptStatusRows() 100 | { 101 | foreach ($this->_status['scripts'] as $key => $data) { 102 | $dirs[dirname($key)][basename($key)] = $data; 103 | $this->_arrayPset($this->_d3Scripts, $key, array( 104 | 'name' => basename($key), 105 | 'size' => $data['memory_consumption'], 106 | )); 107 | } 108 | 109 | asort($dirs); 110 | 111 | $basename = ''; 112 | while (true) { 113 | if (count($this->_d3Scripts) !=1) break; 114 | $basename .= DIRECTORY_SEPARATOR . key($this->_d3Scripts); 115 | $this->_d3Scripts = reset($this->_d3Scripts); 116 | } 117 | 118 | $this->_d3Scripts = $this->_processPartition($this->_d3Scripts, $basename); 119 | $id = 1; 120 | 121 | $rows = array(); 122 | foreach ($dirs as $dir => $files) { 123 | $count = count($files); 124 | $file_plural = $count > 1 ? 's' : null; 125 | $m = 0; 126 | foreach ($files as $file => $data) { 127 | $m += $data["memory_consumption"]; 128 | } 129 | $m = $this->_size_for_humans($m); 130 | 131 | if ($count > 1) { 132 | $rows[] = ''; 133 | $rows[] = "{$dir} ({$count} file{$file_plural}, {$m})"; 134 | $rows[] = ''; 135 | } 136 | 137 | foreach ($files as $file => $data) { 138 | $rows[] = ""; 139 | $rows[] = "" . $this->_format_value($data["hits"]) . ""; 140 | $rows[] = "" . $this->_size_for_humans($data["memory_consumption"]) . ""; 141 | $rows[] = $count > 1 ? "{$file}" : "{$dir}/{$file}"; 142 | $rows[] = ''; 143 | } 144 | 145 | ++$id; 146 | } 147 | 148 | return implode("\n", $rows); 149 | } 150 | 151 | public function getScriptStatusCount() 152 | { 153 | return count($this->_status["scripts"]); 154 | } 155 | 156 | public function getGraphDataSetJson() 157 | { 158 | $dataset = array(); 159 | $dataset['memory'] = array( 160 | $this->_status['memory_usage']['used_memory'], 161 | $this->_status['memory_usage']['free_memory'], 162 | $this->_status['memory_usage']['wasted_memory'], 163 | ); 164 | 165 | $dataset['keys'] = array( 166 | $this->_status['opcache_statistics']['num_cached_keys'], 167 | $this->_status['opcache_statistics']['max_cached_keys'] - $this->_status['opcache_statistics']['num_cached_keys'], 168 | 0 169 | ); 170 | 171 | $dataset['hits'] = array( 172 | $this->_status['opcache_statistics']['misses'], 173 | $this->_status['opcache_statistics']['hits'], 174 | 0, 175 | ); 176 | 177 | $dataset['restarts'] = array( 178 | $this->_status['opcache_statistics']['oom_restarts'], 179 | $this->_status['opcache_statistics']['manual_restarts'], 180 | $this->_status['opcache_statistics']['hash_restarts'], 181 | ); 182 | 183 | if (THOUSAND_SEPARATOR === true) { 184 | $dataset['TSEP'] = 1; 185 | } else { 186 | $dataset['TSEP'] = 0; 187 | } 188 | 189 | return json_encode($dataset); 190 | } 191 | 192 | public function getHumanUsedMemory() 193 | { 194 | return $this->_size_for_humans($this->getUsedMemory()); 195 | } 196 | 197 | public function getHumanFreeMemory() 198 | { 199 | return $this->_size_for_humans($this->getFreeMemory()); 200 | } 201 | 202 | public function getHumanWastedMemory() 203 | { 204 | return $this->_size_for_humans($this->getWastedMemory()); 205 | } 206 | 207 | public function getUsedMemory() 208 | { 209 | return $this->_status['memory_usage']['used_memory']; 210 | } 211 | 212 | public function getFreeMemory() 213 | { 214 | return $this->_status['memory_usage']['free_memory']; 215 | } 216 | 217 | public function getWastedMemory() 218 | { 219 | return $this->_status['memory_usage']['wasted_memory']; 220 | } 221 | 222 | public function getWastedMemoryPercentage() 223 | { 224 | return number_format($this->_status['memory_usage']['current_wasted_percentage'], 2); 225 | } 226 | 227 | public function getD3Scripts() 228 | { 229 | return $this->_d3Scripts; 230 | } 231 | 232 | private function _processPartition($value, $name = null) 233 | { 234 | if (array_key_exists('size', $value)) { 235 | return $value; 236 | } 237 | 238 | $array = array('name' => $name,'children' => array()); 239 | 240 | foreach ($value as $k => $v) { 241 | $array['children'][] = $this->_processPartition($v, $k); 242 | } 243 | 244 | return $array; 245 | } 246 | 247 | private function _format_value($value) 248 | { 249 | if (THOUSAND_SEPARATOR === true) { 250 | return number_format($value); 251 | } else { 252 | return $value; 253 | } 254 | } 255 | 256 | private function _size_for_humans($bytes) 257 | { 258 | if ($bytes > 1048576) { 259 | return sprintf('%.2f MB', $bytes / 1048576); 260 | } else { 261 | if ($bytes > 1024) { 262 | return sprintf('%.2f kB', $bytes / 1024); 263 | } else { 264 | return sprintf('%d bytes', $bytes); 265 | } 266 | } 267 | } 268 | 269 | // Borrowed from Laravel 270 | private function _arrayPset(&$array, $key, $value) 271 | { 272 | if (is_null($key)) return $array = $value; 273 | $keys = explode(DIRECTORY_SEPARATOR, ltrim($key, DIRECTORY_SEPARATOR)); 274 | while (count($keys) > 1) { 275 | $key = array_shift($keys); 276 | if ( ! isset($array[$key]) || ! is_array($array[$key])) { 277 | $array[$key] = array(); 278 | } 279 | $array =& $array[$key]; 280 | } 281 | $array[array_shift($keys)] = $value; 282 | return $array; 283 | } 284 | 285 | } 286 | 287 | $dataModel = new OpCacheDataModel(); 288 | ?> 289 | 290 | 291 | 292 | 293 | 461 | 462 | 463 | 477 | <?php echo $dataModel->getPageTitle(); ?> 478 | 479 | 480 | 481 |
482 |

getPageTitle(); ?>

483 | 484 |
485 | 486 |
487 | 488 | 489 |
490 | 491 | getStatusDataRows(); ?> 492 |
493 |
494 |
495 | 496 |
497 | 498 | 499 |
500 | 501 | getConfigDataRows(); ?> 502 |
503 |
504 |
505 | 506 |
507 | 508 | 509 |
510 | 511 | 512 | 513 | 514 | 515 | 516 | getScriptStatusRows(); ?> 517 |
HitsMemoryPath
518 |
519 |
520 | 521 |
522 | 523 | 524 |
525 |
526 | 527 |
528 | 529 |
530 |
531 | 532 | 533 | 534 | 535 |
536 | 537 |
538 |
539 |
540 | 541 |
✖ Close Visualisation
542 |
543 | 544 | 743 | 744 | 745 | --------------------------------------------------------------------------------