hwraid icon indicating copy to clipboard operation
hwraid copied to clipboard

megaclisas-status difficulty processing megacli output

Open suwalski opened this issue 2 years ago • 1 comments

I've had to move from the dependable megaraid-status to megaclisas-status in my bullseye installations, as it seems the former is deprecated.

In my PERC5 machines, the megaclisas-status, which parses the output of megacli, doesn't work, since the PERC5s have bad binary data in the "Mfg. Data" section that it's all too willing to output:

# megaclisas-status --notemp
-- Controller information --
Traceback (most recent call last):
  File "/usr/sbin/megaclisas-status", line 660, in <module>
    output = getOutput(cmd)
  File "/usr/sbin/megaclisas-status", line 148, in getOutput
    for line in output:
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 420: invalid start byte
                    Mfg. Data
                ================
Mfg. Date       : 00/00/00
Rework Date     : 00/00/00
Revision No     : @��A
Battery FRU     : N/A

I think parsing the output of megacli is a fool's game compared to using the far more robust megactl, but I'm sure there are good reasons for it.

For now, I've created a /usr/local/sbin/MegaCli wrapper (that this script finds first), to preprocess the data:

#!/bin/sh

/usr/sbin/megacli $@ | iconv -c

But apparently the proper solution in the silliness that is Python is apparently to remove os.popen and replace with subprocess.Popen, which has string encoding options. I am useless with Python, so I can't provide a decent patch, though I can test.

suwalski avatar May 31 '22 21:05 suwalski

I use this too but am in transition between sites, will also take a look at it in a month.

egberts avatar Jun 01 '22 11:06 egberts