Activating debugging for remediation packages

If you encounter problems in remediation jobs or undo jobs for rules within Compliance Content component templates, you can activate the debugging of scripts included in the remediation packages that are associated with the compliance rules. This results in debug-level logging to the job log.

By default, debug-level logging of remediation and undo scripts is not activated. Activation and deactivation of debug-level logging by Compliance Content remediation packages can be performed at the following levels:

  • Through individual scripts in individual remediation packages.
  • For all scripts in all remediation packages at once.

Note

As a prerequisite for debug-level logging of scripts in Compliance Content remediation packages, the DEBUG_MODE_ENABLED job property in your remediation job or undo job must be set to TRUE. For more information about setting the DEBUG_MODE_ENABLED job property, see Running a job in debug mode.

To set debug-level logging in an individual remediation package

  1. Navigate to the relevant BLPackage (under the Depot folder) and open it.
  2. In the hierarchy view, select the EXTERNALCMD object for specific rule remediation.
    The right pane shows the attributes associated with the selected object.
  3. Click in the Value column of the Cmd attribute (which contains the remediation script) or the UndoCmd attribute (which contains the undo script), and then click the Open External Editor/File Importer icon.
  4. In the editor, uncomment the set -x line (that is, remove the # number character) to activate debug-level logging.

To deactivate debug-level logging, comment out the set -x line by adding back the # number character at the beginning of the line.

  1. Click OK in the editor.
  2. Save the BLPackage.

To set debug-level logging in all remediation packages

  1. In the file server, create an NSH script file containing one of the following scripts:

    Script for activating debug-level logging from Compliance Content
    
    if [ $# != 1 ]
    then
    echo "Usage: $0 <Path to your BL package directory>"
    exit 0
    fi
    
    BLPACKAGE_DIR=$1
    
    grep -Rl 'set -x' $BLPACKAGE_DIR | while read file
    do
                    echo " Enabling debug for $file"
                    sed 's/##*set -x/set -x/g' $file 1>$file.bk
                    mv $file.bk $file
    done
    echo " Debug Enable Complete "
    

    Note

    If you exported the page to a PDF and if the PDF does not display the script, use the following code:
    if [ $# != 1 ]
    then
    echo "Usage: $0 <Path to your BL package directory>"
    exit 0
    fi

    BLPACKAGE_DIR=$1

    grep -Rl 'set -x' $BLPACKAGE_DIR | while read file
    do
    echo " Enabling debug for $file"
    sed 's/##*set -x/set -x/g' $file 1>$file.bk
    mv $file.bk $file
    done
    echo " Debug Enable Complete "

    Script for deactivating debug-level logging from Compliance Content
    
    if [ $# != 1 ]
    then
    echo "Usage: $0 <Path to your BL package directory>"
    exit 0
    fi
    
    BLPACKAGE_DIR=$1
    
    grep -Rl 'set -x' $BLPACKAGE_DIR | while read file
    do
                    echo "Disabling debug for $file."
                    sed 's/set -x/#set -x/g' $file 1>$file.bk
                    mv $file.bk $file
    done
    echo "Debug disable Complete"
    

    Note

    If you exported the page to a PDF and if the PDF does not display the script, use the following code:
    if [ $# != 1 ]
    then
    echo "Usage: $0 <Path to your BL package directory>"
    exit 0
    fi

    BLPACKAGE_DIR=$1

    grep -Rl 'set -x' $BLPACKAGE_DIR | while read file
    do
    echo "Disabling debug for $file."
    sed 's/set -x/#set -x/g' $file 1>$file.bk
    mv $file.bk $file
    done
    echo "Debug disable Complete"

  2. Set the permission of the NSH script file using the chmod 755 <filename> command.
  3. Start a Network Shell (NSH) session, and logon to the file server.
    For example,
    
    # nsh
    # cd // <fileserver_name>
    

    Note

    If you exported the page to a PDF and if the PDF does not display the script, use the following code:
    # nsh
    # cd // <fileserver_name>

  4. Through the NSH prompt, execute the NSH script that you prepared in step 1 by providing the name of the script and the path to the blpackages directory.
    For example:
    
    ./<script_name> /opt/bmc/BladeLogic/NSH/storage/blpackages
    

    Note

    If you exported the page to a PDF and if the PDF does not display the script, use the following code: 
    ./<script_name> /opt/bmc/BladeLogic/NSH/storage/blpackages 

Was this page helpful? Yes No Submitting... Thank you

Comments