3gstats.php 100% CPU
I have a 3G modem connected the USB port of my pfsense SG-2220 appliance.
For whatever reason, the 3G connection is not very stable and often times does not get reestablished, but this issue is actually about the script 3gstats.php using 100% CPU time and not my 3G problems.
The 3G connection on my pfsense box is currently offline and 3gstats.php uses 100% CPU time:
root 18315 98.7 1.1 228224 22412 u1- R 20Sep15 1164:20.63 /usr/local/bin/php -f /usr/local/bin/3gstats.php cuaU0.3 opt3
I guess CPU goes down when the 3G connection does work, but I cannot confirm that now.
Looking at the script, the main things happen in a while(true) loop, which does not have any kind of throttling or error handling built in.
I'm not familiar with PHP, but shouldn't there be some error handling when fgets cannot read from the device, or at least throttle the while loop to read only every X milliseconds?