Merge pull request #654 from lifeofguenter/patch_php_replace_exec_with_native

replace getLoad() / getDiskPercent() with PHP native functions
pull/660/head
Kyle Johnson 2015-01-03 14:39:25 -05:00
commit db5f5a61ad
1 changed files with 4 additions and 9 deletions

View File

@ -1611,19 +1611,14 @@ function sortTag( $field )
function getLoad() function getLoad()
{ {
$uptime = shell_exec( 'uptime' ); $load = sys_getloadavg();
$load = ''; return( $load[0] );
if ( preg_match( '/load average: ([\d.]+)/', $uptime, $matches ) )
$load = $matches[1];
return( $load );
} }
function getDiskPercent() function getDiskPercent()
{ {
$df = shell_exec( 'df '.ZM_DIR_EVENTS ); $total = disk_total_space(ZM_DIR_EVENTS);
$space = -1; $space = round(($total - disk_free_space(ZM_DIR_EVENTS)) / $total * 100);
if ( preg_match( '/\s(\d+)%/ms', $df, $matches ) )
$space = $matches[1];
return( $space ); return( $space );
} }