aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/hw_info_explorer.cpp
blob: 0a31c1e9f6f3746911ee3f2b120675e9b5c78dcd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "hw_info_explorer.h"
#include <vespa/vespalib/data/slime/cursor.h>

namespace proton {

HwInfoExplorer::HwInfoExplorer(const HwInfo& info)
    : _info(info)
{
}

void
HwInfoExplorer::get_state(const vespalib::slime::Inserter& inserter, bool full) const
{
    auto& object = inserter.insertObject();
    if (full) {
        auto& disk = object.setObject("disk");
        disk.setLong("size_bytes", _info.disk().sizeBytes());
        disk.setBool("slow", _info.disk().slow());
        disk.setBool("shared", _info.disk().shared());

        auto& memory = object.setObject("memory");
        memory.setLong("size_bytes", _info.memory().sizeBytes());

        auto& cpu = object.setObject("cpu");
        cpu.setLong("cores", _info.cpu().cores());
    }
}

}