void server_stats(SERVER_STATS *ssp, int dumpall) { unsigned total, fail, success, nodes, anr, overhead, memcap; memcap = overhead = nodes = anr = total = fail = success = 0; if(ssp && ssp->ipv4_table) { total = sfxhash_find_total(ssp->ipv4_table); fail = sfxhash_find_fail(ssp->ipv4_table); success = sfxhash_find_success(ssp->ipv4_table); nodes = sfxhash_count(ssp->ipv4_table); anr = sfxhash_anr_count(ssp->ipv4_table); memcap = server_stats_memcap(ssp); overhead = server_stats_overhead_bytes(ssp); } flow_printf(",-----[SERVER STATS]------------\n"); flow_printf(" Memcap: %u Overhead Bytes: %u\n", memcap, overhead); flow_printf(" Finds: %u (Sucessful: %u(%%%lf) Unsucessful: %u(%%%lf))\n", total, success, calc_percent(success,total), fail, calc_percent(fail,total)); flow_printf(" Nodes: %u\n", nodes); flow_printf(" Recovered Nodes: %u\n", anr); flow_printf("`-------------------------------\n"); if(dumpall) server_stats_dump(ssp); }
virtual void do_update_ui() { const unsigned c_width = 60; percent_done = calc_percent(extract_completed, extract_total); unsigned __int64 extract_speed; if (time_elapsed() == 0) extract_speed = 0; else extract_speed = al_round(static_cast<double>(extract_completed) / time_elapsed() * ticks_per_sec()); if (extract_total && cache_total > extract_total) cache_total = extract_total; unsigned cache_stored_percent = calc_percent(cache_stored, cache_total); unsigned cache_written_percent = calc_percent(cache_written, cache_total); wostringstream st; st << fit_str(arc_path, c_width) << L'\n'; st << L"\x1\n"; st << fit_str(extract_file_path, c_width) << L'\n'; st << setw(7) << format_data_size(extract_completed, get_size_suffixes()) << L" / " << format_data_size(extract_total, get_size_suffixes()) << L" @ " << setw(9) << format_data_size(extract_speed, get_speed_suffixes()) << L'\n'; st << Far::get_progress_bar_str(c_width, percent_done, 100) << L'\n'; st << L"\x1\n"; st << fit_str(cache_file_path, c_width) << L'\n'; st << L"(" << format_data_size(cache_stored, get_size_suffixes()) << L" - " << format_data_size(cache_written, get_size_suffixes()) << L") / " << format_data_size(cache_total, get_size_suffixes()) << L'\n'; st << get_progress_bar_str(c_width, cache_written_percent, cache_stored_percent) << L'\n'; progress_text = st.str(); }
static void print_status(void) { struct timeval time_end; char diff_buf[32], line_buf[128]; int len; gettimeofday(&time_end, 0); len = snprintf(line_buf, sizeof(line_buf), _("%6.2f%% done, %s elapsed. " "(%d/%d/%d errors)"), calc_percent((unsigned long) currently_testing, (unsigned long) num_blocks), time_diff_format(&time_end, &time_start, diff_buf), num_read_errors, num_write_errors, num_corruption_errors); #ifdef HAVE_MBSTOWCS len = mbstowcs(NULL, line_buf, sizeof(line_buf)); #endif fputs(line_buf, stderr); memset(line_buf, '\b', len); line_buf[len] = 0; fputs(line_buf, stderr); fflush (stderr); }
/* Print a status line if -M was specified */ static void m_status_print(void) { int percentage; if (!past_eof) { if (!line_pos) { if (num_files > 1) printf("%s%s %s%i%s%i%s%i-%i/%i ", HIGHLIGHT, filename, "(file ", current_file, " of ", num_files, ") lines ", line_pos + 1, line_pos + height - 1, num_flines + 1); else { printf("%s%s lines %i-%i/%i ", HIGHLIGHT, filename, line_pos + 1, line_pos + height - 1, num_flines + 1); } } else { printf("%s %s lines %i-%i/%i ", HIGHLIGHT, filename, line_pos + 1, line_pos + height - 1, num_flines + 1); } if (line_pos == num_flines - height + 2) { printf("(END) %s", NORMAL); if ((num_files > 1) && (current_file != num_files)) printf("%s- Next: %s%s", HIGHLIGHT, files[current_file], NORMAL); } else { percentage = calc_percent(); printf("%i%% %s", percentage, NORMAL); } } else { printf("%s%s lines %i-%i/%i (END) ", HIGHLIGHT, filename, line_pos + 1, num_flines + 1, num_flines + 1); if ((num_files > 1) && (current_file != num_files)) printf("- Next: %s", files[current_file]); printf("%s", NORMAL); } }
virtual void do_update_ui() { const unsigned c_width = 60; percent_done = calc_percent(completed, total); wostringstream st; st << fit_str(file_path, c_width) << L'\n'; st << Far::get_progress_bar_str(c_width, percent_done, 100) << L'\n'; progress_text = st.str(); }
/* Print a status line if -m was specified */ static void medium_status_print(void) { int percentage; percentage = calc_percent(); if (!line_pos) printf("%s%s %i%%%s", HIGHLIGHT, filename, percentage, NORMAL); else if (line_pos == num_flines - height + 2) printf("%s(END)%s", HIGHLIGHT, NORMAL); else printf("%s%i%%%s", HIGHLIGHT, percentage, NORMAL); }
static void bg_progress_steps( bg_progress * self ) { uint64_t max_value = atomic64_read( &self -> max_value ); uint64_t value = atomic64_read( &self -> value ); uint32_t percent = calc_percent( max_value, value, self -> digits ); if ( percent > self -> cur ) { uint32_t i; for ( i = self -> cur + 1; i <= percent; ++i ) update_progressbar( self -> progressbar, i ); self -> cur = percent; } }
virtual void do_update_ui() { const unsigned c_width = 60; percent_done = calc_percent(completed, total); unsigned __int64 time = time_elapsed(); unsigned __int64 speed; if (time == 0) speed = 0; else speed = al_round(static_cast<double>(completed) / time * ticks_per_sec()); unsigned __int64 total_time; if (completed) total_time = static_cast<unsigned __int64>(static_cast<double>(total) / completed * time); else total_time = 0; if (total_time < time) total_time = time; wostringstream st; st << fit_str(arc_path, c_width) << L'\n'; st << L"\x1\n"; st << fit_str(file_path, c_width) << L'\n'; st << setw(7) << format_data_size(file_completed, get_size_suffixes()) << L" / " << format_data_size(file_total, get_size_suffixes()) << L'\n'; st << Far::get_progress_bar_str(c_width, calc_percent(file_completed, file_total), 100) << L'\n'; st << L"\x1\n"; st << setw(7) << format_data_size(completed, get_size_suffixes()) << L" / " << format_data_size(total, get_size_suffixes()) << L" @ " << setw(9) << format_data_size(speed, get_speed_suffixes()) << L" -" << format_time((total_time - time) / ticks_per_sec()) << L'\n'; st << setw(7) << format_data_size(total_data_read, get_size_suffixes()) << L" \x2192 " << setw(7) << format_data_size(total_data_written, get_size_suffixes()) << L" = " << setw(2) << calc_percent(total_data_written, total_data_read) << L"%" << L'\n'; st << Far::get_progress_bar_str(c_width, percent_done, 100) << L'\n'; progress_text = st.str(); }
static void print_status(void) { float percent; percent = calc_percent((unsigned long) currently_testing, (unsigned long) num_blocks); percent = (percent/2.0f) + ((cur_op==OP_READ)? 50.0f : 0.0f); PrintStatus(0, FALSE, "Bad Blocks: PASS %d/%d - %0.2f%% (%d/%d/%d errors)", cur_pattern, nr_pattern, percent, num_read_errors, num_write_errors, num_corruption_errors); UpdateProgress(OP_BADBLOCKS, (((cur_pattern-1)*100.0f) + percent) / nr_pattern); }
static void print_status(void) { float percent; percent = calc_percent((unsigned long) currently_testing, (unsigned long) num_blocks); PrintInfo(0, MSG_235, lmprintf(MSG_191 + ((cur_op==OP_WRITE)?0:1)), cur_pattern, nr_pattern, percent, num_read_errors, num_write_errors, num_corruption_errors); percent = (percent/2.0f) + ((cur_op==OP_READ)? 50.0f : 0.0f); UpdateProgress(OP_BADBLOCKS, (((cur_pattern-1)*100.0f) + percent) / nr_pattern); }
void scoreboard_stats(SCOREBOARD *sbp, int dumpall) { unsigned total = sfxhash_find_total(sbp->ipv4_table); unsigned fail = sfxhash_find_fail(sbp->ipv4_table); unsigned success = sfxhash_find_success(sbp->ipv4_table); flow_printf("SCOREBOARD_STATS: %s\n", (char *) sbp->description); flow_printf(" Memcap: %u Overhead Bytes: %u\n", sbp->ipv4_table->mc.memcap, sfxhash_overhead_bytes(sbp->ipv4_table)); flow_printf(" Finds: %u (Sucessful: %u(%%%f) Unsucessful: %u(%%%f))\n", total, success, calc_percent(success,total), fail, calc_percent(fail,total)); flow_printf(" Nodes: %u\n", sfxhash_count(sbp->ipv4_table)); flow_printf(" Recovered Nodes: %u\n", sfxhash_anr_count(sbp->ipv4_table)); flow_printf(" Score Entry Size:: %u\n", sizeof(SCORE_ENTRY)); if(dumpall) scoreboard_dump(sbp); }
/** * Print out some of the common information about the Flow Processor * configuration * */ static void DisplayFlowConfig(void) { SPPFLOW_CONFIG *cp = &s_config; FLOWCACHE *fcp = &s_fcache; LogMessage(",-----------[Flow Config]----------------------\n"); LogMessage("| Stats Interval: %d\n", cp->stats_interval); LogMessage("| Hash Method: %d\n", cp->hashid); LogMessage("| Memcap: %d\n", cp->memcap); LogMessage("| Rows : %d\n", flowcache_row_count(fcp)); LogMessage("| Overhead Bytes: %d(%%%.2lf)\n", flowcache_overhead_bytes(fcp), calc_percent(flowcache_overhead_bytes(fcp),cp->memcap)); LogMessage("`----------------------------------------------\n"); }
static int e2fsck_update_progress(e2fsck_t ctx, int pass, unsigned long cur, unsigned long max) { char buf[80]; float percent; if (pass == 0) return 0; if (ctx->progress_fd) { sprintf(buf, "%d %lu %lu\n", pass, cur, max); write(ctx->progress_fd, buf, strlen(buf)); } else { percent = calc_percent(&e2fsck_tbl, pass, cur, max); e2fsck_simple_progress(ctx, ctx->device_name, percent, 0); } return 0; }
void handle_ver_dlg(BOOL kill) { static HWND hwnd; if (kill) { if (hwnd) DestroyWindow(hwnd); hwnd = NULL; return; } if (hwnd) { MessageLoop(0); } else if (GetTickCount() > verify_time) { #ifdef NSIS_COMPRESS_WHOLE if (g_hwnd) { if (g_exec_flags.status_update & 1) { TCHAR bt[64]; wsprintf(bt, _T("... %d%%"), calc_percent()); update_status_text(0, bt); } } else #endif { hwnd = CreateDialog( g_hInstance, MAKEINTRESOURCE(IDD_VERIFY), 0, verProc ); ShowWindow(hwnd, SW_SHOW); } } }
INT_PTR CALLBACK verProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { SetTimer(hwndDlg,1,250,NULL); uMsg = WM_TIMER; } if (uMsg == WM_TIMER) { TCHAR bt[64]; int percent=calc_percent(); #ifdef NSIS_COMPRESS_WHOLE TCHAR *msg=g_header?_LANG_UNPACKING:_LANG_VERIFYINGINST; #else TCHAR *msg=_LANG_VERIFYINGINST; #endif wsprintf(bt,msg,percent); my_SetWindowText(hwndDlg,bt); my_SetDialogItemText(hwndDlg,IDC_STR,bt); } return FALSE; }
/* Print a status line if -M was specified */ static void m_status_print(void) { int percentage; if (less_gets_pos >= 0) /* don't touch statusline while input is done! */ return; clear_line(); printf(HIGHLIGHT"%s", filename); if (num_files > 1) printf(" (file %i of %i)", current_file, num_files); printf(" lines %i-%i/%i ", cur_fline + 1, cur_fline + max_displayed_line + 1, max_fline + 1); if (cur_fline >= (int)(max_fline - max_displayed_line)) { printf("(END)"NORMAL); if (num_files > 1 && current_file != num_files) printf(HIGHLIGHT" - next: %s"NORMAL, files[current_file]); return; } percentage = calc_percent(); printf("%i%%"NORMAL, percentage); }
/** * Display what the underlying tidbits think the config is * * @param trackerp grab the configuration info from the portscan tracker */ static void FlowPSOutputConfig(PS_TRACKER *trackerp) { if(pv.quiet_flag) return; flow_printf(",-----------[flow-portscan config]-------------\n"); flow_printf("| TCP Penalties: %s\n", trackerp->config.tcp_penalties ? "On": "Off"); flow_printf("| Ouput Mode: %s\n", (trackerp->config.output_mode == VARIABLEMSG) ? "msg" : "pktkludge"); flow_printf("| Base Score: %d\n", trackerp->config.base_score); flow_printf("+----------------------------------------------\n"); flow_printf("| Scoreboard: ACTIVE PORTSCANNER\n"); flow_printf("| memcap: %-8d %-8d\n", scoreboard_memcap(&trackerp->table_active), scoreboard_memcap(&trackerp->table_scanner)); flow_printf("| rows: %-8d %-8d\n", scoreboard_row_count(&trackerp->table_active), scoreboard_row_count(&trackerp->table_scanner)); flow_printf("| overhead: %-8d(%%%.02lf) %-8d(%%%.02lf)\n", scoreboard_overhead_bytes(&trackerp->table_active), calc_percent(scoreboard_overhead_bytes(&trackerp->table_active), scoreboard_memcap(&trackerp->table_active)), scoreboard_overhead_bytes(&trackerp->table_scanner), calc_percent(scoreboard_overhead_bytes(&trackerp->table_scanner), scoreboard_memcap(&trackerp->table_scanner))); flow_printf("| fixed-size: %-4ds %-4ds\n", trackerp->config.limit_talker.fixed_size, trackerp->config.limit_scanner.fixed_size); flow_printf("| sliding-size: %-4ds %-4ds\n", trackerp->config.limit_talker.sliding_size, trackerp->config.limit_scanner.sliding_size); flow_printf("| threshold-fixed: %-4u %-4u\n", trackerp->config.limit_talker.fixed, trackerp->config.limit_scanner.fixed); flow_printf("| threshold-sliding: %-4u %-4u\n", trackerp->config.limit_talker.sliding, trackerp->config.limit_scanner.sliding); flow_printf("| window scale: %-.2lf %-.2lf\n", trackerp->config.limit_talker.window_scale, trackerp->config.limit_scanner.window_scale); flow_printf("+----------------------------------------------\n"); flow_printf("| Uniqueness: memcap: %8d rows: %8d\n", ut_memcap(&trackerp->unique_tracker), ut_row_count(&trackerp->unique_tracker)); flow_printf("| overhead: %d (%%%.02lf)\n", ut_overhead_bytes(&trackerp->unique_tracker), calc_percent(ut_overhead_bytes(&trackerp->unique_tracker), ut_memcap(&trackerp->unique_tracker))); if(flowps_server_stats_enabled(trackerp) == FLOW_SUCCESS) { flow_printf("+----------------------------------------------\n"); flow_printf("| Server Stats: memcap: %8d rows: %8d\n", server_stats_memcap(&trackerp->server_stats), server_stats_row_count(&trackerp->server_stats)); flow_printf("| overhead: %d (%%%.02lf)\n", server_stats_overhead_bytes(&trackerp->server_stats), calc_percent(server_stats_overhead_bytes(&trackerp->server_stats), server_stats_memcap(&trackerp->server_stats))); flow_printf("| learning time: %d\n", trackerp->config.server_learning_time); flow_printf("| ignore limit: %u\n", trackerp->config.server_ignore_limit); flow_printf("| scanner limit: %u\n", trackerp->config.server_scanner_limit); } else { flow_printf("| Server Stats: Disabled\n"); } flow_printf("`----------------------------------------------\n"); }
void ch_main(){ calc_ch(); calc_percent(); calc_grade(); ch_move(); }
void flowcache_stats(FILE *stream, FLOWCACHE *flowcachep) { int could_hold; int i; time_t low_time = 0, high_time = 0, diff_time = 0; int diff_hours = 0, diff_min = 0, diff_sec = 0; int diff_blocks = 0; FLOW *flow_mrup, *flow_lrup; #ifdef INDEPTH_DEBUG printf("table max depth: %u\n", sfxhash_maxdepth(flowcachep->ipv4_table)); #endif /* INDEPTH_DEBUG */ if((flowcache_mru(flowcachep, &flow_mrup) == FLOW_SUCCESS) && (flowcache_lru(flowcachep, &flow_lrup) == FLOW_SUCCESS)) { low_time = flow_lrup->stats.last_packet; high_time = flow_mrup->stats.last_packet; diff_time = high_time - low_time; diff_hours = diff_time / 3600; diff_min = (diff_time - (3600 * diff_hours)) / 60; diff_sec = diff_time % 60; } diff_blocks = flowcachep->ipv4_table->mc.nblocks - flowcache_overhead_blocks(flowcachep); //could_hold = flowcachep->ipv4_table->mc.memcap / // (sizeof(FLOW) + sizeof(FLOWKEY) + sizeof(SFXHASH_NODE)); /* this is a bad calculation -- should clean this up */ if(diff_blocks > 0) { could_hold = (flowcachep->ipv4_table->mc.memused - flowcache_overhead_bytes(flowcachep)) / diff_blocks; could_hold = flowcachep->ipv4_table->mc.memcap / could_hold; } else { could_hold = diff_blocks; } flow_printf(",----[ FLOWCACHE STATS ]----------\n"); flow_printf("Memcap: %u Overhead Bytes %u used(%%%f)/blocks (%u/%u)\nOverhead blocks: %u Could Hold: (%u)\n", flowcachep->ipv4_table->mc.memcap, flowcache_overhead_bytes(flowcachep), calc_percent(flowcachep->ipv4_table->mc.memused, flowcachep->ipv4_table->mc.memcap), flowcachep->ipv4_table->mc.memused, flowcachep->ipv4_table->mc.nblocks, flowcache_overhead_blocks(flowcachep), could_hold); flow_printf("IPV4 count: %u frees: %u\nlow_time: %u, high_time: %u," " diff: %dh:%02d:%02ds\n", sfxhash_count(flowcachep->ipv4_table), sfxhash_anr_count(flowcachep->ipv4_table), (unsigned) low_time, (unsigned) high_time, diff_hours,diff_min,diff_sec); flow_printf(" finds: " STDu64 " reversed: " STDu64 "(%%%f) \n find_success: " STDu64 " " "find_fail: " STDu64 "\npercent_success: (%%%f) new_flows: " STDu64 "\n", flowcachep->total.find_ops, flowcachep->total.reversed_ops, calc_percent64(flowcachep->total.reversed_ops, flowcachep->total.find_ops), flowcachep->total.find_success, flowcachep->total.find_fail, calc_percent64(flowcachep->total.find_success, flowcachep->total.find_ops), flowcachep->total.new_flows); for(i=0;i<256;i++) { if(flowcachep->per_proto[i].find_ops > 0) { flow_printf(" Protocol: %d (%%%f)\n" " finds: " STDu64 "\n" " reversed: " STDu64 "(%%%f)\n" " find_success: " STDu64 "\n" " find_fail: " STDu64 "\n" " percent_success: (%%%f)\n" " new_flows: " STDu64 "\n", i, calc_percent64(flowcachep->per_proto[i].find_ops, flowcachep->total.find_ops), flowcachep->per_proto[i].find_ops, flowcachep->per_proto[i].reversed_ops, calc_percent64(flowcachep->per_proto[i].reversed_ops, flowcachep->per_proto[i].find_ops), flowcachep->per_proto[i].find_success, flowcachep->per_proto[i].find_fail, calc_percent64(flowcachep->per_proto[i].find_success, flowcachep->per_proto[i].find_ops), flowcachep->per_proto[i].new_flows); } } }