lib/utils/job-utils/command-parser.js
function _parseSmartOneDriveData(dataBlock) {
        //split output by empty line
        var dataSegments = dataBlock.split(/\r?\n\s*\r?\n/); //Divided by empty line
        var drvObj = {};

        _.forEach(dataSegments, function(data) {
            data = data.trim();

            //remove the empty data segment and the segment with smartctl version
            if (data.length === 0 || data.match(/^smartctl\s([\d\.]+)\s/)) {
                return;
            }

            var lines = data.split(/\r?\n/); //Divided by line

            if (data.startsWith('=== START OF INFORMATION SECTION ===')) {
                drvObj.Identity = _parseSmartInfoSection(lines);
            }
            else if (data.startsWith('=== START OF READ SMART DATA SECTION ===')) {
                drvObj['Self-Assessment'] = _parseSmartSelfAssessment(lines);
            }
            else if (data.startsWith('General SMART Values')) {
                drvObj.Capabilities = _parseSmartCapabilities(lines);
            }
            else if (data.startsWith('SMART Attributes Data Structure revision number:')) {
                drvObj.Attributes = _parseSmartAttributes(lines);
            }
            else if (data.startsWith('SMART Error Log Version:')) {
                drvObj['Error Log'] = _parseSmartErrorLog(lines);
            }
            else if (data.startsWith('SMART Self-test log structure revision number')) {
                drvObj['Self-test Log'] = _parseSmartSelfTestLog(lines);
            }
            else if (data.startsWith(
                    'SMART Selective self-test log data structure revision number')) {
                drvObj['Selective Self-test Log'] = _parseSmartSelectiveSelfTestLog(lines);
            }
            else {
                //I don't find the regular pattern for some data segment, or I don't know how to
                //well classify some data, so just put them in the 'Un-parsed Raw Data'.
                if (_.isArray(drvObj['Un-parsed Raw Data'])) {
                    drvObj['Un-parsed Raw Data'].push(data);
                }
                else {
                    drvObj['Un-parsed Raw Data'] = [data];
                }
            }
        });

        return drvObj;
    }
function _parseSmartOneDriveData(dataBlock) {
        //split output by empty line
        var dataSegments = dataBlock.split(/\r?\n\s*\r?\n/); //Divided by empty line
        var drvObj = {};

        _.forEach(dataSegments, function(data) {
            data = data.trim();

            //remove the empty data segment and the segment with smartctl version
            if (data.length === 0 || data.match(/^smartctl\s([\d\.]+)\s/)) {
                return;
            }

            var lines = data.split(/\r?\n/); //Divided by line

            if (data.startsWith('=== START OF INFORMATION SECTION ===')) {
                drvObj.Identity = _parseSmartInfoSection(lines);
            }
            else if (data.startsWith('=== START OF READ SMART DATA SECTION ===')) {
                drvObj['Self-Assessment'] = _parseSmartSelfAssessment(lines);
            }
            else if (data.startsWith('General SMART Values')) {
                drvObj.Capabilities = _parseSmartCapabilities(lines);
            }
            else if (data.startsWith('SMART Attributes Data Structure revision number:')) {
                drvObj.Attributes = _parseSmartAttributes(lines);
            }
            else if (data.startsWith('SMART Error Log Version:')) {
                drvObj['Error Log'] = _parseSmartErrorLog(lines);
            }
            else if (data.startsWith('SMART Self-test log structure revision number')) {
                drvObj['Self-test Log'] = _parseSmartSelfTestLog(lines);
            }
            else if (data.startsWith(
                    'SMART Selective self-test log data structure revision number')) {
                drvObj['Selective Self-test Log'] = _parseSmartSelectiveSelfTestLog(lines);
            }
            else {
                //I don't find the regular pattern for some data segment, or I don't know how to
                //well classify some data, so just put them in the 'Un-parsed Raw Data'.
                if (_.isArray(drvObj['Un-parsed Raw Data'])) {
                    drvObj['Un-parsed Raw Data'].push(data);
                }
                else {
                    drvObj['Un-parsed Raw Data'] = [data];
                }
            }
        });

        return drvObj;
    }
function _parseSmartOneDriveData ( dataBlock ) { //split output by empty line var dataSegments = dataBlock . split ( / \r?\n\s*\r?\n / ) ; //Divided by empty line var drvObj = { } ; _ . forEach ( dataSegments , function ( data ) { data = data . trim ( ) ; //remove the empty data segment and the segment with smartctl version if ( data . length === 0 || data . match ( / ^smartctl\s([\d\.]+)\s / ) ) { return ; } var lines = data . split ( / \r?\n / ) ; //Divided by line if ( data . startsWith ( '=== START OF INFORMATION SECTION ===' ) ) { drvObj . Identity = _parseSmartInfoSection ( lines ) ; } else if ( data . startsWith ( '=== START OF READ SMART DATA SECTION ===' ) ) { drvObj [ 'Self-Assessment' ] = _parseSmartSelfAssessment ( lines ) ; } else if ( data . startsWith ( 'General SMART Values' ) ) { drvObj . Capabilities = _parseSmartCapabilities ( lines ) ; } else if ( data . startsWith ( 'SMART Attributes Data Structure revision number:' ) ) { drvObj . Attributes = _parseSmartAttributes ( lines ) ; } else if ( data . startsWith ( 'SMART Error Log Version:' ) ) { drvObj [ 'Error Log' ] = _parseSmartErrorLog ( lines ) ; } else if ( data . startsWith ( 'SMART Self-test log structure revision number' ) ) { drvObj [ 'Self-test Log' ] = _parseSmartSelfTestLog ( lines ) ; } else if ( data . startsWith ( 'SMART Selective self-test log data structure revision number' ) ) { drvObj [ 'Selective Self-test Log' ] = _parseSmartSelectiveSelfTestLog ( lines ) ; } else { //I don't find the regular pattern for some data segment, or I don't know how to //well classify some data, so just put them in the 'Un-parsed Raw Data'. if ( _ . isArray ( drvObj [ 'Un-parsed Raw Data' ] ) ) { drvObj [ 'Un-parsed Raw Data' ] . push ( data ) ; } else { drvObj [ 'Un-parsed Raw Data' ] = [ data ] ; } } } ) ; return drvObj ; }
Parse the whole SMART data of one drive.

The data catalog is refer to the smartctl GUI.

@param {String} dataBlock - The whole smartctl output data for one drive.
@returns {Object} The object with well classfied SMART information.
Parse the whole SMART data of one drive .