156
150
{ // needs to be created/updated
161
memset(&globbuf, 0, sizeof(glob_t));
162
glob((acfg::logdir+"/apt-cacher*.log").c_str(), GLOB_DOOFFS | GLOB_NOSORT,
165
//cout << "wo? " << (acfg::logdir+"/*.log.*").c_str() <<endl;
167
for (unsigned int i=0; i<globbuf.gl_pathc; i++)
154
tStrVec logs=ExpandFilePattern(acfg::logdir +
155
SZPATHSEP "apt-cacher*.log", false);
157
for (tStrVecIterConst it=logs.begin();it!=logs.end();it++)
170
cerr << "Reading log file: " << globbuf.gl_pathv[i] <<endl;
160
cerr << "Reading log file: " << *it <<endl;
171
161
filereader reader;
172
if (!reader.OpenFile(globbuf.gl_pathv[i]))
162
if (!reader.OpenFile(*it))
174
164
aclog::err("Error opening a log file");
255
string GetStatReport()
258
vector<char> buf(1024);
259
vector<aclog::tRowData> data;
260
aclog::GetStats(data);
261
for (vector<aclog::tRowData>::iterator it = data.begin(); it != data.end(); it++)
264
unsigned long reqMax = max(it->reqIn, it->reqOut);
265
uint64_t dataMax = max(it->byteIn, it->byteOut);
267
if (0 == dataMax || 0 == reqMax)
272
ctime_r(&it->from, tbuf);
273
struct tm *tmp = localtime(&it->from);
276
zlen = strftime(tbuf, sizeof(tbuf), TIMEFORMAT, tmp);
280
if (it->from != it->to)
282
tmp = localtime(&it->to);
285
if (0 == strftime(tbuf + zlen, sizeof(tbuf) - zlen,
286
" - " TIMEFORMAT, tmp))
289
snprintf(&buf[0], buf.size(), "<tr bgcolor=\"white\">"
291
"<td class=\"colcont\">%s</td>"
293
"<td class=\"coltitle\"><span> </span></td>"
295
"<td class=\"colcont\">%lu (%2.2f%%)</td>"
296
"<td class=\"colcont\">%lu (%2.2f%%)</td>"
297
"<td class=\"colcont\">%lu</td>"
299
"<td class=\"coltitle\"><span> </span></td>"
301
"<td class=\"colcont\">%2.2f MiB (%2.2f%%)</td>"
302
"<td class=\"colcont\">%2.2f MiB (%2.2f%%)</td>"
303
"<td class=\"colcont\">%2.2f MiB</td>"
304
"</tr>", tbuf, reqMax - it->reqIn, double(reqMax - it->reqIn)
305
/ reqMax * 100, // hitcount
306
it->reqIn, double(it->reqIn) / reqMax * 100, // misscount
309
double(dataMax - it->byteIn) / 1048576, double(dataMax
310
- it->byteIn) / dataMax * 100, // hitdata
311
double(it->byteIn) / 1048576, double(it->byteIn) / dataMax
313
double(dataMax) / 1048576
315
); //, int(it->ratioSent*nRatWid), int((1.0-it->ratioSent)*nRatWid));
319
+= " Invalid time value detected, check the stats database. ";
266
325
errnoFmter::errnoFmter()