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)
Fixed positioning at the end of list. bfedb7fbce206af12cf5cd03ddf88f670982ea1f Catalin(ux) M. BOIE 2008-01-08 22:44:20
Because name iotop is already taken, renamed iotop to io. a4fc9285d5b4079c98e63363859781451e38d076 Catalin(ux) M. BOIE 2008-01-08 22:43:36
Impoved a little the description from spec file. d367b069e3f51be7e159758fc8d9e9a0ef8078bb Catalin(ux) M. BOIE 2007-10-30 09:55:24
Added homepage to README file. e0976ec7f6decd8bcf7c4cff3bb36fc16702332a Catalin(ux) M. BOIE 2007-10-30 09:54:25
Warn if user has a not enough recent kernel and refuse to work. 3687f3965abc6aa66bbde34a7fd53795874aaa69 Catalin(ux) M. BOIE 2007-10-30 09:52:32
No need to have Changelog in git. 2b04dcd1a0a428722ae2ec490eb0ccab93a74e75 Catalin(ux) M. BOIE 2007-10-24 09:33:42
Added GIT_COMMIT stuff. e724fe6003c3e7d30f5d9f78a9ff8ae4fc958fc4 Catalin(ux) M. BOIE 2007-10-24 09:29:43
duilder should be in git repository. eb90b4b59cb3ab9dfb2d5fe3f06561110f2bca98 Catalin(ux) M. BOIE 2007-10-24 08:48:45
Added more info. b91dc05444309ef93aa3c5dc2890fbe4bcbaf82d Catalin(ux) M. BOIE 2007-10-24 08:48:27
Removed duilder from .gitignore. fb32de1325e3719c8214ac3dd4be099a66a2d36f Catalin(ux) M. BOIE 2007-10-24 08:47:33
Switch to new duilder variables. 2ad644f672ced83758a19dda33b8f23abbf60cc5 Catalin(ux) M. BOIE 2007-10-23 02:51:46
Added a new screenshot. 3cc31df36f6a78e2d17b727f9f272f9dec9f32f5 Catalin(ux) M. BOIE 2007-10-23 02:12:56
Remove link to pi. Will come back later. b98ac41d7695e2f497c69dba49ea21e3a86cf66a Catalin(ux) M. BOIE 2007-10-22 09:58:55
Exclude some auto generated files. 64b475e4b06788fb481538cf3b4d6a4c4bcedb4c Catalin(ux) M. BOIE 2007-10-22 08:59:38
Removed some leftovers. f373c6bf966de7d7318b93e75414cdadfd6e8603 Catalin(ux) M. BOIE 2007-10-22 08:56:59
Correct instalation stuff. 9caf660f3d5104028cbab81de17cf23cb3203c24 Catalin(ux) M. BOIE 2007-10-22 08:56:40
Added duilder conf file. 9db23c7c2c165d448027a818266116e313194d4c Catalin(ux) M. BOIE 2007-10-22 08:56:08
Some basic corrections. 81113acb04179336164c68c384449c1a88c4e5e1 Catalin(ux) M. BOIE 2007-10-22 08:55:31
Quiet make commands. e49c4c156f9054cad6a3c28aa77cb70da404b538 Catalin(ux) M. BOIE 2007-10-22 08:54:35
Real switch to duilder build system. 13da5d88af6419a70442c0735c4ea26b25deee21 Catalin(ux) M. BOIE 2007-10-22 08:44:00
Commit bfedb7fbce206af12cf5cd03ddf88f670982ea1f - Fixed positioning at the end of list.
Before fix, if you were positioned at the end of the list and more than one page
of processes exit, you are left on a blank screen.
Author: Catalin(ux) M. BOIE
Author date (UTC): 2008-01-08 22:44
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2008-01-08 22:44
Parent(s): a4fc9285d5b4079c98e63363859781451e38d076
Signer:
Signing key:
Signing status: N
Tree: 405e9ab1491c72c43f53eab46dd93529d5f54b51
File Lines added Lines deleted
src/io.c 49 36
File src/io.c changed (mode: 100644) (index e0b5eea..45e0b2c)
... ... enum {
33 33 static int max_line_len; static int max_line_len;
34 34 static struct pwatch_proc *head; static struct pwatch_proc *head;
35 35 static unsigned int view = VIEW_NORMAL; static unsigned int view = VIEW_NORMAL;
36 static unsigned int selected_line = 1;
36 static unsigned int cells = 0;
37 static unsigned int selected_line = 0, last_line = 0, useful_lines = 0;
38 static unsigned int max_pages = 1, page = 0;
37 39 static pid_t selected_pid = 0; static pid_t selected_pid = 0;
38 40
39 41
 
... ... static void iotop_show_cells(const unsigned int page,
117 119 { {
118 120 struct pwatch_proc *p; struct pwatch_proc *p;
119 121 char buf[256]; char buf[256];
120 int limit, max, line, skip;
121 unsigned int no_of_lines;
122 int max, line, skip;
122 123 char rb[16], wb[16]; char rb[16], wb[16];
123 124 char rs[16], ws[16]; char rs[16], ws[16];
124 125
 
... ... static void iotop_show_cells(const unsigned int page,
126 127 if (max > sizeof(buf)) if (max > sizeof(buf))
127 128 max = sizeof(buf); max = sizeof(buf);
128 129
129 /* Limit the number of lines we can show */
130 limit = LINES - 3;
131
132 130 /* skip is the number of entries we have to skip */ /* skip is the number of entries we have to skip */
133 skip = limit * page;
134
135 no_of_lines = cells - skip;
136
137 /* on the last page, we have only partial entries */
138 if (selected_line > no_of_lines)
139 selected_line = no_of_lines;
131 skip = useful_lines * page;
140 132
141 133 p = head; p = head;
142 line = 1;
134 line = 0;
143 135 while (p) { while (p) {
144 136 if (skip > 0) { if (skip > 0) {
145 137 skip--; skip--;
 
... ... static void iotop_show_cells(const unsigned int page,
168 160 } else { } else {
169 161 attron(COLOR_PAIR(2)); attron(COLOR_PAIR(2));
170 162 } }
171 mvaddstr(1 + line, 0, buf);
163 mvaddstr(2 + line, 0, buf);
172 164
173 limit--;
174 if (limit == 0)
165 if (line == last_line)
175 166 break; break;
176 167
177 168 line++; line++;
 
... ... static void iotop_show_process(void)
208 199 attron(COLOR_PAIR(2)); attron(COLOR_PAIR(2));
209 200
210 201 ifd = proc->fd_head; ifd = proc->fd_head;
211 line = 1;
202 line = 0;
212 203 while (ifd) { while (ifd) {
213 if (line > lines_per_page)
204 if (line == lines_per_page)
214 205 break; break;
215 206
216 207 pwatch_flags(flags, sizeof(flags), ifd->flags); pwatch_flags(flags, sizeof(flags), ifd->flags);
217 208
218 209 snprintf(buf, max, "%5d %16ld %16ld %13s %s", snprintf(buf, max, "%5d %16ld %16ld %13s %s",
219 210 ifd->fd, ifd->offset, ifd->size, flags, ifd->file); ifd->fd, ifd->offset, ifd->size, flags, ifd->file);
220 mvaddstr(1 + line, 0, buf);
211 mvaddstr(2 + line, 0, buf);
221 212
222 213 line++; line++;
223 214
 
... ... static void iotop_show_process(void)
225 216 } }
226 217 } }
227 218
219 /*
220 * Recomputes all screen stuff after some changes
221 */
222 static void iotop_recompute_screen(void)
223 {
224 useful_lines = LINES - 3;
225
226 /* Compute how many pages we have */
227 max_pages = (cells + useful_lines - 1) / useful_lines;
228
229 /* Compute last_line */
230 if (page < max_pages - 1)
231 last_line = useful_lines - 1;
232 else
233 last_line = (cells - 1) % useful_lines;
234
235 /* If list shrinked, adapt to it */
236 if (page > max_pages - 1)
237 page = max_pages - 1;
238 if (selected_line > last_line)
239 selected_line = last_line;
240 }
241
228 242 int main(int argc, char *argv[]) int main(int argc, char *argv[])
229 243 { {
230 244 int ch, key_pressed; int ch, key_pressed;
 
... ... int main(int argc, char *argv[])
239 253 unsigned int force_exit = 0; unsigned int force_exit = 0;
240 254 char error[256]; char error[256];
241 255 int errcode; int errcode;
242 unsigned int cells;
243 unsigned int page = 0, max_pages = 1;
244 unsigned int last_line;
256 unsigned int force_redraw = 0;
245 257
246 258 if (pwatch_counters_avail() == -1) { if (pwatch_counters_avail() == -1) {
247 259 fprintf(stderr, "Counters are not available." fprintf(stderr, "Counters are not available."
 
... ... int main(int argc, char *argv[])
295 307 if (max_line_len > sizeof(status)) if (max_line_len > sizeof(status))
296 308 max_line_len = sizeof(status); max_line_len = sizeof(status);
297 309
298 last_line = LINES - 3;
299
300 310 key_pressed = 0; key_pressed = 0;
301 311 if ((ch = getch()) != ERR) { if ((ch = getch()) != ERR) {
302 312 key_pressed = 1; key_pressed = 1;
 
... ... int main(int argc, char *argv[])
327 337 case KEY_NPAGE: case KEY_NPAGE:
328 338 if (page + 1 < max_pages) { if (page + 1 < max_pages) {
329 339 page++; page++;
330 selected_line = 1;
340 selected_line = 0;
331 341 } }
332 342 break; break;
333 343 case KEY_PPAGE: case KEY_PPAGE:
334 344 if (page > 0) { if (page > 0) {
335 345 page--; page--;
336 selected_line = 1;
346 selected_line = 0;
337 347 } }
338 348 break; break;
339 349 case KEY_HOME: case KEY_HOME:
340 350 page = 0; page = 0;
341 selected_line = 1;
351 selected_line = 0;
342 352 break; break;
343 353 case KEY_END: case KEY_END:
344 354 page = max_pages - 1; page = max_pages - 1;
345 selected_line = 1;
355 selected_line = 0;
346 356 break; break;
347 357 case KEY_UP: case KEY_UP:
348 if (selected_line > 1) {
358 if (selected_line > 0) {
349 359 selected_line--; selected_line--;
350 360 } else if (page > 0) { } else if (page > 0) {
351 361 page--; page--;
352 selected_line = last_line;
362 selected_line = useful_lines - 1;
353 363 } }
354 364 break; break;
355 365 case KEY_DOWN: case KEY_DOWN:
356 366 if (selected_line < last_line) { if (selected_line < last_line) {
357 367 selected_line++; selected_line++;
358 } else if (page + 1 < max_pages) {
368 } else if (page < max_pages - 1) {
359 369 page++; page++;
360 selected_line = 1;
370 selected_line = 0;
361 371 } }
362 372 break; break;
363 373 case 'i': case 'i':
 
... ... int main(int argc, char *argv[])
392 402 } }
393 403
394 404 /* test if is the momment to do the refresh */ /* test if is the momment to do the refresh */
405 force_redraw = 0;
395 406 if ((refresh_count == 0) || (key_pressed == 1)) { if ((refresh_count == 0) || (key_pressed == 1)) {
396 407 if ((cells = pwatch_proc_load(&head)) < 0) { if ((cells = pwatch_proc_load(&head)) < 0) {
397 408 snprintf(error, sizeof(error), "Error getting processes info!\n"); snprintf(error, sizeof(error), "Error getting processes info!\n");
 
... ... int main(int argc, char *argv[])
403 414
404 415 pwatch_proc_sort(&head, sort_by, inverse); pwatch_proc_sort(&head, sort_by, inverse);
405 416
406 /* May be wrong here? */
407 max_pages = (cells + (LINES - 3) - 1) / (LINES - 3);
417 force_redraw = 1;
418 }
419
420 iotop_recompute_screen();
408 421
409 /* draw */
422 if (force_redraw == 1) {
410 423 erase(); erase();
411 424
412 425 /* up status */ /* up status */
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