add ports relay is listening on to http display

This commit is contained in:
ehouse 2009-12-16 02:43:52 +00:00
parent da6a8eb2f0
commit a1be2fb8fc
3 changed files with 24 additions and 3 deletions

View file

@ -229,6 +229,25 @@ CRefMgr::GetStats( CrefMgrInfo& mgrInfo )
mgrInfo.m_nCrefsAll = GetNumGamesSeen();
mgrInfo.m_startTimeSpawn = m_startTime;
if ( 0 == m_ports.length() ) {
RelayConfigs* cfg = RelayConfigs::GetConfigs();
vector<int> ints;
if ( cfg->GetValueFor( "PORTS", ints ) ) {
vector<int>::const_iterator iter;
for ( iter = ints.begin(); ; ) {
char buf[8];
snprintf( buf, sizeof(buf), "%d", *iter );
m_ports += buf;
++iter;
if ( iter == ints.end() ) {
break;
}
m_ports += ",";
}
}
}
mgrInfo.m_ports = m_ports.c_str();
RWReadLock rwl( &m_cookieMapRWLock );
mgrInfo.m_nCrefsCurrent = m_cookieMap.size();

View file

@ -62,6 +62,7 @@ class CrefInfo {
class CrefMgrInfo {
public:
const char* m_ports;
int m_nCrefsAll;
int m_nCrefsCurrent;
time_t m_startTimeSpawn;
@ -159,6 +160,7 @@ class CRefMgr {
SocketMap m_SocketStuff;
time_t m_startTime;
string m_ports;
friend class CookieMapIterator;
}; /* CRefMgr */

View file

@ -188,11 +188,11 @@ printStats( FILE* fil, const CrefMgrInfo* info, bool isLocal )
fprintf( fil, "<div class=\"header\">Stats</div>" );
fprintf( fil, "<table>" );
fprintf( fil, "<tr>"
"<th>Uptime</th><th>Spawns</th><th>Spawn Utime</th>"
"<th>Ports</th><th>Uptime</th><th>Spawns</th><th>Spawn Utime</th>"
"<th>Games played</th><th>Games in play</th></tr>" );
fprintf( fil, "<tr><td>%s</td><td>%d</td>"
fprintf( fil, "<tr><td>%s</td><td>%s</td><td>%d</td>"
"<td>%s</td><td>%d</td><td>%d</td></tr>\n",
uptime1, GetNSpawns(), uptime2, info->m_nCrefsAll,
info->m_ports, uptime1, GetNSpawns(), uptime2, info->m_nCrefsAll,
info->m_nCrefsCurrent );
fprintf( fil, "</table>" );
}