X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=disk_space_estimator.cpp;h=a1961057dc79257f4e1ecdebce95306f803ec507;hb=1836dccf699779d9092a75755cec96cea1734a2a;hp=cacc8117ac5a8e324453ff86dcdb988c5ae0da99;hpb=cf7b9ee186d4ef8e5da0531b75854c97b821be44;p=nageru diff --git a/disk_space_estimator.cpp b/disk_space_estimator.cpp index cacc811..a196105 100644 --- a/disk_space_estimator.cpp +++ b/disk_space_estimator.cpp @@ -5,11 +5,13 @@ #include #include +#include "metrics.h" #include "timebase.h" DiskSpaceEstimator::DiskSpaceEstimator(DiskSpaceEstimator::callback_t callback) : callback(callback) { + global_metrics.add("disk_free_bytes", &metric_disk_free_bytes, Metrics::TYPE_GAUGE); } void DiskSpaceEstimator::report_write(const std::string &filename, uint64_t pts) @@ -41,8 +43,10 @@ void DiskSpaceEstimator::report_write(const std::string &filename, uint64_t pts) return; } + off_t free_bytes = off_t(fst.f_bavail) * fst.f_frsize; + metric_disk_free_bytes = free_bytes; + if (!measure_points.empty()) { - off_t free_bytes = off_t(fst.f_bavail) * fst.f_frsize; double bytes_per_second = double(st.st_size - measure_points.front().size) / (pts - measure_points.front().pts) * TIMEBASE; double seconds_left = free_bytes / bytes_per_second;