Files

143 lines
4.7 KiB
C++

/**
* @file include/ActivMiddleware/ActivAgentApplication/MonitorService.h
*
* @brief Header file for the monitor service class.
*/
#if (!defined ACTIV_AGENT_APPLICATION_MONITOR_SERVICE_H)
#define ACTIV_AGENT_APPLICATION_MONITOR_SERVICE_H
#include "ActivMiddleware/ActivAgentApplication/External.h"
#include ACTIV_BOOST_INCLUDE(scoped_ptr.hpp)
//! Activ namespace.
namespace Activ
{
/**
* @brief Monitor service class.
*/
class MonitorService : private ManagedEndPoint, public Component
{
public:
using Component::GetApplication;
/**
* @brief Settings.
*/
class Settings
{
public:
/**
* @brief System monitor modes.
*/
enum SystemMonitorMode
{
SYSTEM_MONITOR_MODE_OFF, ///< Disable system monitor.
SYSTEM_MONITOR_MODE_ON, ///< Enable system monitor.
SYSTEM_MONITOR_MODE_ON_WITH_LOG ///< Enable system monitor & generate log file.
};
/**
* @brief Default constructor.
*/
ACTIV_AGENT_APPLICATION_API Settings();
/**
* @brief Destructor.
*/
ACTIV_AGENT_APPLICATION_API ~Settings();
/**
* @brief Read settings from an ini file section.
*
* @param sectionIterator iterator to an ini file section.
*
* @throw Exception
*/
ACTIV_AGENT_APPLICATION_API void Read(const IniFileParser::ConstSectionIterator &sectionIterator);
IHeap::Settings m_heapSettings; ///< Properties of heap to create for monitor service.
ManagedEndPoint::Settings m_managedEndPointSettings; ///< ManagedEndPoint settings for the main thread.
ManagedEndPoint::Settings m_pingerManagedEndPointSettings; ///< ManagedEndPoint settings for the pinger thread.
std::vector<String> m_diskMonitorList; ///< List of disks to monitor (default is disk containing working directory).
SystemMonitorMode m_systemMonitorMode; ///< Default: SYSTEM_MONITOR_MODE_ON.
bool m_enableHeapStatsLog; ///< Default: false.
bool m_enableDetailedHeapStatsLog; ///< Default: false. If true the heap stats log file will include bucket level stats.
bool m_enableEndPointStatsLog; ///< Default: false.
size_t m_systemStatsTimerInterval; ///< Default: 1000ms. How often to generate system / process stats.
size_t m_statsTimer; ///< Default: 5000ms. How often to generate endpoint / heap stats.
size_t m_threadStatsMonitorTimerInterval; ///< Default: 10000ms. How often to generate ThreadStatsMessages.
size_t m_endPointPingTimer; ///< Default: 2ms. Timer for dispatching endpoint pings which are sent in groups to cut down cpu spiking.
size_t m_endPointPingInterval; ///< Default: 50ms. How often to ping endpoints, in ms.
size_t m_endPointListUpdateInterval; ///< Default: 1000ms. How often to update the list of endpoint being pinged in ms.
size_t m_numberOfLogBackups; ///< Default: 40. Previous days logs to keep.
byte_t m_heapFreePublishPercent; ///< Default: 25. % free messages at which to publish heap stats.
byte_t m_totalHeapSizeAlertThresholdPercent; ///< Default: 88. 0 to disable. Generate an alert if total heap size / physical memory is greater than this threshold.
};
/**
* @brief Monitor service ui component.
*/
class UiComponent ACTIV_FINAL : public Activ::UiComponent
{
public:
/**
* @brief Constructor.
*
* @param monitorService the monitor service to have the ui.
* @param uiServiceName name of the ui service.
*
* @throw Exception.
*/
ACTIV_AGENT_APPLICATION_API UiComponent(MonitorService &monitorService, const String &uiServiceName);
private:
virtual void Run(UiUser &uiUser) ACTIV_OVERRIDE;
MonitorService & m_monitorService;
// Last member.
Component::Enabler m_componentEnabler;
};
/**
* @brief Constructor.
*
* @param application the application the service will be linked to.
* @param serviceName name of the service.
* @param settings settings for the service.
*
* @throw Exception.
*/
ACTIV_AGENT_APPLICATION_API MonitorService(Application &application, const String &serviceName, const Settings &settings);
/**
* @brief Destructor.
*/
ACTIV_AGENT_APPLICATION_API ~MonitorService();
/**
* @brief Get the number of processes being monitored.
*
* @return The number of processes.
*/
ACTIV_AGENT_APPLICATION_API size_t GetNumberOfProcesses() const;
protected:
ACTIV_AGENT_APPLICATION_API virtual StatusCode OnMessage(HeapMessage &message) ACTIV_OVERRIDE;
ACTIV_AGENT_APPLICATION_API virtual StatusCode OnRequest(HeapMessage &request) ACTIV_OVERRIDE;
ACTIV_AGENT_APPLICATION_API virtual StatusCode OnTimer(const Address &timerAddress, const DateTime &dateTime) ACTIV_OVERRIDE;
private:
class Impl;
Boost::scoped_ptr<Impl> m_pImpl;
};
} // namespace Activ
#endif // (!defined ACTIV_AGENT_APPLICATION_MONITOR_SERVICE_H)