Add CpuUserPercent and CpuSystemPercent to ServerStats
parent
fa9a0e45b7
commit
e08ec34e51
|
@ -59,8 +59,15 @@ while (!$zm_terminate) {
|
|||
'Running', $cpuload[0], &totalmem, &freemem, &totalswap, &freeswap, $Config{ZM_SERVER_ID} ) ) {
|
||||
Error("Failed Updating status of Server record for Id=$Config{ZM_SERVER_ID} :".$dbh->errstr());
|
||||
}
|
||||
if ( ! defined $dbh->do('INSERT INTO Server_Stats (ServerId, TimeStamp, CpuLoad, TotalMem, FreeMem, TotalSwap, FreeSwap) VALUES (?,NOW(),?,?,?,?,?)', undef,
|
||||
$Config{ZM_SERVER_ID}, $cpuload[0], &totalmem, &freemem, &totalswap, &freeswap, $Config{ZM_SERVER_ID} ) ) {
|
||||
|
||||
|
||||
# Get CPU utilization percentages
|
||||
my ($user_utilization, $system_utilization) = split(/ /, `top -b -n 1 | grep "Cpu(s)" | awk '{print \$2, \$4}'`);
|
||||
|
||||
if ( ! defined $dbh->do('INSERT INTO Server_Stats (ServerId, TimeStamp, CpuLoad, CpuUserPercent, CpuSystemPercent, TotalMem, FreeMem, TotalSwap, FreeSwap) VALUES (?,NOW(),?,?,?,?,?,?,?)', undef,
|
||||
$Config{ZM_SERVER_ID},
|
||||
$cpuload[0], $user_utilization, $system_utilization,
|
||||
&totalmem, &freemem, &totalswap, &freeswap, ) ) {
|
||||
Error("Failed Inserting status of Server record for Id=$Config{ZM_SERVER_ID} :".$dbh->errstr());
|
||||
}
|
||||
my $rows = zmDbDo('DELETE FROM `Server_Stats` WHERE `TimeStamp` < now() - interval 1 DAY LIMIT 100');
|
||||
|
|
Loading…
Reference in New Issue