11285115cSWilliam A. Kennington III // Copyright 2021 Google LLC 21285115cSWilliam A. Kennington III // 31285115cSWilliam A. Kennington III // Licensed under the Apache License, Version 2.0 (the "License"); 41285115cSWilliam A. Kennington III // you may not use this file except in compliance with the License. 51285115cSWilliam A. Kennington III // You may obtain a copy of the License at 61285115cSWilliam A. Kennington III // 71285115cSWilliam A. Kennington III // http://www.apache.org/licenses/LICENSE-2.0 81285115cSWilliam A. Kennington III // 91285115cSWilliam A. Kennington III // Unless required by applicable law or agreed to in writing, software 101285115cSWilliam A. Kennington III // distributed under the License is distributed on an "AS IS" BASIS, 111285115cSWilliam A. Kennington III // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121285115cSWilliam A. Kennington III // See the License for the specific language governing permissions and 131285115cSWilliam A. Kennington III // limitations under the License. 141285115cSWilliam A. Kennington III 151285115cSWilliam A. Kennington III #pragma once 161285115cSWilliam A. Kennington III #include <blobs-ipmid/blobs.hpp> 171285115cSWilliam A. Kennington III 181285115cSWilliam A. Kennington III #include <atomic> 191285115cSWilliam A. Kennington III #include <cstdint> 201285115cSWilliam A. Kennington III #include <string> 211285115cSWilliam A. Kennington III #include <string_view> 221285115cSWilliam A. Kennington III #include <unordered_map> 231285115cSWilliam A. Kennington III #include <vector> 241285115cSWilliam A. Kennington III 251285115cSWilliam A. Kennington III namespace metric_blob 261285115cSWilliam A. Kennington III { 271285115cSWilliam A. Kennington III 281285115cSWilliam A. Kennington III class BmcHealthSnapshot 291285115cSWilliam A. Kennington III { 301285115cSWilliam A. Kennington III public: 311285115cSWilliam A. Kennington III BmcHealthSnapshot(); 321285115cSWilliam A. Kennington III 331285115cSWilliam A. Kennington III /** 341285115cSWilliam A. Kennington III * Reads data from this metric 351285115cSWilliam A. Kennington III * @param offset: offset into the data to read 361285115cSWilliam A. Kennington III * @param requestedSize: how many bytes to read 371285115cSWilliam A. Kennington III * @returns Bytes able to read. Returns empty if nothing can be read. 381285115cSWilliam A. Kennington III */ 391285115cSWilliam A. Kennington III std::string_view read(uint32_t offset, uint32_t requestedSize); 401285115cSWilliam A. Kennington III 411285115cSWilliam A. Kennington III /** 421285115cSWilliam A. Kennington III * Returns information about the amount of readable data and whether the 431285115cSWilliam A. Kennington III * metric has finished populating. 441285115cSWilliam A. Kennington III * @param meta: Struct to fill with the metadata info 451285115cSWilliam A. Kennington III */ 461285115cSWilliam A. Kennington III bool stat(blobs::BlobMeta& meta); 471285115cSWilliam A. Kennington III 481285115cSWilliam A. Kennington III /** 491285115cSWilliam A. Kennington III * Start the metric collection process 501285115cSWilliam A. Kennington III */ 511285115cSWilliam A. Kennington III void doWork(); 521285115cSWilliam A. Kennington III 531285115cSWilliam A. Kennington III /** 541285115cSWilliam A. Kennington III * The size of the content string. 551285115cSWilliam A. Kennington III */ 561285115cSWilliam A. Kennington III uint32_t size(); 571285115cSWilliam A. Kennington III 581285115cSWilliam A. Kennington III /** 59*7f49370dSWilliam A. Kennington III * Returns the ID of the provided string 601285115cSWilliam A. Kennington III */ 611285115cSWilliam A. Kennington III int getStringID(const std::string_view s); 62*7f49370dSWilliam A. Kennington III 63*7f49370dSWilliam A. Kennington III private: 641285115cSWilliam A. Kennington III std::atomic<bool> done; 651285115cSWilliam A. Kennington III std::vector<char> pbDump; 661285115cSWilliam A. Kennington III std::unordered_map<std::string, int> stringTable; 671285115cSWilliam A. Kennington III int stringId; 681285115cSWilliam A. Kennington III long ticksPerSec; 691285115cSWilliam A. Kennington III }; 701285115cSWilliam A. Kennington III 711285115cSWilliam A. Kennington III } // namespace metric_blob 72