From 0a24537719de7cab1b4df46e7d6a22564f66ec6a Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Wed, 3 May 2017 13:23:21 +0100 Subject: Added new commands RUSAGE,LOADAVG --- cmd_rusage.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cmd_rusage.c (limited to 'cmd_rusage.c') diff --git a/cmd_rusage.c b/cmd_rusage.c new file mode 100644 index 0000000..3dc5d21 --- /dev/null +++ b/cmd_rusage.c @@ -0,0 +1,34 @@ + +#include "cmd_rusage.h" + +void *cmd_rusage(void *data) +{ + char *ret = NULL; + int fret=-1; + + const int buf_size = 128; + char buf[buf_size+1]; + + struct rusage cur_proc_rusage; + + printf("RUSAGE\n"); + + fret = getrusage(RUSAGE_SELF, &cur_proc_rusage); + if (fret<0) + { + ret = alloc_new_str("Cant get rusage mate\n"); + } + + printf("USER %ld SYS %ld\n", + cur_proc_rusage.ru_utime.tv_sec, + cur_proc_rusage.ru_stime.tv_sec + ); + snprintf(buf, buf_size, "USER %ld SYS %ld\n", + cur_proc_rusage.ru_utime.tv_sec, + cur_proc_rusage.ru_stime.tv_sec + ); + + ret = alloc_new_str(buf); + + return ret; +} -- cgit v1.2.3