diff --git a/cron/servers.php b/cron/servers.php index ca767cd..7a88d90 100644 --- a/cron/servers.php +++ b/cron/servers.php @@ -244,7 +244,16 @@ function cron_uptime($db_conn,$time,$pc){ $datetime = date_create_from_format ('YmdHis', (int)$resu ); $timestamp = date_timestamp_get ($datetime); $uptime = time() - $timestamp; - }else{ //Systemd and init goes same way + }else if ($pc['SO'] == "BSD"){ + $line = commandbyssh($pc['IP'],$pc['SSHPort'],$pc['User'],$pc['Password'],'uptime'); + $line = trim($line); + $line = preg_replace("/[[:blank:]]+/",' ',$line); + $part = explode(' ',$line); + //Example: 6:07PM up 2 days, 20:30, 1 user, load averages: 0.20, 0.16, 0.15. + $exphour = explode(':',$part[4]); + $uptime = $line[2]*86400 + $exphour[0]*3600 + $exphour[1] * 60; + + }else{ //Linux is standard reading /proc/uptime $uptime = explode('.',commandbyssh($pc['IP'],$pc['SSHPort'],$pc['User'],$pc['Password'],'cat /proc/uptime'))[0]; if (DEBUG) echo $uptime;