7c33392001-09-27Martin Nilsson // Locale stuff. // <locale-token project="roxen_config"> _ </locale-token>
d6a8312001-01-01Martin Nilsson #include <roxen.h> #define _(X,Y) _DEF_LOCALE("roxen_config",X,Y) constant box = "large";
aaaf422002-05-02Jonas Wallden constant box_initial = 1;
d6a8312001-01-01Martin Nilsson 
2ecde22003-01-15Henrik Grubbström (Grubba) LocaleString box_name = _(367,"Server status"); LocaleString box_doc = _(368,"Various global server statistics");
d6a8312001-01-01Martin Nilsson  string add_row( string item, string value ) {
2b73ed2017-05-29Pontus Östlund  return "<tr>" "<th style='width:25%'>" + item + "</th>" "<td>" + value + "</td>" "</tr>";
d6a8312001-01-01Martin Nilsson } string parse( RequestID id ) { int dt = (time() - roxen->start_time+1); string contents = "";
9d4d592001-01-01Martin Nilsson  contents += add_row( _(369, "Server started"),
d6a8312001-01-01Martin Nilsson  Roxen.strftime( "%Y-%m-%d %H:%M:%S", roxen->start_time) );
9d4d592001-01-01Martin Nilsson  contents += add_row( _(370, "Server uptime"),
d6a8312001-01-01Martin Nilsson  Roxen.msectos( dt*1000 ));
fc8ffc2017-05-23Pontus Östlund 
57eb122014-10-04Jonas Walldén  mapping(string:int) ru; if(!catch(ru = System.getrusage())) {
d6a8312001-01-01Martin Nilsson  int tmp;
57eb122014-10-04Jonas Walldén  if (ru->utime) tmp = ru->utime / (time() - roxen->start_time + 1);
9d4d592001-01-01Martin Nilsson  contents += add_row( _(371, "CPU-time used"),
57eb122014-10-04Jonas Walldén  Roxen.msectos(ru->utime + ru->stime) +
d6a8312001-01-01Martin Nilsson  (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; }
9d4d592001-01-01Martin Nilsson  contents += add_row( _(2,"Sent data"), Roxen.sizetostring(total->sent) +
d6a8312001-01-01Martin Nilsson  sprintf(" (%.2f kbit/%s)", ((((float)total->sent)/(1024.0*1024.0)/dt) * 8192.0), _(3,"sec")) );
9d4d592001-01-01Martin Nilsson  contents += add_row( _(4,"Sent headers"), Roxen.sizetostring(total->hsent)); contents += add_row( _(234,"Requests"), total->requests +
d6a8312001-01-01Martin Nilsson  sprintf(" (%.2f/%s)", (((float)total->requests*60.0)/dt), _(6,"min")) );
eb4dd82001-10-08Per Hedbor  contents += add_row( _(7,"Received data"), Roxen.sizetostring(total->received));
d6a8312001-01-01Martin Nilsson 
f2df472010-11-18Martin Jonsson #if constant(System.getloadavg)
6a32272011-12-21Jonas Wallden  contents += add_row( _(1060, "System load"),
f2df472010-11-18Martin Jonsson  sprintf ("%{%.2f %}", System.getloadavg())); #endif
2b73ed2017-05-29Pontus Östlund  return "<cbox type='"+box+"' title='"+box_name+"'>" "<div class='negative-wrapper'>" "<table class='nice'>" + contents+"</table>" "</div></cbox>";
d6a8312001-01-01Martin Nilsson }