catalinux / pwatch (public) (License: GPLv3) (since 2016-03-01) (hash sha1)
Set of tools to analyze what a process is doing. 'io' command is used to see who is doing I/O.
List of commits:
Subject Hash Author Date (UTC)
Displayed the sorted column's header using a different color. ab2fd95c996dc6999ccbdd30ade6c69b0933f42b Cosmin HUMENIUC 2008-07-17 11:36:24
Used the same background color for the entire line 3671a14bc85ca65577612e996efbce52ce71c055 Cosmin HUMENIUC 2008-07-16 08:25:17
More TODOs added. 05ed8b0a18505898f7ba503a60644c29e1762e6c Catalin(ux) M. BOIE 2010-09-30 20:15:20
Duilder updates. 0af0ec7f6dcf2447485f9111c67eebadbbb48503 Catalin(ux) M. BOIE 2010-09-30 20:14:58
Close dir after open and in error paths! 6aa78463f5e69e4dfc8b1893106de188746b8b3d Catalin(ux) M. BOIE 2010-09-30 20:13:59
Cosmetic changes to .mailmap. c11badfe7864b7fb8e24bcf49dcedf18357c8d9a Catalin(ux) M. BOIE 2009-10-12 11:06:48
Store offset and size as 64 bits instead of 32 bits. 1be11bbad878383067f23c2c52f0dfc65ad3346f Catalin(ux) M. BOIE 2009-10-12 09:50:05
More aliases added. aa903e5d9992373ec5a4ad84a773b648913dd858 Catalin(ux) M. BOIE 2008-05-23 14:12:02
Bump up version. e88e4bab0f01b83e595154a65f21dc8c3f1f931d Catalin(ux) M. BOIE 2008-05-23 14:11:32
More duilder updates. cdda5cfe213b1e69283a6d2cb7681d23f8118f28 Catalin(ux) M. BOIE 2008-05-23 13:53:37
rpmbuild will complain if .spec file is not present, so do not remove it. 5a661c911396e31277c0caf2211aaf36f6d8bff6 Catalin(ux) M. BOIE 2008-05-23 13:44:35
Makefile should not be cleaned. 0fe4b1c00106217d1e630c763f8047689ded5eb2 Catalin(ux) M. BOIE 2008-05-23 13:39:38
Clean also Makefile and spec file. 7a4a0e837082df352272e6b7f225fc29eacdb418 Catalin(ux) M. BOIE 2008-05-23 13:27:10
Update duilder. 507ef1fd8bd6f9f49f88f4e8b5a76493b3366a45 Catalin(ux) M. BOIE 2008-05-23 13:25:01
More signed/unsigned fixes. f1eebdc469411366b7feea1ede9c6b09faef26ad Catalin(ux) M. BOIE 2008-05-23 13:22:07
Added file for e-mail mapping. 4a3f1fc114c3b0ac1ad5cadb0f6c2e21ef0342a0 Catalin(ux) M. BOIE 2008-05-23 13:17:45
Fixed signed/unsigned comparations. d2f4ec58a496a2b2bd9fa1d9e2c7b3018e86a843 Catalin(ux) M. BOIE 2008-05-23 13:09:40
Bump up version to 0.0.2. 9c4880a7e9667b9778796762ae062c8c92128b49 Catalin(ux) M. BOIE 2008-05-23 13:08:57
Replaced racy /proc IO statistics with netlink ones. 8efe54ca3a337a8a3a8e616ae9a07b10f09dd2d3 Catalin(ux) M. BOIE 2008-05-23 12:56:17
Because duilder has support to submit a package for compile, use it. c479890bdb1cadf233038c566543676c156f24ff Catalin(ux) M. BOIE 2008-05-23 12:53:33
Commit ab2fd95c996dc6999ccbdd30ade6c69b0933f42b - Displayed the sorted column's header using a different color.
Signed-off-by: Cosmin HUMENIUC <cosmin@mandrivausers.ro>
Signed-off-by: Catalin(ux) M. BOIE <catab@embedromix.ro>
Author: Cosmin HUMENIUC
Author date (UTC): 2008-07-17 11:36
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2010-10-30 21:10
Parent(s): 3671a14bc85ca65577612e996efbce52ce71c055
Signing key:
Tree: bb313f63b2922b52d46bcc3a19dcf5e58c9d0cc4
File Lines added Lines deleted
TODO 1 1
src/io.c 139 15
File TODO changed (mode: 100644) (index e9a99a8..d49c69b)
1 1 [ ] Take care of wrap-around. [ ] Take care of wrap-around.
2 2 [ ] Compute totals! [ ] Compute totals!
3 [ ] Instead of showing "Sort by: read bytes", just color "rbytes" differently.
4 3 [ ] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=9b0975a20af1ff2f367e3b6b7c150eb114c6b500 [ ] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=9b0975a20af1ff2f367e3b6b7c150eb114c6b500
5 4 [ ] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=297c5d92634c809cef23d73e7b2556f2528ff7e2 [ ] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=297c5d92634c809cef23d73e7b2556f2528ff7e2
6 5 [ ] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=016ae219b920c4e606088761d3d6070cdf8ba706 [ ] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=016ae219b920c4e606088761d3d6070cdf8ba706
6 [ ] Display a different status bar for process details.
File src/io.c changed (mode: 100644) (index 1e511bc..ee5f20c)
... ... enum {
27 27 VIEW_PROCESS VIEW_PROCESS
28 28 }; };
29 29
30 typedef enum {
31 UNSORTED = 0,
32 ASCENDING = 1,
33 DESCENDING = -1
34 } sort_t;
35
36 struct column {
37 /** The column's caption */
38 const char* name;
39 /** Format string for column content*/
40 const char* format;
41 /** Width of the column, in characters. 0 = auto, -1 = hidden */
42 int width;
43 /** Column's sorting order */
44 sort_t sorted;
45 };
46
47 static struct column columns[] =
48 {
49 { "PID", "%7ld", 7, UNSORTED},
50 { "rbytes", "%7s", 7, UNSORTED},
51 { "wbytes", "%7s", 7, UNSORTED},
52 { "rspeed", "%7s", 7, DESCENDING},
53 { "wspeed", "%7s", 7, UNSORTED},
54 { "Process", " %s", 0, UNSORTED}
55 };
56
57 static const int column_count = 6;
30 58
31 59 /* Variables */ /* Variables */
32 60 static int max_line_len; static int max_line_len;
 
