Leosac  0.8.0
Open Source Access Control
MonitorModule.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
23 #include "modules/BaseModule.hpp"
24 
25 namespace Leosac
26 {
27 namespace Module
28 {
34 namespace Monitor
35 {
39 class MonitorModule : public BaseModule
40 {
41  public:
42  MonitorModule(zmqpp::context &ctx, zmqpp::socket *pipe,
43  const boost::property_tree::ptree &cfg, CoreUtilsPtr utils);
44 
45  MonitorModule(const MonitorModule &) = delete;
46 
47  MonitorModule(MonitorModule &&) = delete;
48 
49  MonitorModule &operator=(const MonitorModule &) = delete;
50 
52 
53  virtual void run() override;
54 
55  private:
56  using TimePoint = std::chrono::system_clock::time_point;
57 
58  void process_config();
59 
64 
68  void process_reader_config();
69 
73  std::string req_scripts_dir();
74 
79  void log_system_bus();
80 
81  void test_ping();
82 
83  zmqpp::socket bus_;
84 
85  bool verbose_;
86 
87  std::string addr_to_ping_;
88 
89  std::string reader_to_watch_;
90 
94  std::unique_ptr<Leosac::Hardware::FLED> network_led_;
95 
99  std::unique_ptr<Leosac::Hardware::FLED> reader_led_;
100 
104  std::unique_ptr<Leosac::Hardware::FLED> system_led_;
105 
107 
108  zmqpp::socket kernel_;
109 };
110 }
111 }
112 }
Leosac::Module::Monitor::MonitorModule::MonitorModule
MonitorModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
Definition: MonitorModule.cpp:36
Leosac::Module::Monitor::MonitorModule::reader_to_watch_
std::string reader_to_watch_
Definition: MonitorModule.hpp:89
Leosac::Module::Monitor::MonitorModule::run
virtual void run() override
This is the main loop of the module.
Definition: MonitorModule.cpp:52
Leosac::Module::Monitor::MonitorModule::process_config
void process_config()
Definition: MonitorModule.cpp:155
Leosac::Module::BaseModule
Base class for module implementation.
Definition: BaseModule.hpp:110
Leosac::Module::Monitor::MonitorModule::process_reader_config
void process_reader_config()
Load config related to reader activity monitoring.
Definition: MonitorModule.cpp:195
Leosac::Module::Monitor::MonitorModule::last_ping_
TimePoint last_ping_
Definition: MonitorModule.hpp:106
Leosac::Module::Monitor::MonitorModule::verbose_
bool verbose_
Definition: MonitorModule.hpp:85
BaseModule.hpp
Leosac::Module::Monitor::MonitorModule::reader_led_
std::unique_ptr< Leosac::Hardware::FLED > reader_led_
Led for feedback about reader activity.
Definition: MonitorModule.hpp:99
Leosac::Module::Monitor::MonitorModule::process_network_config
void process_network_config()
Load config related to network monitoring.
Definition: MonitorModule.cpp:183
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::Monitor::MonitorModule::network_led_
std::unique_ptr< Leosac::Hardware::FLED > network_led_
Led for feedback about network availability.
Definition: MonitorModule.hpp:94
Leosac::Module::Monitor::MonitorModule
Main class for the monitor module.
Definition: MonitorModule.hpp:39
Leosac::Module::Monitor::MonitorModule::test_ping
void test_ping()
Definition: MonitorModule.cpp:119
Leosac::Module::Monitor::MonitorModule::log_system_bus
void log_system_bus()
Called when a message arrives on the system bus and we are configured to log that.
Definition: MonitorModule.cpp:68
Leosac::Module::Monitor::MonitorModule::TimePoint
std::chrono::system_clock::time_point TimePoint
Definition: MonitorModule.hpp:56
Leosac::Module::Monitor::MonitorModule::system_led_
std::unique_ptr< Leosac::Hardware::FLED > system_led_
Led for feedback about system readiness.
Definition: MonitorModule.hpp:104
FLED.hpp
Leosac::Module::Monitor::MonitorModule::req_scripts_dir
std::string req_scripts_dir()
Get scripts directory from kernel.
Definition: MonitorModule.cpp:140
Leosac::Module::Monitor::MonitorModule::addr_to_ping_
std::string addr_to_ping_
Definition: MonitorModule.hpp:87
Leosac::Module::Monitor::MonitorModule::bus_
zmqpp::socket bus_
Definition: MonitorModule.hpp:83
Leosac::Module::Monitor::MonitorModule::operator=
MonitorModule & operator=(const MonitorModule &)=delete
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35
Leosac::Module::Monitor::MonitorModule::kernel_
zmqpp::socket kernel_
Definition: MonitorModule.hpp:108