summaryrefslogtreecommitdiff
path: root/libs/system.php
diff options
context:
space:
mode:
Diffstat (limited to 'libs/system.php')
-rw-r--r--libs/system.php24
1 files changed, 16 insertions, 8 deletions
diff --git a/libs/system.php b/libs/system.php
index 702ef3b..17ed5a4 100644
--- a/libs/system.php
+++ b/libs/system.php
@@ -1,6 +1,5 @@
<?php
require '../autoload.php';
-date_default_timezone_set(@date_default_timezone_get());
// Hostname
$hostname = php_uname('n');
@@ -8,14 +7,11 @@ $hostname = php_uname('n');
// OS
if (!($os = shell_exec('/usr/bin/lsb_release -ds | cut -d= -f2 | tr -d \'"\'')))
{
- if (!($os = shell_exec('cat /etc/system-release | cut -d= -f2 | tr -d \'"\'')))
+ if(!($os = shell_exec('cat /etc/system-release | cut -d= -f2 | tr -d \'"\'')))
{
- if (!($os = shell_exec('cat /etc/os-release | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
+ if (!($os = shell_exec('find /etc/*-release -type f -exec cat {} \; | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
{
- if (!($os = shell_exec('find /etc/*-release -type f -exec cat {} \; | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
- {
- $os = 'N.A';
- }
+ $os = 'N.A';
}
}
}
@@ -61,6 +57,17 @@ if (!($server_date = shell_exec('/bin/date')))
$server_date = date('Y-m-d H:i:s');
}
+// Load average
+if (!($load_tmp = shell_exec('cat /proc/loadavg | awk \'{print $1","$2","$3}\'')))
+{
+ $load_array = array(0, 0, 0);
+}
+else
+{
+ $load_array = explode(',', $load_tmp);
+}
+
+$load_avg = implode(", ", $load_array);
$datas = array(
'hostname' => $hostname,
@@ -70,6 +77,7 @@ $datas = array(
'last_boot' => $last_boot,
'current_users' => $current_users,
'server_date' => $server_date,
+ 'load_avg' => $load_avg,
);
-echo json_encode($datas); \ No newline at end of file
+echo json_encode($datas);