diff options
author | Fred Barclay <Fred-Barclay@users.noreply.github.com> | 2017-05-24 14:13:52 -0500 |
---|---|---|
committer | Fred Barclay <Fred-Barclay@users.noreply.github.com> | 2017-05-24 14:13:52 -0500 |
commit | 96c920e166b40bbe50f216e294f2efac154a1cb2 (patch) | |
tree | fa80a34e81863ab897f2f2b8ec4124b10d023516 /src/firemon/netstats.c | |
parent | remove trailing whitespace from etc/ (diff) | |
download | firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.tar.gz firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.tar.zst firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.zip |
Remove trailing whitespace from src/
Diffstat (limited to 'src/firemon/netstats.c')
-rw-r--r-- | src/firemon/netstats.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/firemon/netstats.c b/src/firemon/netstats.c index 8d78b094b..c5e8a242c 100644 --- a/src/firemon/netstats.c +++ b/src/firemon/netstats.c | |||
@@ -35,7 +35,7 @@ static char *get_header(void) { | |||
35 | if (asprintf(&rv, "%-5.5s %-9.9s %-10.10s %-10.10s %s", | 35 | if (asprintf(&rv, "%-5.5s %-9.9s %-10.10s %-10.10s %s", |
36 | "PID", "User", "RX(KB/s)", "TX(KB/s)", "Command") == -1) | 36 | "PID", "User", "RX(KB/s)", "TX(KB/s)", "Command") == -1) |
37 | errExit("asprintf"); | 37 | errExit("asprintf"); |
38 | 38 | ||
39 | return rv; | 39 | return rv; |
40 | } | 40 | } |
41 | 41 | ||
@@ -59,7 +59,7 @@ void get_stats(int parent) { | |||
59 | free(fname); | 59 | free(fname); |
60 | goto errexit; | 60 | goto errexit; |
61 | } | 61 | } |
62 | 62 | ||
63 | char buf[MAXBUF]; | 63 | char buf[MAXBUF]; |
64 | long long unsigned rx = 0; | 64 | long long unsigned rx = 0; |
65 | long long unsigned tx = 0; | 65 | long long unsigned tx = 0; |
@@ -68,19 +68,19 @@ void get_stats(int parent) { | |||
68 | continue; | 68 | continue; |
69 | if (strncmp(buf, " face", 5) == 0) | 69 | if (strncmp(buf, " face", 5) == 0) |
70 | continue; | 70 | continue; |
71 | 71 | ||
72 | char *ptr = buf; | 72 | char *ptr = buf; |
73 | while (*ptr != '\0' && *ptr != ':') { | 73 | while (*ptr != '\0' && *ptr != ':') { |
74 | ptr++; | 74 | ptr++; |
75 | } | 75 | } |
76 | 76 | ||
77 | if (*ptr == '\0') { | 77 | if (*ptr == '\0') { |
78 | fclose(fp); | 78 | fclose(fp); |
79 | free(fname); | 79 | free(fname); |
80 | goto errexit; | 80 | goto errexit; |
81 | } | 81 | } |
82 | ptr++; | 82 | ptr++; |
83 | 83 | ||
84 | long long unsigned rxval; | 84 | long long unsigned rxval; |
85 | long long unsigned txval; | 85 | long long unsigned txval; |
86 | unsigned a, b, c, d, e, f, g; | 86 | unsigned a, b, c, d, e, f, g; |
@@ -101,7 +101,7 @@ void get_stats(int parent) { | |||
101 | fclose(fp); | 101 | fclose(fp); |
102 | return; | 102 | return; |
103 | 103 | ||
104 | errexit: | 104 | errexit: |
105 | pids[parent].rx = 0; | 105 | pids[parent].rx = 0; |
106 | pids[parent].tx = 0; | 106 | pids[parent].tx = 0; |
107 | pids[parent].rx_delta = 0; | 107 | pids[parent].rx_delta = 0; |
@@ -121,7 +121,7 @@ static void print_proc(int index, int itv, int col) { | |||
121 | } | 121 | } |
122 | else | 122 | else |
123 | ptrcmd = cmd; | 123 | ptrcmd = cmd; |
124 | 124 | ||
125 | // check network namespace | 125 | // check network namespace |
126 | char *name; | 126 | char *name; |
127 | if (asprintf(&name, "/run/firejail/network/%d-netmap", index) == -1) | 127 | if (asprintf(&name, "/run/firejail/network/%d-netmap", index) == -1) |
@@ -145,35 +145,35 @@ static void print_proc(int index, int itv, int col) { | |||
145 | ptruser = user; | 145 | ptruser = user; |
146 | else | 146 | else |
147 | ptruser = ""; | 147 | ptruser = ""; |
148 | 148 | ||
149 | 149 | ||
150 | float rx_kbps = ((float) pids[index].rx_delta / 1000) / itv; | 150 | float rx_kbps = ((float) pids[index].rx_delta / 1000) / itv; |
151 | char ptrrx[15]; | 151 | char ptrrx[15]; |
152 | sprintf(ptrrx, "%.03f", rx_kbps); | 152 | sprintf(ptrrx, "%.03f", rx_kbps); |
153 | 153 | ||
154 | float tx_kbps = ((float) pids[index].tx_delta / 1000) / itv; | 154 | float tx_kbps = ((float) pids[index].tx_delta / 1000) / itv; |
155 | char ptrtx[15]; | 155 | char ptrtx[15]; |
156 | sprintf(ptrtx, "%.03f", tx_kbps); | 156 | sprintf(ptrtx, "%.03f", tx_kbps); |
157 | 157 | ||
158 | char buf[1024 + 1]; | 158 | char buf[1024 + 1]; |
159 | snprintf(buf, 1024, "%-5.5s %-9.9s %-10.10s %-10.10s %s", | 159 | snprintf(buf, 1024, "%-5.5s %-9.9s %-10.10s %-10.10s %s", |
160 | pidstr, ptruser, ptrrx, ptrtx, ptrcmd); | 160 | pidstr, ptruser, ptrrx, ptrtx, ptrcmd); |
161 | if (col < 1024) | 161 | if (col < 1024) |
162 | buf[col] = '\0'; | 162 | buf[col] = '\0'; |
163 | printf("%s\n", buf); | 163 | printf("%s\n", buf); |
164 | 164 | ||
165 | if (cmd) | 165 | if (cmd) |
166 | free(cmd); | 166 | free(cmd); |
167 | if (user) | 167 | if (user) |
168 | free(user); | 168 | free(user); |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | void netstats(void) { | 172 | void netstats(void) { |
173 | pid_read(0); // include all processes | 173 | pid_read(0); // include all processes |
174 | 174 | ||
175 | printf("Displaying network statistics only for sandboxes using a new network namespace.\n"); | 175 | printf("Displaying network statistics only for sandboxes using a new network namespace.\n"); |
176 | 176 | ||
177 | // print processes | 177 | // print processes |
178 | while (1) { | 178 | while (1) { |
179 | // set pid table | 179 | // set pid table |
@@ -186,10 +186,10 @@ void netstats(void) { | |||
186 | if (pids[i].level == 1) | 186 | if (pids[i].level == 1) |
187 | get_stats(i); | 187 | get_stats(i); |
188 | } | 188 | } |
189 | 189 | ||
190 | // wait 5 seconds | 190 | // wait 5 seconds |
191 | firemon_sleep(itv); | 191 | firemon_sleep(itv); |
192 | 192 | ||
193 | // grab screen size | 193 | // grab screen size |
194 | struct winsize sz; | 194 | struct winsize sz; |
195 | int row = 24; | 195 | int row = 24; |
@@ -198,7 +198,7 @@ void netstats(void) { | |||
198 | col = sz.ws_col; | 198 | col = sz.ws_col; |
199 | row = sz.ws_row; | 199 | row = sz.ws_row; |
200 | } | 200 | } |
201 | 201 | ||
202 | // start printing | 202 | // start printing |
203 | firemon_clrscr(); | 203 | firemon_clrscr(); |
204 | char *header = get_header(); | 204 | char *header = get_header(); |
@@ -221,4 +221,3 @@ void netstats(void) { | |||
221 | #endif | 221 | #endif |
222 | } | 222 | } |
223 | } | 223 | } |
224 | |||