PHP Error: Uncaught ValueError in /usr/local/www/rrd_fetch_json.php:431
-
I really don't know since when this error appeared. But if I try to open Status > Monitoring I got this error in the GUI:
Error: JSON not returned. Check to make sure you have an active session
Additionally I got this error message as Notification:
PHP ERROR: Type: 1, File: /usr/local/www/rrd_fetch_json.php, Line: 431, Message: Uncaught ValueError: min(): Argument #1 ($value) must contain at least one element in /usr/local/www/rrd_fetch_json.php:431
Stack trace:
#0 /usr/local/www/rrd_fetch_json.php(431): min(Array)
#1 {main}
thrown
Any suggestions what happened here and how to solve it?
pfSense Plus Home (VM)
v23.01 -
Looks like https://redmine.pfsense.org/issues/13936
But normally that would only happen if a graph database you're trying to access is empty or doesn't exist. For example just after resetting the database files. Once they have data that error shouldn't appear.
But it's fixed in the next version.
You can try applying this diff in the system patches package in the meantime:
diff --git a/sysutils/pfSense-Status_Monitoring/files/usr/local/www/rrd_fetch_json.php b/sysutils/pfSense-Status_Monitoring/files/usr/local/www/rrd_fetch_json.php index 4d7574819ac969f4fde3fab65efa81490bfd195c..43a469b52e56f0a8b62fce548e4c5839ac6c8b28 100644 --- a/blah/usr/local/www/rrd_fetch_json.php +++ b/blah/usr/local/www/rrd_fetch_json.php @@ -428,9 +428,15 @@ foreach ($side as $settings) { $entry['unit_desc'] = $settings['unit_desc']; $entry['invert'] = false; $entry['ninetyfifth'] = true; - $entry['min'] = min($inpass_stats); - $entry['max'] = max($inpass_stats); - $entry['avg'] = array_sum($inpass_stats) / count($inpass_stats); + if ( is_array($inpass_stats) && !empty($inpass_stats) ) { + $entry['min'] = min($inpass_stats); + $entry['max'] = max($inpass_stats); + $entry['avg'] = array_sum($inpass_stats) / count($inpass_stats); + } else { + $entry['min'] = 0; + $entry['max'] = 0; + $entry['avg'] = 0; + } $entry['values'] = $inpass_total; $obj[] = $entry; @@ -443,9 +449,15 @@ foreach ($side as $settings) { $entry['unit_desc'] = $settings['unit_desc']; $entry['invert'] = $invert_graph; $entry['ninetyfifth'] = true; - $entry['min'] = min($outpass_stats); - $entry['max'] = max($outpass_stats); - $entry['avg'] = array_sum($outpass_stats) / count($outpass_stats); + if ( is_array($outpass_stats) && !empty($outpass_stats) ) { + $entry['min'] = min($outpass_stats); + $entry['max'] = max($outpass_stats); + $entry['avg'] = array_sum($outpass_stats) / count($outpass_stats); + } else { + $entry['min'] = 0; + $entry['max'] = 0; + $entry['avg'] = 0; + } $entry['values'] = $outpass_total; $obj[] = $entry; }
-
Thank you very much! I did some research before but never checked redmine.
Problem solved with the patch