Add BPS viewMode
This commit is contained in:
@@ -41,7 +41,7 @@ bughunt mode - implies tracemode.
|
||||
delay for update refresh rate in seconds. default is 1.
|
||||
.TP
|
||||
\fB-v\fP
|
||||
view mode (0 = kB/s, 1 = total kB, 2 = total bytes, 3 = total MB, 4 = MB/s, 5 = GB/s). default is 0.
|
||||
view mode (0 = kB/s, 1 = total kB, 2 = total bytes, 3 = total MB, 4 = MB/s, 5 = GB/s, 6 = B/s). default is 0.
|
||||
|
||||
kB: 2e10 bytes, MB: 2e20 bytes, GB: 2e30 bytes
|
||||
.TP
|
||||
|
||||
@@ -70,7 +70,7 @@ const char *COLUMN_FORMAT_RECEIVED = "%11.3f";
|
||||
|
||||
// All descriptions are padded to 6 characters in length with spaces
|
||||
const char *const desc_view_mode[VIEWMODE_COUNT] = {
|
||||
"kB/s ", "kB ", "bytes ", "MB ", "MB/s ", "GB/s "};
|
||||
"kB/s ", "kB ", "bytes ", "MB ", "MB/s ", "GB/s ", "B/s "};
|
||||
|
||||
constexpr char FILE_SEPARATOR = '/';
|
||||
|
||||
@@ -503,6 +503,8 @@ void do_refresh() {
|
||||
curproc->getVal()->gettotalmb(&value_recv, &value_sent);
|
||||
} else if (viewMode == VIEWMODE_TOTAL_B) {
|
||||
curproc->getVal()->gettotalb(&value_recv, &value_sent);
|
||||
} else if (viewMode == VIEWMODE_BPS) {
|
||||
curproc->getVal()->getbps(&value_recv, &value_sent);
|
||||
} else {
|
||||
forceExit(false, "Invalid viewMode: %d", viewMode);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ static void help(bool iserror) {
|
||||
output << " -d : delay for update refresh rate in seconds. default "
|
||||
"is 1.\n";
|
||||
output << " -v : view mode (0 = kB/s, 1 = total kB, 2 = "
|
||||
"total bytes, 3 = total MB, 4 = MB/s, 5 = GB/s). default is 0.\n";
|
||||
"total bytes, 3 = total MB, 4 = MB/s, 5 = GB/s, 6 = B/s). default is 0.\n";
|
||||
output << " -c : number of updates. default is 0 (unlimited).\n";
|
||||
output << " -t : tracemode.\n";
|
||||
// output << " -f : format of packets on interface, default is
|
||||
|
||||
@@ -70,6 +70,7 @@ enum {
|
||||
VIEWMODE_TOTAL_MB,
|
||||
VIEWMODE_MBPS,
|
||||
VIEWMODE_GBPS,
|
||||
VIEWMODE_BPS,
|
||||
VIEWMODE_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -127,6 +127,16 @@ static void sum_active_connections(Process *process_ptr, u_int64_t &sum_sent,
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the b/s values for this process */
|
||||
void Process::getbps(float *recvd, float *sent) {
|
||||
u_int64_t sum_sent = 0, sum_recv = 0;
|
||||
|
||||
sum_active_connections(this, sum_sent, sum_recv);
|
||||
*recvd = sum_recv;
|
||||
*sent = sum_sent;
|
||||
}
|
||||
|
||||
|
||||
/** Get the kb/s values for this process */
|
||||
void Process::getkbps(float *recvd, float *sent) {
|
||||
u_int64_t sum_sent = 0, sum_recv = 0;
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
int getLastPacket();
|
||||
|
||||
void gettotal(u_int64_t *recvd, u_int64_t *sent);
|
||||
void getbps(float *recvd, float *sent);
|
||||
void getkbps(float *recvd, float *sent);
|
||||
void getmbps(float *recvd, float *sent);
|
||||
void getgbps(float *recvd, float *sent);
|
||||
|
||||
Reference in New Issue
Block a user