... ... static int cells = 0;
36 64 static int selected_line = 0, last_line = 0, useful_lines = 0; static int selected_line = 0, last_line = 0, useful_lines = 0;
37 65 static int max_pages = 1, page = 0; static int max_pages = 1, page = 0;
38 66 static pid_t selected_pid = 0; static pid_t selected_pid = 0;
67 unsigned int inverse = 0;
39 68
40 69
41 70 /* Functions */ /* Functions */
 
... ... static void iotop_show_help(void)
133 162 nodelay(stdscr, TRUE); nodelay(stdscr, TRUE);
134 163 } }
135 164
165 /**
166 * Sort by a column.
167 * \param column_index the column to sort by
168 */
169 static void iotop_sort_by_column(int column_index)
170 {
171 int index;
172
173 for(index = 0; index < column_count; index++) {
174 columns[index].sorted = UNSORTED;
175 }
176 if(inverse == 0) {
177 columns[column_index].sorted = DESCENDING;
178 } else {
179 columns[column_index].sorted = ASCENDING;
180 }
181 }
182
183 /**
184 * Reverse sort order.
185 */
186 static void iotop_sort_reverse(void)
187 {
188 int index;
189
190 for(index = 0; index < column_count; index++) {
191 /* ASCENDING <--> DESCENDING */
192 columns[index].sorted *= (-1);
193 }
194 }
195
196 /**
197 * Print the header for the cells view.
198 */
199 static void iotop_show_cells_header(void)
200 {
201 int index;
202 char caption[128];
203 char caption_format[8];
204 int len; /* the visible length of a column caption */
205 int pos;
206
207 /* Background */
208 attron(COLOR_PAIR(3));
209 iotop_full_line(1, "");
210
211 pos = 0;
212 for(index = 0; index < column_count; index++) {
213 int w = columns[index].width;
214 switch(w) {
215 case 0: /* auto */
216 sprintf(caption_format, " %%s");
217 len = 128;
218 break;
219 case -1: /* hidden */
220 /* do not write anything */
221 len = 0;
222 break;
223 default:
224 sprintf(caption_format, "%%%ds", w);
225 len = w;
226 }
227 snprintf(caption, len + 1, caption_format, columns[index].name);
228 switch(columns[index].sorted) {
229 case DESCENDING:
230 attron(COLOR_PAIR(5));
231 break;
232 case ASCENDING:
233 attron(COLOR_PAIR(6));
234 break;
235 case UNSORTED:
236 default:
237 attron(COLOR_PAIR(3));
238 }
239 mvaddstr(1, pos, caption);
240 pos += len;
241 }
242 }
243
136 244 /* /*
137 245 * Picture the entries * Picture the entries
138 246 */ */
 
