|
| 1 | +// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. |
| 2 | + |
| 3 | +#include "fboss/cli/fboss2/commands/show/platformshowtech/Showtech.h" |
| 4 | +#include "fboss/cli/fboss2/commands/show/platformshowtech/utils.h" |
| 5 | +#include <filesystem> |
| 6 | +#include <iostream> |
| 7 | +#include <sstream> |
| 8 | +#include <string> |
| 9 | +#include <vector> |
| 10 | + |
| 11 | +namespace facebook::fboss::show::platformshowtech { |
| 12 | + |
| 13 | +namespace showtechUtils = show::platformshowtech::utils; |
| 14 | + |
| 15 | +void Showtech::printVersion() { |
| 16 | + std::cout << "################################\n"; |
| 17 | + std::cout << "##### SHOWTECH VERSION " << version << " #####\n"; |
| 18 | + std::cout << "################################\n\n"; |
| 19 | +} |
| 20 | + |
| 21 | +void Showtech::printCpuDetails() { |
| 22 | + std::cout << "##### CPU SYSTEM TIME #####\n" |
| 23 | + << showtechUtils::run_cmd_no_check("date"); |
| 24 | + std::cout << "\n##### CPU HOSTNAME #####\n" |
| 25 | + << showtechUtils::run_cmd_no_check("hostname"); |
| 26 | + std::cout << "\n##### CPU Linux Kernel Version #####\n" |
| 27 | + << showtechUtils::run_cmd_no_check("uname -r"); |
| 28 | + std::cout << "\n##### CPU UPTIME #####\n" |
| 29 | + << showtechUtils::run_cmd_no_check("uptime") << std::endl; |
| 30 | +} |
| 31 | + |
| 32 | +void Showtech::printFbossDetails() { |
| 33 | + showtechUtils::print_fboss2_show_cmd("product"); |
| 34 | + showtechUtils::print_fboss2_show_cmd("version agent"); |
| 35 | + showtechUtils::print_fboss2_show_cmd("environment sensor"); |
| 36 | + showtechUtils::print_fboss2_show_cmd("environment temperature"); |
| 37 | + showtechUtils::print_fboss2_show_cmd("environment fan"); |
| 38 | + showtechUtils::print_fboss2_show_cmd("environment power"); |
| 39 | +} |
| 40 | + |
| 41 | +void Showtech::printWeutil(std::string target) { |
| 42 | + std::string cmd = "weutil --eeprom " + target; |
| 43 | + std::filesystem::path ossConfigPath{ |
| 44 | + "/opt/fboss/share/platform_configs/weutil.json"}; |
| 45 | + |
| 46 | + if (std::filesystem::exists(ossConfigPath)) { |
| 47 | + // OSS doesn't support running weutil without the -config_file arg. |
| 48 | + cmd = cmd + " -config_file " + ossConfigPath.string(); |
| 49 | + } |
| 50 | + std::cout << "##### " + target + " SERIAL NUMBER #####\n"; |
| 51 | + std::cout << showtechUtils::run_cmd_no_check(cmd) << std::endl; |
| 52 | +} |
| 53 | + |
| 54 | +void Showtech::printLspci() { |
| 55 | + std::string cmd; |
| 56 | + |
| 57 | + std::cout << "################################\n"; |
| 58 | + std::cout << "############# LSPCI ############\n"; |
| 59 | + std::cout << "################################\n\n"; |
| 60 | + |
| 61 | + cmd = "lspci"; |
| 62 | + if (verbose_) { |
| 63 | + cmd = cmd + " -vvv"; |
| 64 | + } |
| 65 | + std::cout << cmd << std::endl |
| 66 | + << showtechUtils::run_cmd_no_check(cmd) << std::endl; |
| 67 | +} |
| 68 | + |
| 69 | +void Showtech::printI2cDetect() { |
| 70 | + std::string cmd; |
| 71 | + std::set<int> bus_to_ignore = i2cBusIgnore(); |
| 72 | + int bus; |
| 73 | + |
| 74 | + std::cout << "################################\n"; |
| 75 | + std::cout << "########## I2C DETECT ##########\n"; |
| 76 | + std::cout << "################################\n\n"; |
| 77 | + |
| 78 | + cmd = "i2cdetect -l"; |
| 79 | + std::cout << cmd << std::endl |
| 80 | + << showtechUtils::run_cmd_no_check(cmd) << std::endl; |
| 81 | + |
| 82 | + for (bus = 0; bus <= showtechUtils::get_max_i2c_bus(); ++bus) { |
| 83 | + if (bus_to_ignore.find(bus) == bus_to_ignore.end()) { |
| 84 | + cmd = "i2cdetect -y " + std::to_string(bus); |
| 85 | + std::cout << cmd << std::endl |
| 86 | + << showtechUtils::run_cmd_no_check(cmd) << std::endl; |
| 87 | + } |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +void Showtech::printLogs() { |
| 92 | + std::cout << "################################\n"; |
| 93 | + std::cout << "########## DEBUG LOGS ##########\n"; |
| 94 | + std::cout << "################################\n\n"; |
| 95 | + |
| 96 | + std::cout << "#### SENSORS LOG ####\n"; |
| 97 | + std::cout << showtechUtils::run_cmd_with_limit("journalctl -u sensor_service") |
| 98 | + << std::endl; |
| 99 | + |
| 100 | + std::cout << "#### FAN LOG ####\n"; |
| 101 | + std::cout << showtechUtils::run_cmd_with_limit("journalctl -u fan_service") |
| 102 | + << std::endl; |
| 103 | + |
| 104 | + std::cout << "#### DATA CORRAL LOG ####\n"; |
| 105 | + std::cout << showtechUtils::run_cmd_with_limit("journalctl -u data_corral_service") |
| 106 | + << std::endl; |
| 107 | + |
| 108 | + std::cout << "#### QSFP LOG ####\n"; |
| 109 | + std::cout << showtechUtils::run_cmd_with_limit("journalctl -u qsfp_service") |
| 110 | + << std::endl; |
| 111 | + |
| 112 | + std::cout << "#### SW AGENT LOG ####\n"; |
| 113 | + std::cout << showtechUtils::run_cmd_with_limit("journalctl -u fboss_sw_agent") |
| 114 | + << std::endl; |
| 115 | + |
| 116 | + std::cout << "#### HW AGENT LOG ####\n"; |
| 117 | + std::cout << showtechUtils::run_cmd_with_limit("journalctl -u fboss_hw_agent@0") |
| 118 | + << std::endl; |
| 119 | + |
| 120 | + std::cout << "#### DMESG LOG ####\n"; |
| 121 | + std::cout << showtechUtils::run_cmd_with_limit("dmesg") |
| 122 | + << std::endl; |
| 123 | + |
| 124 | + std::cout << "#### BOOT CONSOLE LOG ####\n"; |
| 125 | + std::cout << showtechUtils::run_cmd_with_limit("cat /var/log/boot.log") |
| 126 | + << std::endl; |
| 127 | + |
| 128 | + std::cout << "#### LINUX MESSAGES LOG ####\n"; |
| 129 | + std::cout << showtechUtils::run_cmd_with_limit("cat /var/log/messages") |
| 130 | + << std::endl; |
| 131 | +} |
| 132 | + |
| 133 | +void Showtech::printL1Info() { |
| 134 | + std::cout << "################################\n"; |
| 135 | + std::cout << "########### L1 LOGS ############\n"; |
| 136 | + std::cout << "################################\n\n"; |
| 137 | + |
| 138 | + showtechUtils::print_fboss2_show_cmd("port"); |
| 139 | + showtechUtils::print_fboss2_show_cmd("fabric"); |
| 140 | + showtechUtils::print_fboss2_show_cmd("lldp"); |
| 141 | + showtechUtils::print_fboss2_show_cmd("interface counters"); |
| 142 | + showtechUtils::print_fboss2_show_cmd("interface errors"); |
| 143 | + showtechUtils::print_fboss2_show_cmd("interface flaps"); |
| 144 | + showtechUtils::print_fboss2_show_cmd("interface phy"); |
| 145 | + showtechUtils::print_fboss2_show_cmd("transceiver"); |
| 146 | + |
| 147 | + if (verbose_) { |
| 148 | + std::cout << "#### wedge_qsfp_util ####\n"; |
| 149 | + std::cout << showtechUtils::run_cmd_no_check("wedge_qsfp_util") << std::endl; |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +void Showtech::printShowtech() { |
| 154 | + printVersion(); |
| 155 | + printCpuDetails(); |
| 156 | + printFbossDetails(); |
| 157 | + printPlatformInfo(); |
| 158 | + printLspci(); |
| 159 | + printL1Info(); |
| 160 | + if (verbose_) { |
| 161 | + printI2cDetect(); |
| 162 | + printLogs(); |
| 163 | + } |
| 164 | +} |
| 165 | + |
| 166 | +} // namespace facebook::fboss::show::platformshowtech |
0 commit comments