1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef HTRACE_DISKI0_PARSER_H 16 #define HTRACE_DISKI0_PARSER_H 17 #include <cstdint> 18 #include <map> 19 #include <string> 20 #include "common_types.h" 21 #include "event_parser_base.h" 22 #include "htrace_plugin_time_parser.h" 23 #include "trace_streamer_config.h" 24 #include "trace_streamer_filters.h" 25 26 namespace SysTuning { 27 namespace TraceStreamer { 28 class HtraceDiskIOParser : public EventParserBase, public HtracePluginTimeParser { 29 public: 30 HtraceDiskIOParser(TraceDataCache* dataCache, const TraceStreamerFilters* ctx); 31 ~HtraceDiskIOParser(); 32 void Parse(ProtoReader::BytesView tracePacket, uint64_t ts); 33 void Finish(); 34 35 private: 36 struct TsDiskIOData { 37 uint64_t ts; 38 int64_t rdSectorsKb; 39 int64_t wrSectorsKb; 40 int64_t prevRdSectorsKb; 41 int64_t prevWrSectorsKb; 42 double rdCountPerSec; // 每秒从设备读取的数据量 kB_read/s 43 double wrCountPerSec; // 每秒向设备写入的数据量 kB_wrtn/s 44 uint64_t rdCount; // 读取的总数据量 kB_read 45 uint64_t wrCount; // 写入的总数量数据量 kB_wrtn 46 }; 47 std::vector<TsDiskIOData> diskIOData_; 48 }; 49 } // namespace TraceStreamer 50 } // namespace SysTuning 51 52 #endif // HTRACE_DISKI0_PARSER_H 53