summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2017-01-19 01:09:04 +0200
committerTobias Klauser <tklauser@distanz.ch>2017-01-25 13:23:38 +0100
commit1df0f481922acfb5f7af0f3a5cb800ec0f77e48f (patch)
tree6386a0c66c673a43bef386d58203712da0e27ef3 /proc.c
parent60648a858b83b63e8dbdd1c45bb901d1206ae444 (diff)
flowtop: Add process UI tab entry
Add process UI tab entry to show flows statistics per pid. Also changed flow_entry which now has pointer to new struct proc_entry object which contains process related info. On each 1 second refresh proc_entry is checked if it exists by checking /proc/<pid> path, and is deleted if there is no any flows related to it (flows_count is 0), if the process exists then dst & src rates info is zeroed and summed from the all related flows which are in the proc_entry->flows list. The bytes & pkts amount info is collected during all the time process exists. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/proc.c b/proc.c
index c25396a..a0e6499 100644
--- a/proc.c
+++ b/proc.c
@@ -183,3 +183,14 @@ int proc_exec(const char *proc, char *const argv[])
return 0;
}
+
+bool proc_exists(pid_t pid)
+{
+ struct stat statbuf;
+ char path[1024];
+
+ if (snprintf(path, sizeof(path), "/proc/%u", pid) < 0)
+ return false;
+
+ return stat(path, &statbuf) == 0;
+}