Example #1
0
    def get_info(self):
        smart_attrs = {
            '^\s*Model Family:\s+(.*)': 'model_family',
            '^\s*Device Model:\s+(.*)': 'device_model',
            '^\s*Serial Number:\s+(.*)': 'serial_number',
            '^\s*LU WWN Device Id:\s+(.*)': 'wwn',
            '^\s*Firmware Version:\s+(.*)': 'firmware_version',
            '^\s*User Capacity:\s+(.*)': 'user_capacity',
            '^\s*Sector Size:\s+(.*)': 'sector_size_b',
            '^\s*Device is:\s+(.*)': 'device_is',
            '^\s*ATA Version is:\s+(.*)': 'ata_version',
            '^\s*SATA Version is:\s+(.*)': 'sata_version',
            '^\s*Local Time is:\s+(.*)': 'local_time',
            '^\s*SMART support is: Available - device has SMART capability.\s*$': 'available',
            '^\s*SMART support is:\s+(.*)': 'smart_enabled',
            '^\s*SMART overall-health self-assessment test result:\s+(.*)': 'test',
        }

        cmd = [smartctl_cmd, '-a', self.dev]

        attrs = Command.run_and_extract_attrs(cmd, smart_attrs)

#        for (key, value) in attrs.iteritems():
#            if callable(value.strip):
#                attrs[key] = value.strip()

        return attrs
Example #2
0
    def get_info(self):
        hdparm_attrs = {
            '^\s*Serial Number:\s*(.*)\s*$': 'serial_number',
            '^\s*Firmware Revision:\s*(.*)\s*$': 'firmware',
            '^\s*Transport:\s*(.*)\s*$':     'transport',
            '^\s*NAA:\s*(.*)\s*$':           'naa',
            '^\s*IEEE OUI:\s*(.*)\s*$':      'ieee_oui',
            '^\s*Unique ID:\s*(.*)\s*$':     'unique_id',
            '^\s*Logical Unit WWN Device Identifier:\s*(.*)\s*$': 'wwn',
            '^\s*Model Number:\s+(.*)\s*$':  'model_number',
            '^\s*CHS current addressable sectors\s*:\s*(\d+)': 'chs_current_addressable_sectors',
            '^\s*LBA\s+user\s+addressable\s+sectors\s*:\s*(\d+)': 'lba_user_addressable_sectors',
            '^\s*LBA48  user addressable sectors:\s*(\d+)': 'lba48_user_addressable_sectors',
            '^\s*Logical/Physical Sector size:\s*(\d+)': 'sector_size_bytes',
            '^\s*device size with M = 1024\*1024:\s*(\d+)': 'size_mb',
}

        cmd = [hdparm_cmd, '-I', self.dev]

        attrs = Command.run_and_extract_attrs(cmd, hdparm_attrs)

        for (key, value) in attrs.iteritems():
            attrs[key] = value.strip()

        # Convert integer values to integers
        int_attrs = ['size_mb', 'sector_size_bytes', 'lba48_user_addressable_sectors', 'chs_current_addressable_sectors']

        for attr in int_attrs:
            value = attrs.get(attr, None)
            if value is not None:
                attrs[attr] = int(value)

        return attrs
Example #3
0
    def speed_test(self, offset=None):
        cmd = [hdparm_cmd, '-t', '--direct']

        if offset:
            cmd.append('--offset')
            cmd.append('%d' % offset)

        cmd.append(self.dev)

        patterns = {'^\s*Timing.*=\s*([0-9\.]+)': 'speed'}

        attrs = Command.run_and_extract_attrs(cmd, patterns)

        float_attrs = ['speed']

        for attr in float_attrs:
            value = attrs.get(attr, None)
            if value is not None:
                attrs[attr] = float(value)

        return attrs['speed']
Example #4
0
    def get_info(self):
        hdparm_attrs = {
            '^\s*Serial Number:\s*(.*)\s*$': 'serial_number',
            '^\s*Firmware Revision:\s*(.*)\s*$': 'firmware',
            '^\s*Transport:\s*(.*)\s*$': 'transport',
            '^\s*NAA:\s*(.*)\s*$': 'naa',
            '^\s*IEEE OUI:\s*(.*)\s*$': 'ieee_oui',
            '^\s*Unique ID:\s*(.*)\s*$': 'unique_id',
            '^\s*Logical Unit WWN Device Identifier:\s*(.*)\s*$': 'wwn',
            '^\s*Model Number:\s+(.*)\s*$': 'model_number',
            '^\s*CHS current addressable sectors\s*:\s*(\d+)':
            'chs_current_addressable_sectors',
            '^\s*LBA\s+user\s+addressable\s+sectors\s*:\s*(\d+)':
            'lba_user_addressable_sectors',
            '^\s*LBA48  user addressable sectors:\s*(\d+)':
            'lba48_user_addressable_sectors',
            '^\s*Logical/Physical Sector size:\s*(\d+)': 'sector_size_bytes',
            '^\s*device size with M = 1024\*1024:\s*(\d+)': 'size_mb',
        }

        cmd = [hdparm_cmd, '-I', self.dev]

        attrs = Command.run_and_extract_attrs(cmd, hdparm_attrs)

        for (key, value) in attrs.iteritems():
            attrs[key] = value.strip()

        # Convert integer values to integers
        int_attrs = [
            'size_mb', 'sector_size_bytes', 'lba48_user_addressable_sectors',
            'chs_current_addressable_sectors'
        ]

        for attr in int_attrs:
            value = attrs.get(attr, None)
            if value is not None:
                attrs[attr] = int(value)

        return attrs
Example #5
0
    def speed_test(self, offset=None):
        cmd = [hdparm_cmd, '-t', '--direct']

        if offset:
            cmd.append('--offset')
            cmd.append('%d' % offset)

        cmd.append(self.dev)
        
        patterns = {
            '^\s*Timing.*=\s*([0-9\.]+)': 'speed'
        }

        attrs = Command.run_and_extract_attrs(cmd, patterns)

        float_attrs = ['speed']

        for attr in float_attrs:
            value = attrs.get(attr, None)
            if value is not None:
                attrs[attr] = float(value)

        return attrs['speed']