/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef INCLUDED_ADMIN_HPP #define INCLUDED_ADMIN_HPP #include #include #include #include #include #include "AdminModel.hpp" const std::string FIFO_NOTIFY = "loolnotify.fifo"; /// An admin command processor. class Admin : public Poco::Runnable { public: Admin(const Poco::Process::PID brokerPid, const int brokerPipe, const int notifyPipe); ~Admin(); static int getBrokerPid() { return Admin::BrokerPid; } static int getBrokerPipe() { return Admin::BrokerPipe; } unsigned getTotalMemoryUsage(AdminModel&); void run() override; /// Callers must ensure that modelMutex is acquired AdminModel& getModel(); unsigned getMemStatsInterval(); unsigned getCpuStatsInterval(); void rescheduleMemTimer(unsigned interval); void rescheduleCpuTimer(unsigned interval); public: std::mutex modelMutex; private: void handleInput(std::string& message); private: Poco::Net::HTTPServer _srv; AdminModel _model; Poco::Util::Timer _memStatsTimer; Poco::Util::TimerTask::Ptr _memStatsTask; unsigned _memStatsTaskInterval = 5000; Poco::Util::Timer _cpuStatsTimer; Poco::Util::TimerTask::Ptr _cpuStatsTask; unsigned _cpuStatsTaskInterval = 5000; static Poco::Process::PID BrokerPid; static int BrokerPipe; static int NotifyPipe; }; class MemoryStats : public Poco::Util::TimerTask { public: MemoryStats(Admin* admin) : _admin(admin) { Log::info("Memory stat ctor"); } ~MemoryStats() { Log::info("Memory stat dtor"); } void run() override; private: Admin* _admin; }; class CpuStats : public Poco::Util::TimerTask { public: CpuStats(Admin* /*admin*/) { Log::info("Cpu stat ctor"); } ~CpuStats() { Log::info("Cpu stat dtor"); } void run() override; private: }; #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */