From a0ae0df45512d5da7fe253b418d33cc3d3d61611 Mon Sep 17 00:00:00 2001 From: Kevin Puertas Date: Sat, 17 Oct 2020 18:13:21 +0200 Subject: [PATCH] Uptime in BSD.. --- cron/servers.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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;