├── LICENSE ├── README.md ├── composer.json ├── opcache.php ├── thumbnail-1.png ├── thumbnail-2.png ├── thumbnail-3.png └── thumbnail-4.png /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Carlos Buenosvinos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OPcache Dashboard 2 | ================= 3 | Set up properly and monitor your Zend OPcache with this dashboard that will help you checking memory, hits and status, configuring for optimal performance (warning you when cache full, validation, etc.) and reseting one or all scripts with one click. 4 | 5 | Installation 6 | ============ 7 | 8 | Composer installation: 9 | ``` 10 | composer require carlosio/opcache-dashboard 11 | ``` 12 | Then you can symlink it to your public folder or require it from another php file. 13 | 14 | Or just copy and paste ```opcache.php``` anywhere in your public folder. You can use something such as: 15 | ```wget https://raw.github.com/carlosbuenosvinos/opcache-dashboard/master/opcache.php``` 16 | 17 | **Try to keep it safe for non authorized users.** 18 | 19 | Screenshots 20 | =========== 21 | ![Main page](https://raw.github.com/carlosbuenosvinos/opcache-dashboard/master/thumbnail-1.png) 22 | ![Status](https://raw.github.com/carlosbuenosvinos/opcache-dashboard/master/thumbnail-2.png) 23 | ![Configuration](https://raw.github.com/carlosbuenosvinos/opcache-dashboard/master/thumbnail-3.png) 24 | ![Scripts](https://raw.github.com/carlosbuenosvinos/opcache-dashboard/master/thumbnail-4.png) 25 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "carlosio/opcache-dashboard", 3 | "description": "Set up properly and monitor your Zend OPcache with this dashboard that will help you checking memory, hits and status, configuring for optimal performance (warning you when cache full, validation, etc.) and reseting one or all scripts with one click.", 4 | "keywords": ["opcache"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Carlos Buenosvinos", 9 | "email": "hi@carlos.io" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /opcache.php: -------------------------------------------------------------------------------- 1 | 1048576) { 28 | return sprintf("%.2f MB", $bytes/1048576); 29 | } elseif ($bytes > 1024) { 30 | return sprintf("%.2f kB", $bytes/1024); 31 | } else { 32 | return sprintf("%d bytes", $bytes); 33 | } 34 | } 35 | 36 | function getOffsetWhereStringsAreEqual($a, $b) 37 | { 38 | $i = 0; 39 | while (strlen($a) && strlen($b) && strlen($a) > $i && $a{$i} === $b{$i}) { 40 | $i++; 41 | } 42 | 43 | return $i; 44 | } 45 | 46 | function getSuggestionMessage($property, $value) 47 | { 48 | switch ($property) { 49 | case 'opcache_enabled': 50 | return $value ? '' : ' You should enabled opcache'; 51 | break; 52 | case 'cache_full': 53 | return $value ? ' You should increase opcache.memory_consumption' : ''; 54 | break; 55 | case 'opcache.validate_timestamps': 56 | return $value ? ' If you are in a production environment you should disabled it' : ''; 57 | break; 58 | } 59 | 60 | return ''; 61 | } 62 | 63 | function getStringFromPropertyAndValue($property, $value) 64 | { 65 | if ($value === false) { 66 | return 'false'; 67 | } 68 | 69 | if ($value === true) { 70 | return 'true'; 71 | } 72 | 73 | switch ($property) { 74 | case 'used_memory': 75 | case 'free_memory': 76 | case 'wasted_memory': 77 | case 'opcache.memory_consumption': 78 | return size_for_humans($value); 79 | break; 80 | case 'current_wasted_percentage': 81 | case 'opcache_hit_rate': 82 | return number_format($value, 2).'%'; 83 | break; 84 | case 'blacklist_miss_ratio': 85 | return number_format($value, 2); 86 | break; 87 | } 88 | 89 | return $value; 90 | } 91 | 92 | ?> 93 | 94 | 95 | 96 | OPcache Dashboard - Carlos Buenosvinos (@buenosvinos) 97 | 98 | 99 | 100 | 108 | 109 | 110 | 111 | 115 | 116 | 117 | Fork me on GitHub 118 | 140 | 141 |
142 |
143 |

OPcache Dashboard

144 |

by Carlos Buenosvinos (@buenosvinos)

145 |

PHP: and OPcache:

146 |
147 | 148 | 152 |

Hits: %

153 |
154 |
155 | Hits 156 |
157 |
158 | Misses 159 |
160 |
161 | 162 | 169 | 170 |

Memory: of

171 |
172 |
173 | Wasted memory 174 |
175 |
176 | Used memory 177 |
178 |
179 | Free memory 180 |
181 |
182 | 183 | 188 |

Keys: of

189 |
190 |
191 | Used keys 192 |
193 |
194 | Free keys 195 |
196 |
197 | 198 |

Status

199 |
200 | 201 | $value) { 203 | if ($key == 'scripts') { 204 | continue; 205 | } 206 | 207 | if (is_array($value)) { 208 | foreach ($value as $k => $v) { 209 | $v = getStringFromPropertyAndValue($k, $v); 210 | $m = getSuggestionMessage($k, $v); 211 | ?> 221 |
222 |
223 | 224 |

Configuration

225 |
226 | 227 | $value) { 228 | $mess = getSuggestionMessage($key, $value); 229 | ?> 230 | 231 | 232 | 233 | 234 | 235 | 236 |
237 |
238 | 239 |

Scripts () Reset all

240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | $data) { 253 | $offset = min( 254 | getOffsetWhereStringsAreEqual( 255 | (null === $previousKey) ? $key : $previousKey, 256 | $key 257 | ), 258 | (null === $offset) ? strlen($key) : $offset 259 | ); 260 | $previousKey = $key; 261 | } 262 | 263 | foreach ($status['scripts'] as $key => $data) { 264 | ?> 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 |
OptionsHitsMemoryPath
Invalidate
273 |
274 | 275 | 276 | 277 | 278 | 279 | -------------------------------------------------------------------------------- /thumbnail-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlosbuenosvinos/opcache-dashboard/cceeb8eb248edd9981f32a37d61790b3f6feab0c/thumbnail-1.png -------------------------------------------------------------------------------- /thumbnail-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlosbuenosvinos/opcache-dashboard/cceeb8eb248edd9981f32a37d61790b3f6feab0c/thumbnail-2.png -------------------------------------------------------------------------------- /thumbnail-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlosbuenosvinos/opcache-dashboard/cceeb8eb248edd9981f32a37d61790b3f6feab0c/thumbnail-3.png -------------------------------------------------------------------------------- /thumbnail-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlosbuenosvinos/opcache-dashboard/cceeb8eb248edd9981f32a37d61790b3f6feab0c/thumbnail-4.png --------------------------------------------------------------------------------