Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/cui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ extern bool sortRecv;
extern int viewMode;
extern bool showcommandline;
extern bool showBasename;
extern bool suppressBanner;

extern unsigned refreshlimit;
extern unsigned refreshcount;
Expand Down Expand Up @@ -347,6 +348,7 @@ void show_ncurses(Line *lines[], int nproc) {
int rows; // number of terminal rows
int cols; // number of terminal columns
unsigned int proglen; // max length of the "PROGRAM" column
int bannerheight = 0; // used to place table below banner, if present

double sent_global = 0;
double recv_global = 0;
Expand All @@ -369,9 +371,12 @@ void show_ncurses(Line *lines[], int nproc) {
proglen = cols - 50 - devlen;

erase();
mvprintw(0, 0, "%s", caption->c_str());
if (!suppressBanner) {
mvprintw(0, 0, "%s", caption->c_str());
bannerheight = 2;
}
attron(A_REVERSE);
mvprintw(2, 0,
mvprintw(bannerheight, 0,
" PID USER %-*.*s %-*.*s SENT RECEIVED ",
proglen, proglen, "PROGRAM", devlen, devlen, "DEV");
attroff(A_REVERSE);
Expand All @@ -380,16 +385,16 @@ void show_ncurses(Line *lines[], int nproc) {
int i;
for (i = 0; i < nproc; i++) {
if (i + 3 < rows)
lines[i]->show(i + 3, proglen, devlen);
lines[i]->show(i + bannerheight + 1, proglen, devlen);
recv_global += lines[i]->recv_value;
sent_global += lines[i]->sent_value;
delete lines[i];
}
attron(A_REVERSE);
int totalrow = std::min(rows - 1, 3 + 1 + i);
int totalrow = std::min(rows - 3, 2 + i) + bannerheight;
mvprintw(totalrow, 0, " TOTAL %-*.*s %-*.*s %11.3f %11.3f ",
proglen, proglen, "", devlen, devlen, "", sent_global, recv_global);
mvprintw(3 + 1 + i, cols - COLUMN_WIDTH_UNIT, "%s", desc_view_mode[viewMode]);
mvprintw(2 + i + bannerheight, cols - COLUMN_WIDTH_UNIT, "%s", desc_view_mode[viewMode]);
attroff(A_REVERSE);
mvprintw(totalrow + 1, 0, "%s", "");
refresh();
Expand Down
6 changes: 5 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static void help(bool iserror) {
output << " device : device(s) to monitor. default is all "
"interfaces up and running excluding loopback\n";
output << " -P : Show only processes.\n";
output << " -q : suppress banner\n";
output << std::endl;
output << "When nethogs is running, press:\n";
output << " q: quit\n";
Expand Down Expand Up @@ -153,7 +154,7 @@ int main(int argc, char **argv) {
int garbage_collection_period = 50;

int opt;
while ((opt = getopt(argc, argv, "Vhxtpsd:v:c:laf:Cbg:P:")) != -1) {
while ((opt = getopt(argc, argv, "Vhxtpsd:v:c:laf:Cbg:P:q")) != -1) {
switch (opt) {
case 'V':
versiondisplay();
Expand Down Expand Up @@ -204,6 +205,9 @@ int main(int argc, char **argv) {
case 'P':
pidsToWatch.insert((pid_t)atoi(optarg));
break;
case 'q':
suppressBanner = true;
break;
default:
help(true);
exit(EXIT_FAILURE);
Expand Down
1 change: 1 addition & 0 deletions src/nethogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ bool bughuntmode = false;
bool sortRecv = true;
bool showcommandline = false;
bool showBasename = false;
bool suppressBanner = false;
// viewMode: kb/s or total
int viewMode = VIEWMODE_KBPS;
const char version[] = " version " VERSION;
Expand Down