accessing hardware information using python

sjdevnull at sjdevnull at
Fri Jan 20 14:40:34 EST 2006

Johhny wrote:
> I am currently looking to write a utility in python that will monitor
> the statis of a RAID card within linux. The card in Question is the LSI
> SAS1064 as the tools provided by the vendor to monitor the software
> does not suit our requirements.

What are your requirements?

> However I am unsure how to convert dmidecode information like so :
> Handle 0x0025
>         DMI type 10, 6 bytes.
>         On Board Device Information
>                 Type: SCSI Controller
>                 Status: Enabled
>                 Description:  LSI serial-ATA #1

If dmidecode is a command-line program, maybe something using os.popen:

#!/usr/bin/env python
import os

dmiOutput = os.popen("dmidecode", "r")

status = None
for line in dmiOutput:
    line = line.strip()
    if line.startswith("Status: "):
        status = line.split("Status: ", 1)[1]

if status is not None:
    print "Status is: ", status
    print "No status information found"

More information about the Python-list mailing list