From cf7060ea08ab072d057195c812ecc1f2f0cf0ded Mon Sep 17 00:00:00 2001 From: Fedor Loshakov Date: Mon, 9 Dec 2024 14:50:35 +0100 Subject: [PATCH] ziomon/ziorep_utilization: add pchid column to physical adapter report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In ziorep_utilization tool physical adapter report represents PCHID scope, rather than CHPID. PCHID column is added as a very first column of physical adapter report for non-CSV format report. Old version of physical adapter report with CHPID column only looks like: ... CHP|adapter in %-|--bus in %---|--cpu in %---| ID min max avg min max avg min max avg 2020-05-14 14:00:41 60 0 0 0.0 1 1 1.0 0 0 0.0 61 0 0 0.0 1 1 1.0 0 0 0.0 ... New version of physical adapter report with additional PCHID column looks like: ... PCH |CHP|adapter in %-|--bus in %---|--cpu in %---| ID ID min max avg min max avg min max avg 2020-05-14 14:00:41 01c0 60 0 0 0.0 1 1 1.0 0 0 0.0 01c1 61 0 0 0.0 1 1 1.0 0 0 0.0 ... For CSV-format report PCHID column is appended to the end of each record line. For older kernel releases, where PCHID sysfs entry is not available, replace PCHID column value with "n/a". Signed-off-by: Fedor Loshakov Reviewed-by: Benjamin Block Reviewed-by: Sakshi Singh <005c7w@linux.ibm.com> Reviewed-by: M Nikhil Signed-off-by: Jan Höppner --- ziomon/ziorep_printers.cpp | 34 +++++++++++++++++++++++++++++++--- ziomon/ziorep_printers.hpp | 4 +++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ziomon/ziorep_printers.cpp b/ziomon/ziorep_printers.cpp index bd4654df..98711987 100644 --- a/ziomon/ziorep_printers.cpp +++ b/ziomon/ziorep_printers.cpp @@ -309,6 +309,22 @@ void PhysAdapterPrinter::print_phys_adpt(FILE *fp, __u32 host_id, int *rc) fprintf(fp, "%3x", chpid); } +void PhysAdapterPrinter::print_pchid(FILE *fp, __u32 host_id, int *rc) +{ + __u32 pchid = m_cfg->get_pchid_by_host_id(host_id, rc); + + if (m_csv) + if (pchid != ZIOREP_PCHID_NA) + fprintf(fp, "%x", pchid); + else + fprintf(fp, "%s", "n/a"); + else + if (pchid != ZIOREP_PCHID_NA) + fprintf(fp, "%04x", pchid); + else + fprintf(fp, "%s", "n/a "); +} + void PhysAdapterPrinter::print_utilization(FILE *fp, const struct abbrev_stat *stat, @@ -361,10 +377,10 @@ void PhysAdapterPrinter::print_topline(FILE *fp) if (m_csv) fprintf(fp, "timestamp,aggregated,CHPID,adapter min %%," "adapter max %%,adapter avg %%,bus min %%,bus max %%," - "bus avg %%,cpu min %%,cpu max %%,cpu avg %%\n"); + "bus avg %%,cpu min %%,cpu max %%,cpu avg %%,PCHID\n"); else { - fprintf(fp, "CHP|adapter in %%-|--bus in %%---|--cpu in %%---|\n"); - fprintf(fp, " ID min max avg min max avg min max avg\n"); + fprintf(fp, "PCH |CHP|adapter in %%-|--bus in %%---|--cpu in %%---|\n"); + fprintf(fp, " ID ID min max avg min max avg min max avg\n"); } } @@ -387,6 +403,12 @@ int PhysAdapterPrinter::print_frame(FILE *fp, // print timestamp for every line in CSV mode timestamp_printed = true; } + if (!m_csv) { + print_pchid(fp, *i, &lrc); + if (lrc) + return -1; + print_delimiter(fp); + } print_phys_adpt(fp, *i, &lrc); if (lrc) return -1; @@ -402,6 +424,12 @@ int PhysAdapterPrinter::print_frame(FILE *fp, print_utilization(fp, &util->stats.cpu, util->stats.count, util->valid); + if (m_csv) { + print_delimiter(fp); + print_pchid(fp, *i, &lrc); + if (lrc) + return -1; + } fputc('\n', fp); } diff --git a/ziomon/ziorep_printers.hpp b/ziomon/ziorep_printers.hpp index 747f009b..9a280775 100644 --- a/ziomon/ziorep_printers.hpp +++ b/ziomon/ziorep_printers.hpp @@ -3,7 +3,7 @@ * * Utility classes to print framsets * - * Copyright IBM Corp. 2008, 2021 + * Copyright IBM Corp. 2008, 2024 * * s390-tools is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. @@ -108,6 +108,8 @@ public: private: void print_phys_adpt(FILE *fp, __u32 host_id, int *rc); + void print_pchid(FILE *fp, __u32 host_id, + int *rc); void print_utilization(FILE *fp, const struct abbrev_stat *stat, __u64 count, bool valid);