#pragma once #include "server.hpp" #include "receiver.hpp" #include "cmix.pb.h" #include #include /*! * \file */ /*! * \brief The Stats class A daemon that receives statistics on a socket and writes it to CSV. */ class Stats { boost::asio::io_service& io_service; Server server; std::list connections; typedef std::vector Column; typedef std::map Table; typedef std::map Tables; Tables data; void accept_connection(std::unique_ptr&& socket); void handle_performance(std::list::iterator it, cmix_proto::Performance perf); void handle_message(std::list::iterator it, cmix_proto::CMixMessage message); public: /*! * \brief Stats The statsd server to be created. * \param io_service The io_service it will run under. * \param lsettings The listen_settings that it will use. */ Stats(boost::asio::io_service& io_service, ListenSettings lsettings); /*! * \brief run Stars the stats daemon, Does not return unless the io_service ends. */ void run(); /*! * \brief output Writes the data to file. * \param file The filename to write it to. */ void output(std::string file); };