3. CLI Commands

To learn CLI commands type "help".

HammerDB v4.11 CLI Help Index

Type "help command" for more details on specific commands below

        buildschema
        checkschema
        deleteschema
        clearscript
        savescript
        customscript
        custommonitor
        datagenrun
        dbset
        dgset
        diset
        distributescript
        giset
        jobs
        librarycheck
        loadscript
        metset
        metstart
        metstatus
        metstop
        print
        quit
        steprun
        switchmode
        tcset
        tcstart
        tcstatus
        tcstop
        vucomplete
        vucreate
        vudestroy
        vurun
        vuset
        vustatus
        wsport
        wsstart
        wsstatus
        wsstop

hammerdb>

The commands have the following functionality.

Table 9.2. CLI commands

CommandUsageDescription
buildschemaUsage: buildschemaRuns the schema build for the database and benchmark selected with dbset and variables selected with diset. Equivalent to the Build command in the graphical interface. Note that the buildschema command will assume the "yes" reply to the Yes or no prompt to proceed with the schema build. This is to prevent the stalling of CLI scripts during builds.
checkschemaUsage: checkschemaRuns the schema consistency check for the database and benchmark selected with dbset and variables selected with diset. Equivalent to the Check command in the graphical interface.
deleteschemaUsage: deleteschemaRuns the schema delete for the database and benchmark selected with dbset and variables selected with diset. Equivalent to the Delete command in the graphical interface.
clearscriptUsage: clearscriptClears the script. Equivalent to the "Clear the Screen" button in the graphical interface.
savescriptUsage: savescriptSave the script to a file. Equivalent to the "Save" button in the graphical interface.
customscriptUsage: customscript scriptname.tclLoad an external script. Equivalent to the "Open Existing File" button in the graphical interface.
custommonitorUsage: custommonitor test|timedCauses an additional Virtual User to be created when running vucreate. Used when loading a custom script.
datagenrunUsage: datagenrunRun Data Generation. Equivalent to the Generate option in the graphical interface.
dbsetUsage: dbset [db|bm] valueSets the database (db) or benchmark (bm). Equivalent to the Benchmark Menu in the graphical interface. Database value is set by the database prefix in the XML configuration.
dgsetUsage: dgset [vu|ware|directory]Set the Datagen options. Equivalent to the Datagen Options dialog in the graphical interface.
disetUsage: diset dict key valueSet the dictionary variables for the current database. Equivalent to the Schema Build and Driver Options windows in the graphical interface. Use "print dict" to see what these variables area and diset to change: Example: hammerdb>diset tpcc count_ware 10 Changed tpcc:count_ware from 1 to 10 for Oracle.
distributescriptUsage: distributescriptIn Primary mode distributes the script loaded by Primary to the connected Replicas.
gisetUsage: giset dict key valueSet the dictionary variables for the generic settings. Use "print generic" to see what these variables are and giset to change Example: hammerdb>giset commandline keepalive_margin 60 Changed commandline:keepalive_margin from 10 to 60 for generic
jobs (alias job)hammerdb>help jobs jobs - Usage: jobs list all jobs. jobs - Usage: jobs [jobid|joblist|result|timestamp] jobid: list VU output for jobid. joblist: returns text list of jobs wthout newlines. result: list result for all jobs. timestamp: list starting timestamp for all jobs. jobs format - Usage: jobs format [ text | JSON ] text: Format job output as text. JSON: Format job output as JSON. jobs disable - Usage: jobs disable [ 0 | 1 ] 0: Enable storage of job output, restart required. 1: Disable storage of job output, restart required. jobs profileid - Usage: jobs profileid [ id ] profileid: returns current performance profile id. profileid id: sets current performance profile id. jobs profile - Usage: jobs profile [ id ] profile id: returns the results for the performance profile id. jobs jobid - Usage: jobs jobid [bm|db|delete|dict|metrics|result|status|system|tcount|timestamp|timing|vuid] bm: list benchmark for jobid. db: list database for jobid. delete: delete jobid. dict: list dict for jobid. metrics: show system metrics for jobid. result: list result for jobid. status: list status for jobid. system: show system data for jobid. tcount: list count for jobid. timestamp: list starting timestamp for jobid. timing: list xtprof summary timings for jobid. vuid: list VU output for VU with vuid for jobid. jobs jobid timing - Usage: jobs jobid timing vuid timing vuid: list xtprof timings for vuid for jobid. jobs jobid getchart - Usage: jobs jobid getchart [result | timing | tcount | metrics | profile ] result: generate html chart for TPROC-C/TPROC-H result. timing: generate html chart for TPROC-C/TPROC-H timings. metrics: generate html chart for TPROC-C/TPROC-H metrics. profile: generate html chart for TPROC-C performance profile using profileid for jobid argument. tcount: generate html chart for TPROC-C transaction count. hammerdb>The jobs command can be used to enable or disable jobs functionality. If enabled it records the output, configuration, result, timing and transactions of a workload for retrieval at a later point identified by a jobid.
librarycheckUsage: librarycheckAttempts to load the vendor provided 3rd party library for all databases and reports whether the attempt was successful.
loadscriptUsage: loadscriptLoad the script for the database and benchmark set with dbset and the dictionary variables set with diset. Use "print script" to see the script that is loaded. Equivalent to loading a Driver Script in the Script Editor window in the graphical interface.
metsetUsage: metset [agent_hostname|agent_id]Configure the CPU Metrics options. Equivalent to the Metrics Options window in the graphical interface.
metstartUsage: metstatusChecks the status of the CPU Metrics.
metstatusUsage: metstartStarts the CPU Metrics and agent if configured to the localhost.
metstopUsage: metstopStops the CPU Metrics.
printUsage: print [db|bm|dict|generic|script|vuconf |vucreated|vustatus|datagen]prints the current configuration: db: database bm: benchmark dict: the dictionary for the current database ie all active variables generic: the dictionary for generic settings script: the loaded script vuconf: the virtual user configuration vucreated: the number of virtual users created vustatus: the status of the virtual users datagen : the configuration to build when datagen is run
quitUsage: quit Shuts down the HammerDB CLI.Calls the exit command and terminates the CLI interface
steprunUsage: steprunAutomatically switches into Primary mode, creates and connects the multiple Replicas defined in config/steps.xml and starts the Primary and Replica Virtual Users at the defined intervals creating a step workload. Both Primary and Replicas will exit on completion.
switchmodeUsage: switchmode [mode] ?PrimaryID? ?PrimaryHostname?Changes the remote mode to Primary, Replica or Local. When Master it will report an id and a hostname. Equivalent to the Mode option in the graphical interface. Mode to switch to must be one of Local, Primary or Replica. If Mode is Replica then the ID and Hostname of the Primary to connect to must be given.
tcsetUsage: tcset [refreshrate|logtotemp|unique|timestamps]Configure the transaction counter options. Equivalent to the Transaction Counter Options window in the graphical interface.
tcstartUsage: tcstartStarts the Transaction Counter.
tcstatusUsage: tcstatusChecks the status of the Transaction Counter.
tcstopUsage: tcstopStops the Transaction Counter.
vucompleteUsage: vucompleteReturns "true" or "false" depending on whether all virtual users that started a workload have completed regardless of whether the status was "FINISH SUCCESS" or "FINISH FAILED".
vucreateUsage: vucreateCreate the virtual users. Equivalent to the Virtual User Create option in the graphical interface. Use "print vucreated" to see the number created, vustatus to see the status and vucomplete to see whether all active virtual users have finished the workload. A script must be loaded before virtual users can be created.
vudestroyUsage: vudestroyDestroy the virtual users. Equivalent to the Destroy Virtual Users button in the graphical interface that replaces the Create Virtual Users button after virtual user creation.
vurunUsage: vurunSend the loaded script to the created virtual users for execution. Equivalent to the Run command in the graphical interface. In the CLI returns a jobid to access the workloads output and configuration.
vusetUsage: vuset [vu|delay|repeat|iterations|showoutput |logtotemp|unique|nobuff|timestampsConfigure the virtual user options. Equivalent to the Virtual User Options window in the graphical interface. vuset expects an integer or the string "vcpu". Where "vcpu" is specified the vu value will be set to the number of logical CPUs detected on the system where HammerDB is running.
vustatusUsage: vustatusShow the status of virtual users. Status will be "WAIT IDLE" for virtual users that are created but not running a workload,"RUNNING" for virtual users that are running a workload, "FINISH SUCCESS" for virtual users that completed successfully or "FINISH FAILED" for virtual users that encountered an error.
wsportUsage: wsport [ port number ]Set or report the Web Service Port.
wsstartUsage: wsstartStart the Web Service.
wsstopUsage: wsstopStops the Web Service.
wsstatusUsage: wsstatusChecks the status of the Web Service.


Note that the runtimer and waittocomplete parameters have been deprecated from v4.6. For this reason an additional configuration parameter of keepalive_margin with a default value of 10 seconds increasing to 60 seconds from v4.10 has been added to generic.xml in the commandline section to modify the additional time that HammerDB will wait after completion before terminating the workload. This can be useful if for example gathering timing data for event driven scaling workloads with a large number of asynchronous clients.

3.1. CLI commands in Python

The HammerDB commands in Python are identical to the ones in the default Tcl mode except accessed as Python functions with either string or integer arguments.

C:\Program Files\HammerDB-4.12>hammerdbcli py
HammerDB CLI v4.12
Copyright (C) 2003-2024 Steve Shaw
Type "help()" for a list of commands
hammerdb>>>help()
HammerDB v4.12 CLI Help Index

Type "help command" for more details on specific commands below

        buildschema
        checkschema
        deleteschema
        clearscript
        savescript
        customscript
        custommonitor
        datagenrun
        dbset
        dgset
        diset
        distributescript
        giset
        jobs
        librarycheck
        loadscript
        metset
        metstart
        metstatus
        metstop
        print
        quit
        steprun
        switchmode
        tcset
        tcstart
        tcstatus
        tcstop
        vucomplete
        vucreate
        vudestroy
        vurun
        vuset
        vustatus
        wsport
        wsstart
        wsstatus
        wsstop

hammerdb>>>vuset('vu',10)
hammerdb>>>

hammerdb>>>print('vuconf')
Virtual Users = 10
User Delay(ms) = 500
Repeat Delay(ms) = 500
Iterations = 1
Show Output = 1
Log Output = 0
Unique Log Name = 0
No Log Buffer = 0
Log Timestamps = 0

hammerdb>>>