lib/utils/job-utils/command-parser.js
function _parseSmartCapabilities(lines) {
        var combineLines = [];
        var strBuf = '';

        /*
         The first line is 'General SMART Values:', it should be discarded.

         Some of the entry information is divided into multiline,
         so first we try to combine these lines to achieve a regular patter.
         Below is the example data:

         Offline data collection status:  (0x84)  Offline data collection activity
         was suspended by an interrupting command from host.
         Auto Offline Data Collection: Enabled.
        */
        for (var i = 1; i < lines.length; i+=1) {
            var firstChar = lines[i][0];
            if (firstChar >= 'A' && firstChar <= 'Z') {
                if (strBuf !== '') {
                    combineLines.push(strBuf);
                }
                strBuf = lines[i];
            }
            else {
                if (strBuf[strBuf.length-1] !== '.') {
                    strBuf += ' ';
                }
                strBuf += lines[i].trim();
            }
        }
        if (strBuf !== '') { // if this is ignored, the last capabilities entry will be missed.
            combineLines.push(strBuf);
        }

        //After combination, each line will become something like this:
        //name:  (0x84)  annotation1.annotation2.annotation3
        var result = [];
        _.forEach(combineLines, function(line) {
            var arr = line.split(/:\s*\(\s*(\w+)\)\s*/);
            var annotation = (arr[2] ? arr[2].split('.') : []);
            if (annotation.length > 0 && annotation[annotation.length-1].length === 0) {
                annotation.pop();
            }
            result.push({
                'Name'  : arr[0],
                'Value' : arr[1] || '',
                'Annotation' : annotation
            });
        });
        return result;
    }
function _parseSmartCapabilities(lines) {
        var combineLines = [];
        var strBuf = '';

        /*
         The first line is 'General SMART Values:', it should be discarded.

         Some of the entry information is divided into multiline,
         so first we try to combine these lines to achieve a regular patter.
         Below is the example data:

         Offline data collection status:  (0x84)  Offline data collection activity
         was suspended by an interrupting command from host.
         Auto Offline Data Collection: Enabled.
        */
        for (var i = 1; i < lines.length; i+=1) {
            var firstChar = lines[i][0];
            if (firstChar >= 'A' && firstChar <= 'Z') {
                if (strBuf !== '') {
                    combineLines.push(strBuf);
                }
                strBuf = lines[i];
            }
            else {
                if (strBuf[strBuf.length-1] !== '.') {
                    strBuf += ' ';
                }
                strBuf += lines[i].trim();
            }
        }
        if (strBuf !== '') { // if this is ignored, the last capabilities entry will be missed.
            combineLines.push(strBuf);
        }

        //After combination, each line will become something like this:
        //name:  (0x84)  annotation1.annotation2.annotation3
        var result = [];
        _.forEach(combineLines, function(line) {
            var arr = line.split(/:\s*\(\s*(\w+)\)\s*/);
            var annotation = (arr[2] ? arr[2].split('.') : []);
            if (annotation.length > 0 && annotation[annotation.length-1].length === 0) {
                annotation.pop();
            }
            result.push({
                'Name'  : arr[0],
                'Value' : arr[1] || '',
                'Annotation' : annotation
            });
        });
        return result;
    }
function _parseSmartCapabilities ( lines ) { var combineLines = [ ] ; var strBuf = '' ; /*
         The first line is 'General SMART Values:', it should be discarded.

         Some of the entry information is divided into multiline,
         so first we try to combine these lines to achieve a regular patter.
         Below is the example data:

         Offline data collection status:  (0x84)  Offline data collection activity
         was suspended by an interrupting command from host.
         Auto Offline Data Collection: Enabled.
        */ for ( var i = 1 ; i < lines . length ; i += 1 ) { var firstChar = lines [ i ] [ 0 ] ; if ( firstChar >= 'A' && firstChar <= 'Z' ) { if ( strBuf !== '' ) { combineLines . push ( strBuf ) ; } strBuf = lines [ i ] ; } else { if ( strBuf [ strBuf . length - 1 ] !== '.' ) { strBuf += ' ' ; } strBuf += lines [ i ] . trim ( ) ; } } if ( strBuf !== '' ) { // if this is ignored, the last capabilities entry will be missed. combineLines . push ( strBuf ) ; } //After combination, each line will become something like this: //name:  (0x84)  annotation1.annotation2.annotation3 var result = [ ] ; _ . forEach ( combineLines , function ( line ) { var arr = line . split ( / :\s*\(\s*(\w+)\)\s* / ) ; var annotation = ( arr [ 2 ] ? arr [ 2 ] . split ( '.' ) : [ ] ) ; if ( annotation . length > 0 && annotation [ annotation . length - 1 ] . length === 0 ) { annotation . pop ( ) ; } result . push ( { 'Name' : arr [ 0 ] , 'Value' : arr [ 1 ] || '' , 'Annotation' : annotation } ) ; } ) ; return result ; }
Parse SMART capabilities information from smartctl output

@param {Array} The data to parse, it has been splitted by lines
@return {Array} All parsed capabilities entries,
each entry contains properties 'Name', 'Value' and 'Annotation'.
Parse SMART capabilities information from smartctl output