Skip to content

Commit df84e0c

Browse files
fix(SystemStatus): cap cpu_usage at 100
1 parent c630bc8 commit df84e0c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/SystemStatus.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ class SystemStatus extends Model {
252252
$cpu_count = (int) get_single_sysctl('hw.ncpu');
253253

254254
# Determine the CPU usage by dividing the last minute load avg by the cpu count and multiplying by 100
255-
return ($load_avg_last_min / $cpu_count) * 100;
255+
$cpu_usage = ($load_avg_last_min / $cpu_count) * 100;
256+
257+
# If the usage estimate is above 100%, ensure it is capped at 100
258+
return ($cpu_usage <= 100) ? $cpu_usage : 100;
256259
}
257260

258261
/**

0 commit comments

Comments
 (0)