Page tree

BMC Server Automation provides a default Network Shell script and Network Shell Script Job that you can use to check and clean various elements of the BMC Server Automation infrastructure, using BLCLI cleanup commands. You can edit and adjust this Database Cleanup script according to your cleanup needs.

Note

For the script to function properly, the role that runs the script must be granted the BL_Administration.System_Cleanup authorization.

To examine or change the options and commands included in the default script:

  1. In the Depot folder, navigate to the BMC Maintenance Depot object and select the BSA Recommended Database Cleanup Script.
  2. Right-click the script and select Open.

The following topics describe the options, parameters, and commands that you can use with the Network Shell script.

Script options

The Script Options panel provides identifying information for the Network Shell script. The default settings are shown in the following figure.

The Script Type setting must be set to Execute the script once, passing the host list as a parameter to the script, with the Allow run with no targets option selected.

The script executes repeatedly from the Application Server, each time running on a different server. This option uses the Network Shell runscript program, which can run the same script on multiple machines. The script uses environment variables local to the Application Server.

Script parameters

The Parameters panel lets you define parameters that are replaced with server property values when the script runs. Using this panel, you can add flags to parameters, you can specify whether the flag is required at runtime, and, if necessary, require a value to be provided for the flag. In addition, you can define a default value for a flag, make the default value editable when the script is run, and require a value to be entered for the flag at runtime.

Note

If you do not plan to use certain parameters and want the script to ignore them and not take them into account, you can set their flags to a value of ignore (in the Value column).

When you deploy a Network Shell script, BMC Server Automation automatically generates a master script that controls the script's deployment and execution. The system uses the parameters defined here to generate values in the master script.
The following figure shows the parameters for the script. The following table describes the parameters.

Description of parameters

Note

Script parameters are not case-sensitive.

Parameter nameFlagDescription
ExecutionMode

-m

Sets the Execution mode for the script. There are two options: Typical mode and individual command mode.

With the Typical mode, the script executes a series of recommended delete commands. The script executes the following commands in the order listed below:

  • Delete cleanupHistoricalData JobRunEvent
  • Delete cleanupHistoricalData AuditTrail
  • Delete executeRetentionPolicy
  • Delete cleanupDatabase
  • Delete hardDeleteAllSharedObjects
  • Delete cleanupFileServer
You can also choose to execute an individual delete command. Enter one of the values shown in Supported execution modes to execute an individual delete command. This option is useful if you want to cleanup a specific type of data, such as agent logs.
ContinueOnError

-c

Specifies if the script is to keep processing if it runs into errors. By default, the NSH Script uses Continue on error = true. If set to true, upon encountering an error the script will log the error and then continue with the cleanup run.
MaxDuration

-d

Specifies the overall maximum run-time for the script. By default, the NSH Script uses an overall maximum run-time of 720 minutes. You can change the overall maximum duration default value.
DurationDistribution

-p

Distributes the run-time across the delete commands in below shares (percent).

  • JobRunEvent = 8% (60 minutes)
  • AuditTrail = 8% (60 minutes)
  • cleanupDatabase = 50% (360 minutes)
  • hardDeleteAllSharedObjects = 17% (120 minutes)
  • cleanupFileServer = 17% (120 minutes)

These are the recommended settings for the script. BMC recommends that you do not change these settings. However, if you are very familiar with the landscape of the objects in the database that you want to delete, then you might want to adjust the settings. To adjust the settings, enter the settings in quotes, as shown below:
"JobRunEvent=8 AuditTrail=8 cleanupDatabase=50 hardDeleteAllSharedObjects=17 cleanupFileServer=17"

RetentionTime

-r

Specifies the number of days that must be exceeded for the script to delete the specified data. This parameter is used by the following execution modes:

TYPICAL

HISTORY_RDR

 


HISTORY_ORDR

 

CLEAN_AGENT

CLEAN_ALL_AS

CLEAN_AS

CLEAN_REPEATER

It is used by the following BLCLI commands:

Delete cleanupHistoricalData

Delete cleanupAgent

Delete cleanupAllAppServerCaches

Delete cleanupAppServerCache

