Horizon: ERROR: A non-numeric value encountered - language issue

Created on 27 May 2019  路  7Comments  路  Source: laravel/horizon

Different issue than #597

  • Horizon Version: 3.2.1
  • Laravel Version: 5.8.18
  • PHP Version: 7.3.3

Description:

Running on Valet on MacOS Mojave 10.14.4 - on a German system, and that's the issue.

exec ps axo %cpu,%mem,command returns something like
%CPU %MEM COMMAND
0,0 0,1 /sbin/launchd
0,0 0,0 /usr/sbin/syslogd
0,0 0,1 /usr/libexec/UserEventAgent (System)

The separator in German is a comma. Parsing that fails in SystemProcessCounter.

Steps To Reproduce:

"3,4" / 100 ==> "PHP Notice: A non well formed numeric value encountered"

Solution

Use "float":
return ['cpu' => (float) $row->first() / 100, 'mem' => (float) $row->last()];

needs more info

Most helpful comment

All 7 comments

As I stated, from my point of view it's another issue. #597 drifted towards Alpine - this is about a decimals separator other than ".".

Ping @AJenbo: can we use the solution from above?

Afaik it will loose precision, but I can probably either set the local for the command or do propper parsing of the local specific format to get the correct value. I plan to work on it today so this is good timing 馃檪

Thanks!

@tomswinkels I believe so.

Was this page helpful?
0 / 5 - 0 ratings