diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2017-01-19 01:09:04 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-01-25 13:23:38 +0100 |
commit | 1df0f481922acfb5f7af0f3a5cb800ec0f77e48f (patch) | |
tree | 6386a0c66c673a43bef386d58203712da0e27ef3 /proc.c | |
parent | 60648a858b83b63e8dbdd1c45bb901d1206ae444 (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.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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; +} |