Added memory usage to AsynchronousMetrics

This commit is contained in:
Alexey Milovidov 2020-04-17 07:09:41 +03:00
parent 17e7d4d88a
commit fdc5688d2d
2 changed files with 22 additions and 0 deletions

View File

@ -9,9 +9,12 @@
#include <Storages/StorageMergeTree.h>
#include <Storages/StorageReplicatedMergeTree.h>
#include <IO/UncompressedCache.h>
#include <IO/ReadBufferFromFile.h>
#include <IO/ReadHelpers.h>
#include <Databases/IDatabase.h>
#include <chrono>
#if !defined(ARCADIA_BUILD)
# include "config_core.h"
#endif
@ -130,6 +133,23 @@ void AsynchronousMetrics::update()
set("Uptime", context.getUptimeSeconds());
/// Process memory usage according to OS
#if defined(OS_LINUX)
{
char buf[1024];
ReadBufferFromFile in("/proc/self/statm", 1024, -1, buf);
size_t memory_virtual = 0;
size_t memory_resident = 0;
readIntText(memory_virtual, in);
skipWhitespaceIfAny(in);
readIntText(memory_resident, in);
static constexpr size_t PAGE_SIZE = 4096;
set("MemoryVirtual", memory_virtual * PAGE_SIZE);
set("MemoryResident", memory_resident * PAGE_SIZE);
}
#endif
{
auto databases = DatabaseCatalog::instance().getDatabases();

View File

@ -27,6 +27,8 @@ MergeTreeSequentialBlockInputStream::MergeTreeSequentialBlockInputStream(
message << "Reading " << data_part->getMarksCount() << " marks from part " << data_part->name
<< ", total " << data_part->rows_count
<< " rows starting from the beginning of the part";
if (columns_to_read.size() == 1) /// Print column name but don't pollute logs in case of many columns.
message << ", column " << columns_to_read.front();
LOG_TRACE(log, message.rdbuf());
}