Merge pull request #133 from jantman/issues/130-process-changes-only

issue #130 - have Process::gettotal include closed connections removed from ConnList
This commit is contained in:
Arnout Engelen
2017-08-27 13:22:57 +02:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -102,6 +102,9 @@ void Process::getkbps(float *recvd, float *sent) {
ConnList *previous = NULL; ConnList *previous = NULL;
while (curconn != NULL) { while (curconn != NULL) {
if (curconn->getVal()->getLastPacket() <= curtime.tv_sec - CONNTIMEOUT) { if (curconn->getVal()->getLastPacket() <= curtime.tv_sec - CONNTIMEOUT) {
/* capture sent and received totals before deleting */
this->sent_by_closed_bytes += curconn->getVal()->sumSent;
this->rcvd_by_closed_bytes += curconn->getVal()->sumRecv;
/* stalled connection, remove. */ /* stalled connection, remove. */
ConnList *todelete = curconn; ConnList *todelete = curconn;
Connection *conn_todelete = curconn->getVal(); Connection *conn_todelete = curconn->getVal();
@@ -137,8 +140,8 @@ void Process::gettotal(u_int32_t *recvd, u_int32_t *sent) {
} }
// std::cout << "Sum sent: " << sum_sent << std::endl; // std::cout << "Sum sent: " << sum_sent << std::endl;
// std::cout << "Sum recv: " << sum_recv << std::endl; // std::cout << "Sum recv: " << sum_recv << std::endl;
*recvd = sum_recv; *recvd = sum_recv + this->rcvd_by_closed_bytes;
*sent = sum_sent; *sent = sum_sent + this->sent_by_closed_bytes;
} }
void Process::gettotalmb(float *recvd, float *sent) { void Process::gettotalmb(float *recvd, float *sent) {

View File

@@ -78,6 +78,8 @@ public:
connections = NULL; connections = NULL;
pid = 0; pid = 0;
uid = 0; uid = 0;
sent_by_closed_bytes = 0;
rcvd_by_closed_bytes = 0;
} }
void check() { assert(pid >= 0); } void check() { assert(pid >= 0); }
@@ -99,6 +101,8 @@ public:
char *cmdline; char *cmdline;
const char *devicename; const char *devicename;
int pid; int pid;
u_int32_t sent_by_closed_bytes;
u_int32_t rcvd_by_closed_bytes;
ConnList *connections; ConnList *connections;
uid_t getUid() { return uid; } uid_t getUid() { return uid; }