Discussion:
[Ipmitool-devel] [PATCH V1]Prevention of printing outdated event log entry if SEL Record ID is not present
Mamatha Inamdar
2014-03-03 09:20:14 UTC
Permalink
Currently when we issue ipmitool command to get SEL Record ID,
it prints the following outdated event log entry if SEL Record ID is not present.

ipmitool -I lanplus -H <ip address> -P PASSW0RD -C 1 sel get 1
Get SEL Entry 1 command failed: Requested sensor, data, or record not found

SEL Record ID : 0000
Record Type : 00
Timestamp : 01/01/1970 00:00:00
Generator ID : 92c0
EvM Revision : 04
Sensor Type : Power Supply
Sensor Number : 28
Event Type : Reserved
Event Direction : Assertion Event
Event Data : 0d0809

This patch is to avoid printing outdated event log entry if SEL Record ID is not present.

Test results:

1)SEL Record ID not present

./ipmitool -I lanplus -H <ip address> -P PASSW0RD -C 1 sel get 5
Get SEL Entry 5 command failed: Requested sensor, data, or record not found

2) SEL Record ID present

./ipmitool -I lanplus -H <ip address> -P PASSW0RD -C 1 sel get 1
SEL Record ID : 0001
Record Type : 02
Timestamp : 02/25/2014 03:09:53
Generator ID : 2000
EvM Revision : 04
Sensor Type : System Event
Sensor Number : 36
Event Type : Generic Discrete
Event Direction : Assertion Event
Event Data : 466fff
Description : Transition to Non-recoverable

Changes in V1:
Updated terminology as "SEL Record ID".

Signed-off-by: Mamatha Inamdar <***@linux.vnet.ibm.com>
---
lib/ipmi_sel.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c
index 63ecbcf..0393a99 100644
--- a/lib/ipmi_sel.c
+++ b/lib/ipmi_sel.c
@@ -2898,7 +2898,11 @@ ipmi_sel_show_entry(struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_DEBUG, "Looking up SEL entry 0x%x", id);

/* lookup SEL entry based on ID */
- ipmi_sel_get_std_entry(intf, id, &evt);
+ if(!ipmi_sel_get_std_entry(intf, id, &evt)) {
+ lprintf(LOG_DEBUG, "SEL Entry %d not found", id);
+ return -1;
+ }
+
if (evt.sel_type.standard_type.sensor_num == 0 && evt.sel_type.standard_type.sensor_type == 0 && evt.record_type == 0) {
lprintf(LOG_WARN, "SEL Entry 0x%x not found", id);
rc = -1;
Zdenek Styblik
2014-03-03 16:56:27 UTC
Permalink
On Mon, Mar 3, 2014 at 10:20 AM, Mamatha Inamdar
<***@linux.vnet.ibm.com> wrote:
[...]
Post by Mamatha Inamdar
---
lib/ipmi_sel.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c
index 63ecbcf..0393a99 100644
--- a/lib/ipmi_sel.c
+++ b/lib/ipmi_sel.c
@@ -2898,7 +2898,11 @@ ipmi_sel_show_entry(struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_DEBUG, "Looking up SEL entry 0x%x", id);
/* lookup SEL entry based on ID */
- ipmi_sel_get_std_entry(intf, id, &evt);
+ if(!ipmi_sel_get_std_entry(intf, id, &evt)) {
+ lprintf(LOG_DEBUG, "SEL Entry %d not found", id);
+ return -1;
+ }
+
if (evt.sel_type.standard_type.sensor_num == 0 && evt.sel_type.standard_type.sensor_type == 0 && evt.record_type == 0) {
lprintf(LOG_WARN, "SEL Entry 0x%x not found", id);
rc = -1;
Hello Mamatha,

I believe you're patch is incorrect as 'sel get' actually accepts
multiple SEL IDs. Therefore, it should be:
~~~
rc = (-1);
continue;
~~~

instead of:
~~~
return (-1);
~~~

Best regards,
Z.
Mamatha Inamdar
2014-03-04 05:46:54 UTC
Permalink
Post by Zdenek Styblik
On Mon, Mar 3, 2014 at 10:20 AM, Mamatha Inamdar
[...]
Post by Mamatha Inamdar
---
lib/ipmi_sel.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/ipmi_sel.c b/lib/ipmi_sel.c
index 63ecbcf..0393a99 100644
--- a/lib/ipmi_sel.c
+++ b/lib/ipmi_sel.c
@@ -2898,7 +2898,11 @@ ipmi_sel_show_entry(struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_DEBUG, "Looking up SEL entry 0x%x", id);
/* lookup SEL entry based on ID */
- ipmi_sel_get_std_entry(intf, id, &evt);
+ if(!ipmi_sel_get_std_entry(intf, id, &evt)) {
+ lprintf(LOG_DEBUG, "SEL Entry %d not found", id);
+ return -1;
+ }
+
if (evt.sel_type.standard_type.sensor_num == 0 && evt.sel_type.standard_type.sensor_type == 0 && evt.record_type == 0) {
lprintf(LOG_WARN, "SEL Entry 0x%x not found", id);
rc = -1;
Hello Mamatha,
I believe you're patch is incorrect as 'sel get' actually accepts
~~~
rc = (-1);
continue;
~~~
~~~
return (-1);
~~~
Hi Zdenek Styblik
Thanks for reviewing the code...
I have updated your comments and sent out the new version of patch.

Thanks
Mamatha
Post by Zdenek Styblik
Best regards,
Z.
Loading...