Changeset 1343 for trunk/pdns/pdns/ws.cc

Show
Ignore:
Timestamp:
03/29/09 23:34:17 (12 months ago)
Author:
ahu
Message:

finally finally get rid of 1e2% - apologies to Jeff Sipek for lying that this bug was fixed already :-)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/ws.cc

    r1303 r1343  
    105105  int printed=0; 
    106106  for(vector<pair<string,int> >::const_iterator i=ring.begin();limit && i!=ring.end();++i,--limit) { 
    107     ret<<"<tr><td>"<<i->first<<"</td><td>"<<i->second<<"</td><td align=right>"<< (boost::format("%.01f") % (i->second*100.0/tot))<<"%</td>"<<endl; 
     107    ret<<"<tr><td>"<<i->first<<"</td><td>"<<i->second<<"</td><td align=right>"<< StatWebServer::makePercentage(i->second*100.0/tot)<<"</td>"<<endl; 
    108108    printed+=i->second; 
    109109  } 
    110110  ret<<"<tr><td colspan=3></td></tr>"<<endl; 
    111111  if(printed!=tot) 
    112     ret<<"<tr><td><b>Rest:</b></td><td><b>"<<tot-printed<<"</b></td><td align=right><b>"<< (boost::format("%.01f") % ((tot-printed)*100.0/tot))<<"%</b></td>"<<endl; 
     112    ret<<"<tr><td><b>Rest:</b></td><td><b>"<<tot-printed<<"</b></td><td align=right><b>"<< StatWebServer::makePercentage((tot-printed)*100.0/tot)<<"</b></td>"<<endl; 
    113113 
    114114  ret<<"<tr><td><b>Total:</b></td><td><b>"<<tot<<"</td><td align=right><b>100%</b></td>"; 
     
    135135    ret<<"<tr><td>"<<*i<<"</td><td>"<<arg()[*i]<<"</td><td>"<<arg().getHelp(*i)<<"</td>"<<endl; 
    136136  } 
     137} 
     138 
     139string StatWebServer::makePercentage(const double& val) 
     140{ 
     141  return (boost::format("%.01f%%") % val).str(); 
    137142} 
    138143 
     
    179184   
    180185  if(sws->d_cachemisses.get10()+sws->d_cachehits.get10()>0) 
    181     ret<<"Cache hitrate, 1, 5, 10 minute averages: "<<setprecision(2)<< 
    182       (sws->d_cachehits.get1()*100.0)/((sws->d_cachehits.get1())+(sws->d_cachemisses.get1()))<<"%, "<< 
    183       (sws->d_cachehits.get5()*100.0)/((sws->d_cachehits.get5())+(sws->d_cachemisses.get5()))<<"%, "<< 
    184       (sws->d_cachehits.get10()*100.0)/((sws->d_cachehits.get10())+(sws->d_cachemisses.get10()))<< 
    185       "%<br>"<<endl; 
     186    ret<<"Cache hitrate, 1, 5, 10 minute averages: "<< 
     187      makePercentage((sws->d_cachehits.get1()*100.0)/((sws->d_cachehits.get1())+(sws->d_cachemisses.get1())))<<", "<< 
     188      makePercentage((sws->d_cachehits.get5()*100.0)/((sws->d_cachehits.get5())+(sws->d_cachemisses.get5())))<<", "<< 
     189      makePercentage((sws->d_cachehits.get10()*100.0)/((sws->d_cachehits.get10())+(sws->d_cachemisses.get10())))<< 
     190      "<br>"<<endl; 
    186191 
    187192  if(sws->d_qcachemisses.get10()+sws->d_qcachehits.get10()>0) 
    188193    ret<<"Backend query cache hitrate, 1, 5, 10 minute averages: "<<setprecision(2)<< 
    189       (sws->d_qcachehits.get1()*100.0)/((sws->d_qcachehits.get1())+(sws->d_qcachemisses.get1()))<<"%, "<< 
    190       (sws->d_qcachehits.get5()*100.0)/((sws->d_qcachehits.get5())+(sws->d_qcachemisses.get5()))<<"%, "<< 
    191       (sws->d_qcachehits.get10()*100.0)/((sws->d_qcachehits.get10())+(sws->d_qcachemisses.get10()))<< 
    192       "%<br>"<<endl; 
     194      makePercentage((sws->d_qcachehits.get1()*100.0)/((sws->d_qcachehits.get1())+(sws->d_qcachemisses.get1())))<<", "<< 
     195      makePercentage((sws->d_qcachehits.get5()*100.0)/((sws->d_qcachehits.get5())+(sws->d_qcachemisses.get5())))<<", "<< 
     196      makePercentage((sws->d_qcachehits.get10()*100.0)/((sws->d_qcachehits.get10())+(sws->d_qcachemisses.get10())))<< 
     197      "<br>"<<endl; 
    193198 
    194199  ret<<"Backend query load, 1, 5, 10 minute averages: "<<setprecision(3)<<