From 552ed668291e6782cf215ffb1ce42c3c3e7f63a5 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 21 May 2021 17:20:46 -0400 Subject: [PATCH] fix(cgi-bin): transform CPU cores and threads to JSON numbers --- cgi-bin/get_cpu | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cgi-bin/get_cpu b/cgi-bin/get_cpu index 18bf00f9..80d33795 100755 --- a/cgi-bin/get_cpu +++ b/cgi-bin/get_cpu @@ -118,25 +118,27 @@ ORDER BY scan_hardware_cpu_cores => $scan_hardware_cpu_cores, scan_hardware_cpu_threads => $scan_hardware_cpu_threads, }}); + + # Important: ensure the cores and threads are integers, which will be auto-transformed JSON number type. if (not $hash->{cores}) { - $hash->{cores} = $scan_hardware_cpu_cores; + $hash->{cores} = int($scan_hardware_cpu_cores); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 'hash->cores' => $hash->{cores} }}); } elsif ($scan_hardware_cpu_cores < $hash->{cores}) { - $hash->{cores} = $scan_hardware_cpu_cores; + $hash->{cores} = int($scan_hardware_cpu_cores); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 'hash->cores' => $hash->{cores} }}); } if (not $hash->{threads}) { - $hash->{threads} = $scan_hardware_cpu_threads; + $hash->{threads} = int($scan_hardware_cpu_threads); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 'hash->threads' => $hash->{threads} }}); } elsif ($scan_hardware_cpu_threads < $hash->{threads}) { - $hash->{threads} = $scan_hardware_cpu_threads; + $hash->{threads} = int($scan_hardware_cpu_threads); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { 'hash->threads' => $hash->{threads} }}); } }