stats_exporter: Refactor and add docstrings to export script
This:
- refactor a bit into multiple functions with docstrings.
- simplify the data computation
- prepare the code to make it parametric
In another step, we could thus improve to make the script parametric. Have it
use server, port, object type data to graph etc... as input so that the cron
explicit those (from puppet manifest's).