ezservermonitor-web/libs/last_login.php
ShevAbam 3ed4c1d633 CPU : changes on retrieving CPU information
Load Average and CPU : fix on recovery the number of CPU cores
Last login : the datas are retrieved differently
2015-01-16 18:14:07 +01:00

30 lines
575 B
PHP

<?php
require 'Utils/Config.class.php';
$Config = new Config();
$datas = array();
if (!(exec('/usr/bin/lastlog --time 365 | /usr/bin/awk -F\' \' \'{ print $1";"$5, $4, $8, $6}\'', $users)))
{
$datas[] = array(
'user' => 'N.A',
'date' => 'N.A',
);
}
else
{
$max = $Config->get('last_login:max');
for ($i = 1; $i < count($users) && $i <= $max; $i++)
{
list($user, $date) = explode(';', $users[$i]);
$datas[] = array(
'user' => $user,
'date' => $date,
);
}
}
echo json_encode($datas);