diff options
author | John Crispin <blogic@openwrt.org> | 2013-08-27 14:50:45 +0200 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2013-09-03 19:49:59 +0200 |
commit | 8555851160bcc5a04acfa8837af0977b82f7b500 (patch) | |
tree | 413cd74c26f7c49931331664a04cdd7778369623 /instance.c | |
parent | 392ad3ba793f44a343026d5d49f7b8dc1435a2b8 (diff) | |
download | unitd-8555851160bcc5a04acfa8837af0977b82f7b500.tar unitd-8555851160bcc5a04acfa8837af0977b82f7b500.zip |
add suport for measuring process resource usage
Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'instance.c')
-rw-r--r-- | instance.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -422,6 +422,7 @@ instance_init(struct service_instance *in, struct service *s, struct blob_attr * void instance_dump(struct blob_buf *b, struct service_instance *in, int verbose) { void *i; + struct pid_info pi; i = blobmsg_open_table(b, in->name); blobmsg_add_u8(b, "running", in->proc.pending); @@ -430,5 +431,18 @@ void instance_dump(struct blob_buf *b, struct service_instance *in, int verbose) blobmsg_add_blob(b, in->command); if (verbose && in->trigger) blobmsg_add_blob(b, in->trigger); + if (!measure_process(in->proc.pid, &pi)) { + struct timespec tp; + long uptime; + + clock_gettime(CLOCK_MONOTONIC, &tp); + uptime = tp.tv_sec - in->start.tv_sec; + + blobmsg_add_u8(b, "ppid", pi.ppid); + blobmsg_add_u16(b, "uid", pi.uid); + blobmsg_add_u32(b, "fdcount", pi.fdcount); + blobmsg_add_u32(b, "vmsize", pi.vmsize); + blobmsg_add_u32(b, "uptime", uptime); + } blobmsg_close_table(b, i); } |