1.8 KiB
1.8 KiB
PHP-Furnace
Proof of concept in alpha stage.
A near zero-dependency, PHP-FPM process profiler and live streaming dashboard. Designed for PHP 8.1+ using only standard libraries. It uses /proc
, gdb
, and Server-Sent Events to continuously trace live PHP-FPM processes but requires PHP to have pcntl extension to be enabled.
🚀 Features
-
Monitors all running PHP-FPM worker processes
-
Tracks:
- Memory usage
- CPU time and deltas
- Number of open file descriptors
- Number of threads
- Last handled request URI (via
$_SERVER['REQUEST_URI']
) - Backtraces using GDB
-
Streams data live to the browser via SSE
-
Comes with a minimal HTML viewer
-
Logs data in newline-delimited JSON for later use
📦 Requirements
- PHP 8.1 or later
- Linux-based system (uses
/proc
and GDB) gdb
installed and executable by the current userpcntl
extension enabled
sudo apt install gdb
🛠️ Setup
- Ensure
gdb
andpcntl
are available - Run the script:
php furnace.php
- Open the live dashboard:
http://localhost:8123/
📁 Output Location
Log data is appended to:
/tmp/php-furnace/furnace-stream.log
Each event is streamed to the browser and formatted in JSON:
{
"time": 1720043265,
"delta": 5,
"pid": 3410,
"calls": 3,
"cpu_time_ticks": 20199,
"cpu_delta": 15,
"memory_kb": 10240,
"threads": 1,
"fds": 23,
"request_uri": "/index.php",
"stack": ["#0 ...", "#1 ..."]
}
🧯 Troubleshooting
-
No data in the browser:
- Check
/tmp/php-furnace/furnace-stream.log
for entries - Confirm PHP-FPM workers exist via
ps aux | grep php-fpm
- Ensure
gdb
is installed and accessible without blocking
- Check
-
GDB timeout:
- Process may be idle or protected — increase timeout or skip slow PIDs