Changeset 3492583
- Timestamp:
- 03/27/2026 11:17:42 AM (22 hours ago)
- Location:
- ressources/trunk
- Files:
-
- 2 edited
-
ressources.css (modified) (1 diff)
-
ressources.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ressources/trunk/ressources.css
r3492522 r3492583 27 27 } 28 28 29 #ressources_cpu .cpu-ships{ 30 display: inline-flex; 31 flex-wrap: wrap; 32 gap: 2px; 33 } 34 #ressources_cpu .cpu-ship{ 35 background: linear-gradient(90deg, var(--wp-admin-theme-color), var(--wp-admin-theme-color-darker-10) 100%); 36 width: 10px; 37 height: 10px; 38 cursor: progress; 39 } 40 29 41 #ressources_memory .inside, 30 42 #ressources_disk .inside, -
ressources/trunk/ressources.php
r3492532 r3492583 175 175 <th><?php esc_attr_e('TIME', 'ressources') ?></th> 176 176 <th><?php esc_attr_e('CPU Load average', 'ressources') ?></th> 177 <th><?php esc_attr_e('Utilization', 'ressources') ?></th> 177 178 </tr> 178 179 </thead> 179 <tbody class="ressources-widget-content" data-id="cpu" data-refresh=" 20">180 <tbody class="ressources-widget-content" data-id="cpu" data-refresh="5"> 180 181 </tbody> 181 182 </table> … … 284 285 // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec 285 286 exec('cat /proc/loadavg', $cpuloadavg); 287 // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec 288 exec('grep "^model name" /proc/cpuinfo', $model); 289 $count = count($model); 290 // get load of each CPU core 291 $cpus_load = array(); 292 for($i=0; $i<$count; $i++){ 293 // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec 294 exec('cat /proc/stat | grep "^cpu'.$i.'"', $cpus_load[$i]); 295 } 286 296 if($cpuloadavg){ 287 297 $load = explode(' ',$cpuloadavg[0]); 288 298 ?> 289 299 <tr> 290 <td>1 MIN</td> 291 <td><?php echo esc_html( $load[0] ) ?></td> 292 </tr> 293 <tr> 294 <td>5 MIN</td> 295 <td><?php echo esc_html( $load[1] ) ?></td> 296 </tr> 297 <tr> 298 <td>15 MIN</td> 299 <td><?php echo esc_html( $load[2] ) ?></td> 300 <td>1 MIN</td> 301 <td><?php echo esc_html( $load[0] ) ?></td> 302 <td> 303 <div class="cpu-ships"> 304 <?php foreach($cpus_load as $cpu => $cpu_load): ?> 305 <?php 306 $data = explode(' ',$cpu_load[0]); 307 $total = array_sum(array_slice($data, 1)); 308 $idle = $data[4]; 309 $usage = 100 - round($idle / $total * 100); 310 // translators: %1$d is the CPU index, %2$d is the CPU usage percentage ?> 311 <div class="cpu-ship" style="opacity:<?php echo esc_attr( $usage/100 ) ?>;" title="<?php echo esc_attr( sprintf('CPU %1$d: %2$d%% load', $cpu+1, $usage) ) ?>"> 312 </div> 313 <?php endforeach; ?> 314 </div> 315 </td> 316 </tr> 317 <tr> 318 <td>5 MIN</td> 319 <td><?php echo esc_html( $load[1] ) ?></td> 320 </tr> 321 <tr> 322 <td>15 MIN</td> 323 <td><?php echo esc_html( $load[2] ) ?></td> 300 324 </tr> 301 325 <?php 302 326 } 303 327 } 328 304 329 function getMySQLVersion() { 305 330 // PHPCS:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_shell_exec
Note: See TracChangeset
for help on using the changeset viewer.