X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fmetricsserver.h;fp=src%2Fcore%2Fmetricsserver.h;h=1d268335066a5c01ad99da106fa5b0ab326b3f18;hp=0000000000000000000000000000000000000000;hb=8f92b3f08df9f4eb8fd243ccec6aa9d4b563ec23;hpb=dc0cc8130d64a74df07a133bc1cc457ab12bb7a0 diff --git a/src/core/metricsserver.h b/src/core/metricsserver.h new file mode 100644 index 00000000..1d268335 --- /dev/null +++ b/src/core/metricsserver.h @@ -0,0 +1,86 @@ +/*************************************************************************** + * Copyright (C) 2005-2019 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#pragma once + +#include +#include +#include +#include + +#include "coreidentity.h" + +class MetricsServer : public QObject +{ + Q_OBJECT + +public: + explicit MetricsServer(QObject* parent = nullptr); + + bool startListening(); + void stopListening(const QString& msg); + + void addLoginAttempt(UserId user, bool successful); + void addLoginAttempt(const QString& user, bool successful); + + void addSession(UserId user, const QString& name); + void removeSession(UserId user); + + void addClient(UserId user); + void removeClient(UserId user); + + void addNetwork(UserId user); + void removeNetwork(UserId user); + + void transmitDataNetwork(UserId user, uint64_t size); + void receiveDataNetwork(UserId user, uint64_t size); + + void loginSuccessful(); + void loginFailed(); + + void messageQueue(UserId user, uint64_t size); + + void setCertificateExpires(QDateTime expires); + +private slots: + void incomingConnection(); + void respond(); + +private: + QTcpServer _server, _v6server; + + QHash _loginAttempts{}; + QHash _successfulLogins{}; + + QHash _sessions{}; + + QHash _clientSessions{}; + QHash _networkSessions{}; + + QHash _networkDataTransmit{}; + QHash _networkDataReceive{}; + + QHash _messageQueue{}; + + uint64_t _loginSuccessful{}; + uint64_t _loginFailed{}; + + QDateTime _certificateExpires{}; +};