summaryrefslogtreecommitdiff
path: root/libs/load_average.php
diff options
context:
space:
mode:
authorShevAbam <shevabam@gmail.com>2014-06-18 10:11:11 +0200
committerShevAbam <shevabam@gmail.com>2014-06-18 10:11:11 +0200
commit20705a550df5b13a544dc0865c6aef16e64c99d9 (patch)
treee396dface41e30d39a68d5fe66097b1f8f641a81 /libs/load_average.php
+ First commit (version 2.0)v2.0
Diffstat (limited to 'libs/load_average.php')
-rw-r--r--libs/load_average.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/load_average.php b/libs/load_average.php
new file mode 100644
index 0000000..8eea8f9
--- /dev/null
+++ b/libs/load_average.php
@@ -0,0 +1,25 @@
+<?php
+
+if (!($load_tmp = shell_exec('/bin/cat /proc/loadavg | /usr/bin/awk \'{print $1","$2","$3}\'')))
+{
+ $load = array(0, 0, 0);
+}
+else
+{
+ $load_exp = explode(',', $load_tmp);
+
+ $load = array_map(
+ function ($value) {
+ $v = (int)($value * 100);
+ if ($v > 100)
+ $v = 100;
+ return $v;
+ },
+ $load_exp
+ );
+}
+
+
+$datas = $load;
+
+echo json_encode($datas); \ No newline at end of file