summaryrefslogtreecommitdiff
path: root/cmd_loadavg.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-05-03 13:23:21 +0100
committerFreeArtMan <dos21h@gmail.com>2017-05-03 13:23:21 +0100
commit0a24537719de7cab1b4df46e7d6a22564f66ec6a (patch)
treed17f8215843fb4789bf8492ae633ec8cf4e00592 /cmd_loadavg.c
parentc6f5689838de263b8129b7c612cde030617ce780 (diff)
downloadagni-0a24537719de7cab1b4df46e7d6a22564f66ec6a.tar.gz
agni-0a24537719de7cab1b4df46e7d6a22564f66ec6a.zip
Added new commands RUSAGE,LOADAVG
Diffstat (limited to 'cmd_loadavg.c')
-rw-r--r--cmd_loadavg.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd_loadavg.c b/cmd_loadavg.c
new file mode 100644
index 0000000..a9a4b28
--- /dev/null
+++ b/cmd_loadavg.c
@@ -0,0 +1,28 @@
+#include "cmd_loadavg.h"
+
+void *cmd_loadavg(void *data)
+{
+ char *param = (char *)data;
+ char *ret = NULL;
+ int fret=-1;
+
+ const int buf_size = 128;
+ char buf[buf_size+1];
+
+ double loadavg_d[3];
+
+ printf("LOADAVG\n");
+
+ fret = getloadavg(loadavg_d, 3);
+ if (fret<0)
+ {
+ ret = alloc_new_str("Cant get load avg mate\n");
+ }
+
+ printf("1M %lf 5M %lf 15M %lf\n", loadavg_d[0], loadavg_d[1], loadavg_d[2]);
+ snprintf(buf, buf_size,"1M %.1f 5M %.1f 15M %.1f\n", loadavg_d[0], loadavg_d[1], loadavg_d[2]);
+
+ ret = alloc_new_str(buf);
+
+ return ret;
+} \ No newline at end of file