... ... static void iotop_show_cells(const unsigned int page,
145 253 int line, skip, max; int line, skip, max;
146 254 char rb[16], wb[16]; char rb[16], wb[16];
147 255 char rs[16], ws[16]; char rs[16], ws[16];
256 char format[256];
257 int index;
148 258
149 259 buf_len = sizeof(buf); buf_len = sizeof(buf);
150 260
 
... ... static void iotop_show_cells(const unsigned int page,
170 280 pwatch_nice_output(rs, sizeof(rs), p->speed_read); pwatch_nice_output(rs, sizeof(rs), p->speed_read);
171 281 pwatch_nice_output(ws, sizeof(ws), p->speed_write); pwatch_nice_output(ws, sizeof(ws), p->speed_write);
172 282
173 snprintf(buf, max, "%7ld"
174 "%7s"
175 "%7s"
176 "%7s"
177 "%7s"
178 " %s",
283 strcpy(format, "");
284 for(index = 0; index < column_count; index++) {
285 strcat(format, columns[index].format);
286 }
287 snprintf(buf, max, format,
179 288 (long int) p->pid, (long int) p->pid,
180 289 rb, wb, rs, ws, p->name); rb, wb, rs, ws, p->name);
181 290
 
... ... static void iotop_recompute_screen(void)
316 425 int main(int argc, char *argv[]) int main(int argc, char *argv[])
317 426 { {
318 427 int ch; int ch;
319 unsigned int sort_by = SORT_BY_SPEED_READ, inverse = 0;
428 unsigned int sort_by = SORT_BY_SPEED_READ;
320 429 unsigned int re_sort = 0, force_sort; unsigned int re_sort = 0, force_sort;
321 430 char s_sort[256]; char s_sort[256];
322 431 char status[256]; char status[256];
 
... ... int main(int argc, char *argv[])
362 471 init_pair(2, COLOR_WHITE, COLOR_BLACK); init_pair(2, COLOR_WHITE, COLOR_BLACK);
363 472 init_pair(3, COLOR_WHITE, COLOR_RED); init_pair(3, COLOR_WHITE, COLOR_RED);
364 473 init_pair(4, COLOR_RED, COLOR_WHITE); init_pair(4, COLOR_RED, COLOR_WHITE);
474 init_pair(5, COLOR_WHITE, COLOR_BLUE);
475 init_pair(6, COLOR_BLACK, COLOR_CYAN);
365 476
366 477 iotop_warning(); iotop_warning();
367 478
 
... ... int main(int argc, char *argv[])
474 585 re_sort = 0; re_sort = 0;
475 586
476 587 switch (ch) { switch (ch) {
477 case '0': inverse = 1 - inverse; break;
478 case '1': sort_by = SORT_BY_BYTES_READ; break;
479 case '2': sort_by = SORT_BY_BYTES_WRITE; break;
480 case '3': sort_by = SORT_BY_SPEED_READ; break;
481 case '4': sort_by = SORT_BY_SPEED_WRITE; break;
588 case '0':
589 inverse = 1 - inverse;
590 iotop_sort_reverse();
591 break;
592 case '1':
593 sort_by = SORT_BY_BYTES_READ;
594 iotop_sort_by_column(1);
595 break;
596 case '2':
597 sort_by = SORT_BY_BYTES_WRITE;
598 iotop_sort_by_column(2);
599 break;
600 case '3':
601 sort_by = SORT_BY_SPEED_READ;
602 iotop_sort_by_column(3);
603 break;
604 case '4':
605 sort_by = SORT_BY_SPEED_WRITE;
606 iotop_sort_by_column(4);
607 break;
482 608 } }
483 609
484 610 snprintf(s_sort, sizeof(s_sort), "[Sort by: %s]", snprintf(s_sort, sizeof(s_sort), "[Sort by: %s]",
 
... ... int main(int argc, char *argv[])
518 644 /* line 2 header and body */ /* line 2 header and body */
519 645 attron(COLOR_PAIR(3)); attron(COLOR_PAIR(3));
520 646 if (view == VIEW_NORMAL) { if (view == VIEW_NORMAL) {
521 snprintf(status, max_line_len,
522 " PID rbytes wbytes rspeed wspeed Process");
523 iotop_full_line(1, status);
647 iotop_show_cells_header();
524 648 iotop_show_cells(page, cells); iotop_show_cells(page, cells);
525 649 } else if (view == VIEW_PROCESS) { } else if (view == VIEW_PROCESS) {
526 650 snprintf(status, max_line_len, snprintf(status, max_line_len,
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/pwatch

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/pwatch

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/pwatch

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main