PEL: peltool: Exclude info PELs by default
Added default to exclude informational PELs when listing or showing
number of PELs.
Added -f, --info option to include them.
./peltool -n
{
"Number of PELs found": 3
}
./peltool -nf
{
"Number of PELs found": 10
}
Signed-off-by: Harisuddin Mohamed Isa <harisuddin@gmail.com>
Change-Id: I094e197370c123195591a90fd5e68c8664c64b6d
diff --git a/extensions/openpower-pels/tools/peltool.cpp b/extensions/openpower-pels/tools/peltool.cpp
index 7d1e304..61fb257 100644
--- a/extensions/openpower-pels/tools/peltool.cpp
+++ b/extensions/openpower-pels/tools/peltool.cpp
@@ -209,13 +209,15 @@
* stdout the full PEL in JSON if fullPEL is true
* @param[in] itr - std::map iterator of <uint32_t, BCDTime>
* @param[in] hidden - Boolean to include hidden PELs
+ * @param[in] includeInfo - Boolean to include informational PELs
* @param[in] fullPEL - Boolean to print full JSON representation of PEL
* @param[in] foundPEL - Boolean to check if any PEL is present
* @param[in] scrubRegex - SRC regex object
* @return std::string - JSON string of PEL entry (empty if fullPEL is true)
*/
template <typename T>
-std::string genPELJSON(T itr, bool hidden, bool fullPEL, bool& foundPEL,
+std::string genPELJSON(T itr, bool hidden, bool includeInfo, bool fullPEL,
+ bool& foundPEL,
const std::optional<std::regex>& scrubRegex)
{
std::size_t found;
@@ -243,6 +245,10 @@
{
return listStr;
}
+ if (!includeInfo && pel.userHeader().severity() == 0)
+ {
+ return listStr;
+ }
std::bitset<16> actionFlags{pel.userHeader().actionFlags()};
if (!hidden && actionFlags.test(hiddenFlagBit))
{
@@ -350,10 +356,11 @@
* @brief Print a list of PELs or a JSON array of PELs
* @param[in] order - Boolean to print in reverse orser
* @param[in] hidden - Boolean to include hidden PELs
+ * @param[in] includeInfo - Boolean to include informational PELs
* @param[in] fullPEL - Boolean to print full PEL into a JSON array
* @param[in] scrubRegex - SRC regex object
*/
-void printPELs(bool order, bool hidden, bool fullPEL,
+void printPELs(bool order, bool hidden, bool includeInfo, bool fullPEL,
const std::optional<std::regex>& scrubRegex)
{
std::string listStr;
@@ -373,9 +380,10 @@
}
}
bool foundPEL = false;
- auto buildJSON = [&listStr, &hidden, &fullPEL, &foundPEL,
+ auto buildJSON = [&listStr, &hidden, &includeInfo, &fullPEL, &foundPEL,
&scrubRegex](const auto& i) {
- listStr += genPELJSON(i, hidden, fullPEL, foundPEL, scrubRegex);
+ listStr +=
+ genPELJSON(i, hidden, includeInfo, fullPEL, foundPEL, scrubRegex);
};
if (order)
{
@@ -548,9 +556,11 @@
/**
* @brief Print number of PELs
* @param[in] hidden - Bool to include hidden logs
+ * @param[in] includeInfo - Bool to include informational logs
* @param[in] scrubRegex - SRC regex object
*/
-void printPELCount(bool hidden, const std::optional<std::regex>& scrubRegex)
+void printPELCount(bool hidden, bool includeInfo,
+ const std::optional<std::regex>& scrubRegex)
{
std::size_t count = 0;
for (auto it = fs::directory_iterator(EXTENSION_PERSIST_DIR "/pels/logs");
@@ -570,6 +580,10 @@
{
continue;
}
+ if (!includeInfo && pel.userHeader().severity() == 0)
+ {
+ continue;
+ }
std::bitset<16> actionFlags{pel.userHeader().actionFlags()};
if (!hidden && actionFlags.test(hiddenFlagBit))
{
@@ -684,19 +698,20 @@
bool listPEL = false;
bool listPELDescOrd = false;
bool hidden = false;
+ bool includeInfo = false;
bool deleteAll = false;
bool showPELCount = false;
bool fullPEL = false;
app.set_help_flag("--help", "Print this help message and exit");
- app.add_option("-f,--file", fileName,
- "Display a PEL using its Raw PEL file");
+ app.add_option("--file", fileName, "Display a PEL using its Raw PEL file");
app.add_option("-i, --id", idPEL, "Display a PEL based on its ID");
app.add_flag("-a", fullPEL, "Display all PELs");
app.add_flag("-l", listPEL, "List PELs");
app.add_flag("-n", showPELCount, "Show number of PELs");
app.add_flag("-r", listPELDescOrd, "Reverse order of output");
app.add_flag("-h", hidden, "Include hidden PELs");
+ app.add_flag("-f,--info", includeInfo, "Include informational PELs");
app.add_option("-d, --delete", idToDelete, "Delete a PEL based on its ID");
app.add_flag("-D, --delete-all", deleteAll, "Delete all PELs");
app.add_option("-s, --scrub", scrubFile,
@@ -728,7 +743,7 @@
{
scrubRegex = genRegex(scrubFile);
}
- printPELs(listPELDescOrd, hidden, fullPEL, scrubRegex);
+ printPELs(listPELDescOrd, hidden, includeInfo, fullPEL, scrubRegex);
}
else if (showPELCount)
{
@@ -736,7 +751,7 @@
{
scrubRegex = genRegex(scrubFile);
}
- printPELCount(hidden, scrubRegex);
+ printPELCount(hidden, includeInfo, scrubRegex);
}
else if (!idToDelete.empty())
{