#785209 apt-cacher-ng: provide a switch to retrieve stats information

Package:
apt-cacher-ng
Source:
apt-cacher-ng
Description:
caching proxy server for software repositories
Submitter:
Sandro Tosi
Date:
2015-05-18 15:09:11 UTC
Severity:
wishlist
#785209#5
Date:
2015-05-13 13:56:56 UTC
From:
To:
Hello,
it would be nice if apt-cacher-ng had a cli switch to output the statistical
information which currently only lives in the html output of report.html. It
seems like that html page is just a "template" and some information are
replacedby a-c-ng when it parses it, but if you want to graph those info the
only solution at this time is parsing the html output, which is .. well
suboptimal :)

Bonus point if the cli switch will output those info in an easily parsable
manner, like YAML, JSON or other formats

Regards,
Sandro

#785209#10
Date:
2015-05-13 15:56:29 UTC
From:
To:
another point I forgot to mention it's that it would be even nicer if
the stats could be generated for a "static" timeframe, like from today
@ 00:00 up until I run the command, or last 5 minutes or so, else
graphing them or correlate previous values would be difficult.

Regards,

#785209#15
Date:
2015-05-15 13:48:36 UTC
From:
To:
Hallo,
* Sandro Tosi [Wed, May 13 2015, 09:56:56AM]:

Not sure I want to provide a CLI interface (probably not). The current
way is retrieving a special URL (see cron job script, you can also
encode parameters from the webui and admin credentials into that URL.
wget -qO- is your friend, IMHO).

Apart from that, here is sample output. Are we happy?

{
   "assignedSpace": {
      "debrep/dists/unstable/InRelease": 150471450,
      "debrep/dists/unstable/main/binary-amd64/Packages": 36001368,
      "debrep/dists/unstable/main/binary-amd64/Packages.diff/Index": 2260432,
      "debrep/dists/unstable/main/binary-amd64/Packages.xz": 7198500,
      "debrep/dists/unstable/main/binary-i386/Packages": 35943083,
      "debrep/dists/unstable/main/binary-i386/Packages.diff/Index": 7876,
      "debrep/dists/unstable/main/binary-i386/Packages.xz": 7197644,
      "debrep/dists/unstable/main/i18n/Translation-en.diff/Index": 108235,
      "debrep/dists/unstable/main/source/Sources": 36760788,
      "debrep/dists/unstable/main/source/Sources.diff/Index": 7876,
      "debrep/dists/unstable/main/source/Sources.gz": 9739685,
      "debrep/dists/unstable/main/source/Sources.xz": 7814020
   },
   "total": 293510957
}

Regards,
Eduard.

#785209#20
Date:
2015-05-15 14:24:37 UTC
From:
To:
Hi Eduard,

I was just thinking of a apt-cacher-ng --stats to get the same output
on the command line (easy to script?), but if it's simple for you to
expose that as a URL that's fine as well; my aim is to avoid to parse
the webpage as we have to do now :)

the only cronjob I can found is the expire-caller.pl , are you
referring to this one?

I'm not sure what those info mean :( I Was expecting something on the line of:

2015-05-14 09:56 - 2015-05-15 09:56 248 (31.08%)550 (68.92%)798 0.03
MiB (16.49%)0.16 MiB (83.51%)0.19 MiB

(request hits/misses + percentage, total reqs date hits/misses +
percentage, total traffic) but without the unconventional data
aggregation (now it takes the exact moment of the web page request and
goes back 1 day - and so on - and that makes impossible to use the
info on the webpage to graph the cache usage, as the information keeps
rolling), so something like every day an entry with the previous days
information static and the only one changing is the current day, all

Cheers,

#785209#25
Date:
2015-05-15 15:07:55 UTC
From:
To:
Hallo,
* Sandro Tosi [Fri, May 15 2015, 10:24:37AM]:
...

Ah, now I see what you wanted... I should have read your second mail to the end.
For me, "the stats" are the ones that are displayed at the end of index
stuff processing.

The other "stats" are actually a cheap hack. apt-cacher.log contains
the incoming/outgoing data counts and those are counted together,
eventually grouped in ranges based on time stamps for
the last hour, 24hours, week, etc..

I guess this can be implemented in the same way with a dozen lines of
perl code, or I could rip out the calculating code and make it reusable,
providing an external tool.

I guess I will try that soon.

Regards,
Eduard.

#785209#30
Date:
2015-05-18 15:03:47 UTC
From:
To:
gotcha, but maybe some information also about the size of the cache
itself would be useful (split per source? just the total size? dunno)

also consider a more "consistent" output: last 24h is what we have on
the acng report page and it creates a "rolling" stat info as it
depends on when the command is executed; a report of every day from
00:00:00 to 23:59:59 would be awesome

awesome, thanks!