Exemple #1
0
/*
 *  *_procstates(total, brkdn, names) - print the process summary line
 *
 *  Assumptions:  cursor is at the beginning of the line on entry
 */
void
i_procstates(int total, int *brkdn)
{
	if (screen_length > 2 || !smart_terminal) {
		int i;
		char procstates_buffer[MAX_COLS];

		move(1, 0);
		clrtoeol();
		/* write current number of processes and remember the value */
		printwp("%d processes:", total);

		if (smart_terminal)
			move(1, 15);
		else {
			/* put out enough spaces to get to column 15 */
			i = digits(total);
			while (i++ < 4) {
				if (putchar(' ') == EOF)
					exit(1);
			}
		}

		/* format and print the process state summary */
		summary_format(procstates_buffer, sizeof(procstates_buffer), brkdn,
		    procstate_names);

		addstrp(procstates_buffer);
		putn();
	}
}
Exemple #2
0
void
i_timeofday(time_t * tod)
{
	static char buf[30];

	if (buf[0] == '\0')
		gethostname(buf, sizeof(buf));

	if (screen_length > 1 || !smart_terminal) {
		if (smart_terminal) {
			move(0, screen_width - 8 - strlen(buf) - 1);
		} else {
			if (fputs("    ", stdout) == EOF)
				exit(1);
		}
#ifdef DEBUG
		{
			char *foo;
			foo = ctime(tod);
			addstrp(foo);
		}
#endif
		printwp("%s %-8.8s", buf, &(ctime(tod)[11]));
		putn();
	}
}
Exemple #3
0
void
i_loadave(pid_t mpid, double *avenrun)
{
	if (screen_length > 1 || !smart_terminal) {
		int i;

		move(0, 0);
		clrtoeol();

		addstrp("load averages");
		/* mpid == -1 implies this system doesn't have an _mpid */
		if (mpid != -1)
			printwp("last pid: %5ld;  ", (long) mpid);

		for (i = 0; i < 3; i++)
			printwp("%c %5.2f", i == 0 ? ':' : ',', avenrun[i]);
	}
}
Exemple #4
0
/*
 *  show_errors() - display on stdout the current log of errors.
 */
void
show_errors(void)
{
	struct errs *errp = errs;
	int cnt = 0;

	if (smart_terminal) {
		clear();
		nl();
	}
	printwp("%d error%s:\n\n", errcnt, errcnt == 1 ? "" : "s");
	while (cnt++ < errcnt) {
		printwp("%5s: %s\n", errp->arg,
		    errp->err == 0 ? "Not a number" : strerror(errp->err));
		errp++;
	}
	printwp("\n");
	if (smart_terminal) {
		nonl();
		refresh();
	}
}
Exemple #5
0
static char *
printregs(EiceRegs *regs, char *s, int ssz)
{
	char *e, *te, i;

	te = s + ssz -1;
	
	e = seprint(s, te, "debug: %#2.2ux\n", regs->debug);
	e = seprint(e, te, "debsts: %#2.2ux\n", regs->debsts);
	e = seprint(e, te, "veccat: %#2.2ux\n", regs->veccat);
	e = seprint(e, te, "debcomctl: %#2.2ux\n", regs->debcomctl);
	e = seprint(e, te, "debcomdata: %#8.8ux\n", regs->debcomdata);

	for(i = 0; i<nelem(regs->wp); i++)
		e = printwp(regs->wp + i, e, ssz+(s-e));
	return e;
}
Exemple #6
0
/*
 *  show_help() - display the help screen; invoked in response to
 *		either 'h' or '?'.
 */
void
show_help(void)
{
	if (smart_terminal) {
		clear();
		nl();
	}
	printwp("These single-character commands are available:\n"
	    "\n"
	    "^L           - redraw screen\n"
	    "<space>      - update screen\n"
	    "+            - reset any g, p, or u filters\n"
	    "1            - display CPU statistics on a single line\n"
	    "C            - toggle the display of command line arguments\n"
	    "d count      - show `count' displays, then exit\n"
	    "e            - list errors generated by last \"kill\" or \"renice\" command\n"
	    "g string     - filter on command name (g+ selects all commands)\n"
	    "h | ?        - help; show this text\n"
	    "H            - toggle the display of threads\n"
	    "I | i        - toggle the display of idle processes\n"
	    "k [-sig] pid - send signal `-sig' to process `pid'\n"
	    "n|# count    - show `count' processes\n"
	    "o field      - specify sort order (size, res, cpu, time, pri, pid, command)\n"
	    "P pid        - highlight process `pid' (P+ switches highlighting off)\n"
	    "p pid        - display process by `pid' (p+ selects all processes)\n"
	    "q            - quit\n"
	    "r count pid  - renice process `pid' to nice value `count'\n"
	    "S            - toggle the display of system processes\n"
	    "s time       - change delay between displays to `time' seconds\n"
	    "u user       - display processes for `user' (u+ selects all users)\n"
	    "\n");

	if (smart_terminal) {
		nonl();
		refresh();
	}
}
Exemple #7
0
void
i_cpustates(int64_t *ostates)
{
	int i, first, cpu;
	double value;
	int64_t *states;
	char **names, *thisname;

	if (combine_cpus) {
		static double *values;
		if (!values) {
			values = calloc(num_cpustates, sizeof(*values));
			if (!values)
				err(1, NULL);
		}
		memset(values, 0, num_cpustates * sizeof(*values));
		for (cpu = 0; cpu < ncpu; cpu++) {
			names = cpustate_names;
			states = ostates + (CPUSTATES * cpu);
			i = 0;
			while ((thisname = *names++) != NULL) {
				if (*thisname != '\0') {
					/* retrieve the value and remember it */
					values[i++] += *states++;
				}
			}
		}
		if (screen_length > 2 || !smart_terminal) {
			names = cpustate_names;
			i = 0;
			first = 0;
			move(2, 0);
			clrtoeol();
			addstrp("All CPUs: ");

			while ((thisname = *names++) != NULL) {
				if (*thisname != '\0') {
					value = values[i++] / ncpu;
					/* if percentage is >= 1000, print it as 100% */
					printwp((value >= 1000 ? "%s%4.0f%% %s" :
					    "%s%4.1f%% %s"), first++ == 0 ? "" : ", ",
					    value / 10., thisname);
				}
			}
			putn();
		}
		return;
	}
	for (cpu = 0; cpu < ncpu; cpu++) {
		/* now walk thru the names and print the line */
		names = cpustate_names;
		first = 0;
		states = ostates + (CPUSTATES * cpu);

		if (screen_length > 2 + cpu || !smart_terminal) {
			move(2 + cpu, 0);
			clrtoeol();
			addstrp(cpustates_tag(cpu));

			while ((thisname = *names++) != NULL) {
				if (*thisname != '\0') {
					/* retrieve the value and remember it */
					value = *states++;

					/* if percentage is >= 1000, print it as 100% */
					printwp((value >= 1000 ? "%s%4.0f%% %s" :
					    "%s%4.1f%% %s"), first++ == 0 ? "" : ", ",
					    value / 10., thisname);
				}
			}
			putn();
		}
	}
}