Delete cleanupRepeater

The default value is 14 days.

condObjectType

-o

Deletes a specific type of object. To use this parameter, you must be using an execution mode of HISTORY_O or HISTORY_ORDR. Use one of the following values: 

AuditResult

AuditTrail

ComplianceResult

 Deploy 

JobRunEvent

JobSchedule

PatchResult

SnapshotResult

RoleName

-R

Deletes objects from the database that were created by a specific role.
TargetDevices

-t

Lists the device names which have an Application Server cache or a repeater. The execution modes CLEAN_AS and CLEAN_REPEATER use this parameter.
TargetSize

-s

Specifies the maximum size, in MB, for the repeater staging directory.

Supported execution modes

The following table lists the BLCLI commands and the mode values that are supported for use with the database and file server cleanup script.

 Mode valueCommand executedWhat it does
HISTORYDelete cleanupHistoricalData

Cleans up BMC Server Automation historical data based on retention time. Historical data includes Compliance Job results, Audit Job results, Snapshot Job results, Patch Job results, Deploy Job results, job run events, job schedules, and the audit trail.

HISTORY_OCleans up BMC Server Automation historical data for the specified OBJECT_TYPE (a required argument) using the default retention of 14 days.
HISTORY_RDRCleans up BMC Server Automation objects older than the RetentionTime parameter value for RoleName. The RoleName parameter can be literally null to cleanup data from all roles.

HISTORY_ORDR

Cleans up BMC Server Automation historical data for objects of the specified ObjectType and RoleName, deleting objects that are older than the RetentionTime parameter value.

RETENTIONDelete executeRetentionPolicyMarks entries for deletion based on retention time in the BMC Server Automation database. It marks old job runs and automatically created jobs and depot objects.
CLEAN_DBDelete cleanupDatabase

Deletes database rows for objects that have been previously marked for deletion.

Note: Certain objects are not deleted due to potential object dependencies. The cleanup process deletes all top-level model objects of the classes listed in the hk_allowed_classes database table, as well as all their child classes (which are not listed in this table). BMC recommends that you do NOT modify the contents of the hk_allowed_classes table.

CLEAN_DB_TLPerforms a BMC Server Automation Database cleanup with the duration limitation specified in the DurationDistribution parameter.
CLEAN_OBJECTSDelete hardDeleteAllSharedObjectsDeletes database rows for shared data objects with the duration limitation specified in DurationDistribution parameter. It includes data for shared files, checksum files, ACL entries, and internal values generated by BMC Server Automation.
CLEAN_FSDelete cleanupFileServerCleans all the unused files from the file server and from temporary file storage on the Application Server.

Note: When a Custom Package Deploy Job runs, it creates a subdirectory under the BLPackage directory for every iteration. Even after the job run history is removed by the retention policy, these directories still exist. These directories are not removed by the cleanup script.
CLEAN_FS_TLPerforms a FileServer cleanup with the duration limitation specified in the DurationDistribution parameter.
CHECK_FSDelete checkFileServerIntegrityPerforms a FileServer integrity check.

FULL_CLEANUP

Delete performFullCleanupJob

Deletes all objects marked for deletion and cleans all unused files from the file server and the temporary file storage area on the Application Server.

CLEAN_AGENTDelete cleanupAgent

Cleans up old temporary files on a target server (agent) that are older than the RetentionTime parameter value. This includes old files that were created by Deploy Jobs (transactions, staging, and so on).

Note: To clean up transactions, the value of the server's TRANSACTIONS_DIR property is used to locate the transactions directory. For information about configuring this property, see Configuring the location of the transactions directory.

CLEAN_ALL_ASDelete cleanupAllAppServerCachesDeletes old temporary files on all the Application Servers that are currently up and running (and accessible). It removes files older than the RetentionTime parameter value.
CLEAN_ASDelete cleanupAppServerCacheDeletes old temporary files on a specific Application Server (any files older than the RetentionTime parameter value).
CLEAN_REPEATERDelete cleanupRepeaterCleans up files from the staging directory of a repeater server. This cleanup removes files that have not been accessed for the RetentionTime parameter value.