How difficult would it be to add an option to the real time screen as a drop down under display options(carrier stats, agent time, etc) to have the server status(+time) shown in real time that updates as the stats do?
Nox
Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N
+----------------+------------------------+-----------+----------+---------+
4 agents logged in on all servers
System Load Average: 0.38 0.27 0.14 M
{
$UD_bad_grab=0;
if ( ( ($endless_loop =~ /0$/) && ($SYSPERF) ) || ($endless_loop =~ /00$/) || ($gather_stats_first >= 1) )
{
$cpuUSERcent=0; $cpuSYSTcent=0; $cpuIDLEcent=0;
### get processor usage seconds ###
# cpu 924841 211725 270473 6961811
@cpuUSE = `$bincat /proc/stat`;
if ($cpuUSE[0] =~ /cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/)
{
$cpuUSER = ($1 + $2);
$cpuSYST = $3;
$cpuIDLE = $4;
$cpuUSERdiff = ($cpuUSER - $cpuUSERprev);
$cpuSYSTdiff = ($cpuSYST - $cpuSYSTprev);
$cpuIDLEdiff = ($cpuIDLE - $cpuIDLEprev);
$cpuIDLEdiffTOTAL = (($cpuUSERdiff + $cpuSYSTdiff) + $cpuIDLEdiff);
if ($cpuIDLEdiffTOTAL > 0)
{
$cpuUSERcent = sprintf("%.0f", (($cpuUSERdiff / $cpuIDLEdiffTOTAL) * 100));
$cpuSYSTcent = sprintf("%.0f", (($cpuSYSTdiff / $cpuIDLEdiffTOTAL) * 100));
$cpuIDLEcent = sprintf("%.0f", (($cpuIDLEdiff / $cpuIDLEdiffTOTAL) * 100));
}
$cpuUSERprev=$cpuUSER;
$cpuSYSTprev=$cpuSYST;
$cpuIDLEprev=$cpuIDLE;
}
### get system load ###
$serverLOAD = `$bincat /proc/loadavg`;
$serverLOAD =~ s/ .*//gi;
$serverLOAD =~ s/\D//gi;
### get memory usage ###
@GRABserverMEMORY = `$binfree -m -t`;
if ($GRABserverMEMORY[1] =~ /Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+/)
{
$MEMused = $2;
$MEMfree = $3;
}
### get number of system processes ###
@GRABserverPROCESSES = `$binps -A --no-heading`;
$serverPROCESSES = $#GRABserverPROCESSES;
if ($SYSPERF_rec) {$recording_count = ($test_local_count / 2)}
else {$recording_count=0;}
if ($SYSPERF)
{
if ($SYSPERFDB)
{print "$serverLOAD $MEMfree $MEMused $serverPROCESSES $#list_channels $cpuUSERcent $cpuSYSTcent $cpuIDLEcent\n";}
$stmtA = "INSERT INTO server_performance (start_time,server_ip,sysload,freeram,usedram,processes,channels_total,trunks_total,clients_total,clients_zap,clients_iax,clients_local,clients_sip,live_recordings,cpu_user_percent,cpu_system_percent,cpu_idle_percent) values('$now_date','$server_ip','$serverLOAD','$MEMfree','$MEMused','$serverPROCESSES','$#list_channels','$channel_counter','$sip_counter','$test_zap_count','$test_iax_count','$test_local_count','$test_sip_count','$recording_count','$cpuUSERcent','$cpuSYSTcent','$cpuIDLEcent')";
if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n";
}
if ( ($endless_loop =~ /00$/) || ($gather_stats_first >= 1) )
{
### get disk space usage ###
$disk_usage='';
@serverDISK = `$dfbin -B 1048576`;
#Filesystem 1M-blocks Used Available Use% Mounted on
#/dev/sda1 30030 6867 21613 0% /
$gather_stats_first=0;
$channels_total=0;
if ($#list_channels > 0)
{$channels_total = ($#list_channels - 1);}
$ct=0; $ct_PCT=0;
foreach(@serverDISK)
{
if ($serverDISK[$ct] =~ /(\d+\%)/)
{
$ct_PCT++;
$usage = $1;
$usage =~ s/\%//gi;
$disk_usage .= "$ct_PCT $usage|";
}
$ct++;
}
$stmtA = "UPDATE servers SET sysload='$serverLOAD',channels_total='$channels_total',cpu_idle_percent='$cpuIDLEcent',disk_usage='$disk_usage' where server_ip='$server_ip';";
if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n";
}
}
}
Users browsing this forum: No registered users and 57 guests