77 {
78
79 struct stat statbuf;
80 auto status = space_provider.get_stat(path_name.string().c_str(), &statbuf);
81 SYS_ASSERT(status == 0, chain::plugin_config_exception,
82 "Failed to run stat on ${path} with status ${status}", ("path", path_name.string())("status", status));
83
84 dlog(
"${path_name}'s file system to be monitored", (
"path_name", path_name.string()));
85
86
87
88 for (auto& fs: filesystems) {
89 if (statbuf.st_dev ==
fs.st_dev) {
90 dlog(
"${path_name}'s file system already monitored", (
"path_name", path_name.string()));
91
92 return;
93 }
94 }
95
96
97
98
99 boost::system::error_code ec;
100 auto info = space_provider.get_space(path_name, ec);
101 SYS_ASSERT(!ec, chain::plugin_config_exception,
102 "Unable to get space info for ${path_name}: [code: ${ec}] ${message}",
103 ("path_name", path_name.string())
104 ("ec", ec.value())
105 ("message", ec.message()));
106
107 auto shutdown_available = (100 - shutdown_threshold) * (info.capacity / 100);
108 auto warning_available = (100 - warning_threshold) * (info.capacity / 100);
109
110
111 filesystems.emplace_back(statbuf.st_dev, shutdown_available, path_name, warning_available);
112
113 ilog(
"${path_name}'s file system monitored. shutdown_available: ${shutdown_available}, capacity: ${capacity}, threshold: ${threshold}", (
"path_name", path_name.string()) (
"shutdown_available", shutdown_available) (
"capacity", info.capacity) (
"threshold", shutdown_threshold) );
114 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
static const Segment fs(Segment::fs)