Stats fixes
This commit is contained in:
parent
89374e4038
commit
ff0b03b01a
1 changed files with 21 additions and 11 deletions
|
@ -327,6 +327,7 @@ void Controller::SharedMemStats(void * config){
|
|||
std::set<std::string> inactiveStreams;
|
||||
Controller::initState();
|
||||
bool shiftWrites = true;
|
||||
bool firstRun = true;
|
||||
while(((Util::Config*)config)->is_active){
|
||||
{
|
||||
tthread::lock_guard<tthread::mutex> guard(Controller::configMutex);
|
||||
|
@ -334,6 +335,17 @@ void Controller::SharedMemStats(void * config){
|
|||
cacheLock->wait(); /*LTS*/
|
||||
//parse current users
|
||||
statServer.parseEach(parseStatistics);
|
||||
if (firstRun){
|
||||
firstRun = false;
|
||||
servUpOtherBytes = 0;
|
||||
servDownOtherBytes = 0;
|
||||
servUpBytes = 0;
|
||||
servDownBytes = 0;
|
||||
for (std::map<std::string, struct streamTotals>::iterator it = streamStats.begin(); it != streamStats.end(); ++it){
|
||||
it->second.upBytes = 0;
|
||||
it->second.downBytes = 0;
|
||||
}
|
||||
}
|
||||
//wipe old statistics
|
||||
if (sessions.size()){
|
||||
std::list<sessIndex> mustWipe;
|
||||
|
@ -580,9 +592,9 @@ void Controller::statSession::update(unsigned long index, IPC::statExchange & da
|
|||
servDownBytes += currDown - prevDown;
|
||||
}
|
||||
}
|
||||
if (currDown + currUp > COUNTABLE_BYTES){
|
||||
if (currDown + currUp >= COUNTABLE_BYTES){
|
||||
std::string streamName = data.streamName();
|
||||
if (prevUp + prevDown < COUNTABLE_BYTES){
|
||||
if (sessionType == SESS_UNSET){
|
||||
if (data.connector() == "INPUT"){
|
||||
++servInputs;
|
||||
streamStats[streamName].inputs++;
|
||||
|
@ -599,6 +611,10 @@ void Controller::statSession::update(unsigned long index, IPC::statExchange & da
|
|||
streamStats[streamName].currViews++;
|
||||
sessionType = SESS_VIEWER;
|
||||
}
|
||||
}
|
||||
//If previous < COUNTABLE_BYTES, we haven't counted any data so far.
|
||||
//We need to count all the data in that case, otherwise we only count the difference.
|
||||
if (prevUp + prevDown < COUNTABLE_BYTES){
|
||||
if (!streamName.size() || streamName[0] == 0){
|
||||
if (streamStats.count(streamName)){streamStats.erase(streamName);}
|
||||
}else{
|
||||
|
@ -612,15 +628,6 @@ void Controller::statSession::update(unsigned long index, IPC::statExchange & da
|
|||
streamStats[streamName].upBytes += currUp - prevUp;
|
||||
streamStats[streamName].downBytes += currDown - prevDown;
|
||||
}
|
||||
if (sessionType == SESS_UNSET){
|
||||
if (data.connector() == "INPUT"){
|
||||
sessionType = SESS_INPUT;
|
||||
}else if (data.connector() == "OUTPUT"){
|
||||
sessionType = SESS_OUTPUT;
|
||||
}else{
|
||||
sessionType = SESS_VIEWER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -730,6 +737,7 @@ void Controller::statSession::ping(const Controller::sessIndex & index, unsigned
|
|||
wipedUp = 0;
|
||||
wipedDown = 0;
|
||||
oldConns.clear();
|
||||
sessionType = SESS_UNSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1615,6 +1623,7 @@ void Controller::handlePrometheus(HTTP::Parser & H, Socket::Connection & conn, i
|
|||
for (std::map<sessIndex, statSession>::iterator it = sessions.begin(); it != sessions.end(); it++){
|
||||
switch (it->second.getSessType()){
|
||||
case SESS_UNSET:
|
||||
break;
|
||||
case SESS_VIEWER:
|
||||
if (it->second.hasDataFor(tOut) && it->second.isViewerOn(tOut)){
|
||||
outputs[it->first.connector]++;
|
||||
|
@ -1702,6 +1711,7 @@ void Controller::handlePrometheus(HTTP::Parser & H, Socket::Connection & conn, i
|
|||
for (std::map<sessIndex, statSession>::iterator it = sessions.begin(); it != sessions.end(); it++){
|
||||
switch (it->second.getSessType()){
|
||||
case SESS_UNSET:
|
||||
break;
|
||||
case SESS_VIEWER:
|
||||
if (it->second.hasDataFor(tOut) && it->second.isViewerOn(tOut)){
|
||||
outputs[it->first.connector]++;
|
||||
|
|
Loading…
Add table
Reference in a new issue