mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-12-06 01:38:19 +01:00
Uptime in BSD..
This commit is contained in:
1 parent
41d6ba04c5
commit
a0ae0df455
1 file changed
+10
-1
+10
-1
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user