mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-19 12:06:29 -04:00
Fix "top" command parsing on FreeBSD (tested in FreeBSD 13.5 jail, running 1.38.1).
This commit is contained in:
@@ -24,6 +24,7 @@ package ZoneMinder::Server;
|
||||
use 5.006;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Config;
|
||||
|
||||
require ZoneMinder::Base;
|
||||
require ZoneMinder::Config;
|
||||
@@ -127,7 +128,13 @@ sub CpuUsage {
|
||||
|
||||
} else {
|
||||
# Get CPU utilization percentages
|
||||
my $top_output = `top -b -n 1 | grep -i "^%Cpu(s)" | awk '{print \$2, \$4, \$6, \$8}'`;
|
||||
my $top_output = '';
|
||||
## FreeBSD
|
||||
if (@Config{qw(uname)} == 'freebsd') {
|
||||
$top_output = `top -b -n 1 | grep "^CPU" | sed 's/%//g' | awk '{print \$2, \$6, \$4, \$10}'`;
|
||||
} else {
|
||||
$top_output = `top -b -n 1 | grep -i "^%Cpu(s)" | awk '{print \$2, \$4, \$6, \$8}'`;
|
||||
}
|
||||
my ($user, $system, $nice, $idle) = split(/ /, $top_output);
|
||||
$user =~ s/[^\d\.]//g;
|
||||
$system =~ s/[^\d\.]//g;
|
||||
|
||||
Reference in New Issue
Block a user