示例#1
0
static void output_memstats(struct stats *stats)
{
	char buf[128];
	unsigned long totalmem;
	int blink = 0;

	werase(mem_window);
	if (stats->mem > 0 || (stats->mem >=0 && (stats->lpoolt > 0))) {
		box(mem_window, 0, 0);

		if (stats->mem > 0)
		    snprintf(buf, sizeof(buf),"heap %4luM mmap %4luM unused %3luM",
			     stats->lheapu/1000, stats->lmmapu/1000, stats->lreleasable/1000);
		else
		    snprintf(buf, sizeof(buf), "heap   N/A mmap   N/A unused  N/A");
		mvwprintw(mem_window, 1, 1, "Mem:  ");
		print_colored(mem_window, buf);

		mvwprintw(mem_window, 2, 1, "Libc: ");
		if (stats->mem > 0)
		    snprintf(buf, sizeof(buf),"used %4luM free %4luM total %4luM",
			     stats->ltotalu/1000, stats->ltotalf/1000, (stats->ltotalu+stats->ltotalf)/1000);
		else
		    snprintf(buf, sizeof(buf), "used   N/A free   N/A total   N/A");
		print_colored(mem_window, buf);

		mvwprintw(mem_window, 3, 1, "Pool: ");
		snprintf(buf, sizeof(buf), "count %4u used %4luM total %4luM",
			stats->pools_cnt, stats->lpoolu/1000, stats->lpoolt/1000);
		print_colored(mem_window, buf);

		totalmem = stats->lheapu + stats->lmmapu + stats->lpoolt;
		if(totalmem > biggest_mem) {
			biggest_mem = totalmem;
			blink = 1;
		}
		show_bar(mem_window, 4, totalmem, stats->lmmapu + stats->lreleasable + stats->lpoolt - stats->lpoolu,
				biggest_mem, blink);
	}
	wrefresh(mem_window);
}
示例#2
0
void main(void) {
	clear();
	println_newline();
	print_colored("     _   _                ", LOGO_NEM_COLOR);
	println_colored(" ____   _____", LOGO_OS_COLOR);
	print_colored("    | \\ | |               ", LOGO_NEM_COLOR);
	println_colored("/ __ \\ / ____|", LOGO_OS_COLOR);
	print_colored("    |  \\| | ___ _ __ ___ ", LOGO_NEM_COLOR);
	println_colored("| |  | | (___  ", LOGO_OS_COLOR);
	print_colored("    | . ` |/ _ \\ '_ ` _ \\", LOGO_NEM_COLOR);
	println_colored("| |  | |\\___ \\ ", LOGO_OS_COLOR);
	print_colored("    | |\\  |  __/ | | | | ", LOGO_NEM_COLOR);
	println_colored("| |__| |____) |", LOGO_OS_COLOR);
	print_colored("    |_| \\_|\\___|_| |_| |_|", LOGO_NEM_COLOR);
	println_colored("\\____/|_____/ ", LOGO_OS_COLOR);
	println_newline();

	initialize_idt();
	initialize_keyboard();

	while (1);
}
示例#3
0
void println_colored(const char *str, char color) {
	print_colored(str, color);
	println_newline();
}
示例#4
0
void print(const char *str) {
	print_colored(str, BASE_COLOR);
}
示例#5
0
static int output_stats(struct stats *stats, unsigned idx)
{
	char buf[128];
	char timbuf[15];
	int blink = 0;
	size_t i= 0;
	char mem[6];
	WINDOW *win = stats_head_window;
	int sel = detail_is_selected(idx);
	char *line = malloc(maxx+1);

	OOM_CHECK(line);

	if (stats->mem <= 0 || stats->stats_unsupp) {
		strncpy(mem, "N/A", sizeof(mem));
		mem[sizeof(mem)-1]='\0';
	}
	else {
		char c;
		double s;
		if (stats->mem > 999.0)  {
			c = 'G';
			s = stats->mem / 1024.0;
		} else {
			c = 'M';
			s = stats->mem;
		}
		snprintf(mem, sizeof(mem), "%7.3f", s);
		i = 4;
		if (mem[i-1] == '.') i--;
		mem[i++] = c;
		mem[i] = '\0';
	}
	i = idx+1;

	if (!stats->db_time.tm_year) {
		strncpy(timbuf,"N/A",sizeof(timbuf));
		timbuf[sizeof(timbuf)-1]='\0';
	}
	else
		snprintf(timbuf, sizeof(timbuf), "%04u-%02u-%02u %02uh",
				1900 + stats->db_time.tm_year,
				stats->db_time.tm_mon+1,
				stats->db_time.tm_mday,
				stats->db_time.tm_hour);

	memset(line, ' ', maxx+1);
	if (!stats->stats_unsupp) {
		snprintf(line, maxx-1, "%2u %02u:%02u:%02u %3u %3u %5u %5u %5s %-14s %-6s %5s %s", idx+1,  stats->conn_hr, stats->conn_min, stats->conn_sec,
			stats->live, stats->idle,
			stats->current_q, stats->biggest_queue,
			mem,
			stats->remote, stats->engine_version, stats->db_version, timbuf);
	} else {
		snprintf(line, maxx-1, "%2u %02u:%02u:%02u N/A N/A   N/A   N/A   N/A %-14s %-6s %5s %s", idx+1,  stats->conn_hr, stats->conn_min, stats->conn_sec,
			stats->remote, stats->engine_version, stats->db_version, timbuf);
	}
	line[maxx] = '\0';
	line[strlen(line)] = ' ';
	if (sel) {
		wattron(win,  COLOR_PAIR(selected_color));
	}
	mvwprintw(win, i, 0, "%s", line);
	if (sel) {
		wattroff(win, COLOR_PAIR(selected_color));
	}
	win = stats_window;
	i = 0;
	if (sel && !stats->stats_unsupp) {
		memset(line, ' ', maxx+1);
		snprintf(line, maxx-1, "Details for Clamd version: %s", stats->version);
		line[maxx] = '\0';
		line[strlen(line)]= ' ';
		wattron(win,  COLOR_PAIR(queue_header_color));
		mvwprintw(win, i++, 0, "%s", line);
		wattroff(win, COLOR_PAIR(queue_header_color));
		mvwprintw(win, i++, 0, "Primary threads: ");
		snprintf(buf, sizeof(buf), "live %3u idle %3u max %3u", stats->prim_live, stats->prim_idle, stats->prim_max);
		print_colored(win, buf);
		show_bar(win, i++, stats->prim_live, stats->prim_idle, stats->prim_max, 0);
/*		mvwprintw(win, i++, 0, "Multiscan pool : ");
		snprintf(buf, sizeof(buf), "live %3u idle %3u max %3u", stats->live, stats->idle, stats->max);
		print_colored(win, buf);
		show_bar(win, i++, stats->live, stats->idle, stats->max, 0);*/

		blink = 0;
		if(stats->current_q > stats->biggest_queue) {
			stats->biggest_queue = stats->current_q;
			blink = 1;
		}
		mvwprintw(win, i++, 0, "Queue:");
		snprintf(buf, sizeof(buf), "%6u items %6u max", stats->current_q, stats->biggest_queue);
		print_colored(win, buf);
		show_bar(win, i++, stats->current_q, 0, stats->biggest_queue, blink);
		i += 2;
		werase(mem_window);
		output_memstats(stats);
	}
	free(line);
	return i;
}