Leosac  0.7.0
OpenSourceAccessControl
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 }
MonitorModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
MonitorModule & operator=(const MonitorModule &)=delete
This is the header file for a generated source file, GitSHA1.cpp.
virtual void run() override
This is the main loop of the module.
void process_network_config()
Load config related to network monitoring.
std::unique_ptr< Leosac::Hardware::FLED > network_led_
Led for feedback about network availability.
std::string req_scripts_dir()
Get scripts directory from kernel.
Base class for module implementation.
Definition: BaseModule.hpp:110
std::chrono::system_clock::time_point TimePoint
void log_system_bus()
Called when a message arrives on the system bus and we are configured to log that.
std::unique_ptr< Leosac::Hardware::FLED > reader_led_
Led for feedback about reader activity.
Main class for the monitor module.
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35
std::unique_ptr< Leosac::Hardware::FLED > system_led_
Led for feedback about system readiness.
void process_reader_config()
Load config related to reader activity monitoring.