--- pfsense-utils.inc.submitted20032010 2010-03-22 18:44:16.000000000 +0700 +++ pfsense-utils.inc.new 2010-03-24 20:10:53.000000000 +0700 @@ -1181,7 +1181,7 @@ //returns interface information function get_interface_info($ifdescr) { - global $config, $linkinfo, $netstatrninfo; + global $config, $linkinfo, $netstatrninfo, $g; $ifinfo = array(); /* if list */ @@ -1299,15 +1299,30 @@ break; /* PPP interface? -> get uptime for this session and cumulative uptime from the persistant log file in conf */ case "ppp": - if ($config['interfaces'][$if]['serialport']){ + $ppp_int = $config['interfaces'][$if]['if']; $dev = $config['interfaces'][$if]['serialport']; + if ($dev == "") + break; if (file_exists("/dev/{$dev}")){ $ifinfo['ppplink'] = $dev; - if (file_exists("/var/run/{$dev}.sock") && file_exists("/var/run/{$dev}.if")){ - $ifinfo['ppp_uptime'] = trim(`/usr/sbin/pppctl /var/run/$dev.sock bg echo UPTIME`); - if (stristr($ifinfo['ppp_uptime'],">")) - $ifinfo['ppp_uptime'] = substr($ifinfo['ppp_uptime'], 2 + strpos($ifinfo['ppp_uptime'], ">")); + if (file_exists("{$g['varrun_path']}/{$ppp_int}.pid") && file_exists("{$g['varetc_path']}/{$ppp_int}.query")){ + $sec = trim(`/usr/bin/nc localhost 5005 < {$g['varetc_path']}/{$ppp_int}.query | grep 'Session time' | cut -f7 -d ' '`); + if ($sec != 0){ + $min = floor($sec/60); + $sec %= 60; + if ($sec < 10) + $sec = "0{$sec}"; + } + if ($min !=0){ + $hrs = floor($min/60); + $min %= 60; + if ($min < 10) + $min = "0{$min}"; + } + if ($hrs < 10) + $hrs = "0{$hrs}"; + $ifinfo['ppp_uptime'] = "{$hrs}:{$min}:{$sec}"; } $ifinfo['missing_device'] = 0; } @@ -1317,7 +1332,6 @@ } // Calculate cumulative uptime for PPP link. Useful for connections that have per minute/hour contracts so you don't go over! $ifinfo['ppp_uptime_accumulated'] = get_ppp_uptime($dev); - } break; default: