diff options
author | FreeArtMan <dos21h@gmail.com> | 2017-05-03 13:23:21 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2017-05-03 13:23:21 +0100 |
commit | 0a24537719de7cab1b4df46e7d6a22564f66ec6a (patch) | |
tree | d17f8215843fb4789bf8492ae633ec8cf4e00592 /cmd_rusage.c | |
parent | c6f5689838de263b8129b7c612cde030617ce780 (diff) | |
download | agni-0a24537719de7cab1b4df46e7d6a22564f66ec6a.tar.gz agni-0a24537719de7cab1b4df46e7d6a22564f66ec6a.zip |
Added new commands RUSAGE,LOADAVG
Diffstat (limited to 'cmd_rusage.c')
-rw-r--r-- | cmd_rusage.c | 34 |
1 files changed, 34 insertions, 0 deletions
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; +} |