Fix annoying messages in AsynchronousMetrics

This commit is contained in:
Alexey Milovidov 2022-11-12 19:07:28 +01:00
parent ebde28bc50
commit b8c877db29
2 changed files with 22 additions and 9 deletions

View File

@ -12,6 +12,7 @@
#include <fmt/format.h> #include <fmt/format.h>
namespace Poco { class Logger; } namespace Poco { class Logger; }

View File

@ -24,9 +24,9 @@
#include <IO/MMappedFileCache.h> #include <IO/MMappedFileCache.h>
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
#include <Databases/IDatabase.h> #include <Databases/IDatabase.h>
#include <base/errnoToString.h>
#include <chrono> #include <chrono>
#include "config.h" #include "config.h"
#if USE_JEMALLOC #if USE_JEMALLOC
@ -123,9 +123,9 @@ void AsynchronousMetrics::openSensors()
{ {
LOG_WARNING( LOG_WARNING(
&Poco::Logger::get("AsynchronousMetrics"), &Poco::Logger::get("AsynchronousMetrics"),
"Thermal monitor '{}' exists but could not be read, error {}.", "Thermal monitor '{}' exists but could not be read: {}.",
thermal_device_index, thermal_device_index,
e.getErrno()); errnoToString(e.getErrno()));
continue; continue;
} }
@ -252,10 +252,10 @@ void AsynchronousMetrics::openSensorsChips()
{ {
LOG_WARNING( LOG_WARNING(
&Poco::Logger::get("AsynchronousMetrics"), &Poco::Logger::get("AsynchronousMetrics"),
"Hardware monitor '{}', sensor '{}' exists but could not be read, error {}.", "Hardware monitor '{}', sensor '{}' exists but could not be read: {}.",
hwmon_name, hwmon_name,
sensor_name, sensor_name,
e.getErrno()); errnoToString(e.getErrno()));
continue; continue;
} }
@ -1083,7 +1083,17 @@ void AsynchronousMetrics::update(TimePoint update_time)
BlockDeviceStatValues current_values{}; BlockDeviceStatValues current_values{};
BlockDeviceStatValues & prev_values = block_device_stats[name]; BlockDeviceStatValues & prev_values = block_device_stats[name];
current_values.read(*device);
try
{
current_values.read(*device);
}
catch (const ErrnoException & e)
{
LOG_DEBUG(log, "Cannot read statistics about the block device '{}': {}.",
name, errnoToString(e.getErrno()));
continue;
}
BlockDeviceStatValues delta_values = current_values - prev_values; BlockDeviceStatValues delta_values = current_values - prev_values;
prev_values = current_values; prev_values = current_values;
@ -1129,10 +1139,10 @@ void AsynchronousMetrics::update(TimePoint update_time)
} }
catch (...) catch (...)
{ {
tryLogCurrentException(__PRETTY_FUNCTION__); LOG_DEBUG(log, getCurrentExceptionMessage(false));
/// Try to reopen block devices in case of error /// Try to reopen block devices in case of error
/// (i.e. ENOENT means that some disk had been replaced, and it may apperas with a new name) /// (i.e. ENOENT or ENODEV means that some disk had been replaced, and it may appear with a new name)
try try
{ {
openBlockDevices(); openBlockDevices();
@ -1271,7 +1281,9 @@ void AsynchronousMetrics::update(TimePoint update_time)
} }
catch (const ErrnoException & e) catch (const ErrnoException & e)
{ {
LOG_DEBUG(&Poco::Logger::get("AsynchronousMetrics"), "Hardware monitor '{}', sensor '{}' exists but could not be read, error {}.", hwmon_name, sensor_name, e.getErrno()); LOG_DEBUG(log, "Hardware monitor '{}', sensor '{}' exists but could not be read: {}.",
hwmon_name, sensor_name, errnoToString(e.getErrno()));
continue;
} }
if (sensor_name.empty()) if (sensor_name.empty())