Merge pull request #787 from phil-davis/master

Provide get_uptime_sec in a common include file
This commit is contained in:
Renato Botelho 2013-08-31 07:31:04 -07:00
commit f89f3b3d21
2 changed files with 15 additions and 8 deletions

View File

@ -1445,6 +1445,19 @@ function get_cpu_speed() {
return exec("sysctl hw.clockrate | awk '{ print $2 }'");
}
function get_uptime_sec() {
$boottime = "";
$matches = "";
exec("/sbin/sysctl -n kern.boottime", $boottime);
preg_match("/sec = (\d+)/", $boottime[0], $matches);
$boottime = $matches[1];
if(intval($boottime) == 0)
return 0;
$uptime = time() - $boottime;
return $uptime;
}
function add_hostname_to_watch($hostname) {
if(!is_dir("/var/db/dnscache")) {
mkdir("/var/db/dnscache");

View File

@ -8,6 +8,7 @@ if(Connection_Aborted()) {
}
require_once("config.inc");
require_once("pfsense-utils.inc");
function get_stats() {
$stats['cpu'] = cpu_usage();
@ -77,15 +78,8 @@ function get_gatewaystats() {
}
function get_uptime() {
$boottime = "";
$matches = "";
exec("/sbin/sysctl -n kern.boottime", $boottime);
preg_match("/sec = (\d+)/", $boottime[0], $matches);
$boottime = $matches[1];
$uptime = time() - $boottime;
$uptime = get_uptime_sec();
if(intval($boottime) == 0)
return;
if(intval($uptime) == 0)
return;