Scorum
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
node_monitoring_api.cpp
Go to the documentation of this file.
3 
4 namespace scorum {
5 namespace blockchain_monitoring {
6 
7 namespace detail {
9 {
10 
11 public:
13 
14 public:
16  : _app(app)
17  {
18  }
19 
20  std::shared_ptr<blockchain_monitoring_plugin> get_plugin() const
21  {
23 
24  FC_ASSERT(plugin, "Cann't get " BLOCKCHAIN_MONITORING_PLUGIN_NAME " plugin from application.");
25 
26  return plugin;
27  }
28 };
29 } // namespace detail
30 
32 {
33  _my = std::make_shared<detail::node_monitoring_api_impl>(ctx.app);
34 }
35 
37 {
38 }
39 
41 {
42  return _my->_app.chain_database()->with_read_lock(
43  [&]() { return _my->get_plugin()->get_last_block_duration_microseconds(); });
44 }
45 
47 {
48  return _my->_app.chain_database()->with_read_lock(
49  [&]() { return uint32_t(_my->_app.chain_database()->get_free_memory() / (1024 * 1024)); });
50 }
52 {
53  return _my->_app.chain_database()->with_read_lock(
54  [&]() { return uint32_t(_my->_app.chain_database()->get_size() / (1024 * 1024)); });
55 }
56 
57 } // namespace blockchain_monitoring
58 } // namespace scorum
#define BLOCKCHAIN_MONITORING_PLUGIN_NAME
std::shared_ptr< abstract_plugin > get_plugin(const std::string &name) const
std::shared_ptr< blockchain_monitoring_plugin > get_plugin() const
node_monitoring_api(const scorum::app::api_context &ctx)
uint32_t get_last_block_duration_microseconds() const
Returns last block processing duration in microseconds.
Definition: asset.cpp:15