d6a8312001-01-01Martin Nilsson  constant box = "large";
aaaf422002-05-02Jonas Wallden constant box_initial = 1;
d6a8312001-01-01Martin Nilsson 
683a342002-06-14Martin Nilsson constant box_name = "Server status"; constant box_doc = "Various global server statistics";
d6a8312001-01-01Martin Nilsson  string add_row( string item, string value ) { return "<tr><td>" + item + ":</td><td>" + value + "</td></tr>"; } string parse( RequestID id ) { int dt = (time() - roxen->start_time+1); string contents = "";
683a342002-06-14Martin Nilsson  contents += add_row( "Server started",
d6a8312001-01-01Martin Nilsson  Roxen.strftime( "%Y-%m-%d %H:%M:%S", roxen->start_time) );
683a342002-06-14Martin Nilsson  contents += add_row( "Server uptime",
d6a8312001-01-01Martin Nilsson  Roxen.msectos( dt*1000 )); array ru; if(!catch(ru=rusage())) { int tmp; if(ru[0]) tmp = ru[0]/(time() - roxen->start_time+1);
683a342002-06-14Martin Nilsson  contents += add_row( "CPU-time used",
d6a8312001-01-01Martin Nilsson  Roxen.msectos(ru[0]+ru[1]) + (tmp?(" ("+tmp/10+"."+tmp%10+"%)"):"")); } mapping total = ([]); foreach(roxen->configurations, Configuration conf) { if(!conf->sent || !conf->received || !conf->hsent) continue; total->sent += conf->sent; total->hsent += conf->hsent; total->received += conf->received; total->requests += conf->requests; }
683a342002-06-14Martin Nilsson  contents += add_row( "Sent data", Roxen.sizetostring(total->sent) + sprintf(" (%.2f kbit/sec)", ((((float)total->sent)/(1024.0*1024.0)/dt) * 8192.0)) ); contents += add_row( "Sent headers", Roxen.sizetostring(total->hsent)); contents += add_row( "Requests", total->requests + sprintf(" (%.2f/min)", (((float)total->requests*60.0)/dt)) ); contents += add_row( "Received data", Roxen.sizetostring(total->received));
d6a8312001-01-01Martin Nilsson 
9d4d592001-01-01Martin Nilsson  return ("<box type='"+box+"' title='"+box_name+"'><table cellpadding='0'>"+ contents+"</table></box>");
d6a8312001-01-01Martin Nilsson }