Previous Next
Use Case Examples
The section lists some possible use cases and the client commands:
Printing Log Entries to the Console
Print the specified log entries to the console.
vmwb_lbcli print [options]
 
--count <arg> Optional max count of the number of entries to display. Defaults to 30.
You may also specify 'all' in order to fetch all log entries.
--first <arg> Optional 1 based entry number of the first entry to display.
--format <arg> Optional format for the output. Must be one of json,xml,txt. Default is
txt.
--lbserver <arg> The host name of the log browser server to connect to. If not provided
looks for env variable VMLB_SERVER, and then defaults to localhost.
--noextra If given, suppress printing of 'extra' lines in the output, leaving only
the first line of a given log entry as the value emitted. Default is to
emit the extra lines.
--nofilter If given, the printed results are the UNFILTERED log entries. By default
the entries printed are a result of the currently applied filter.
--outfile <arg> Redirect the output to the specified file instead of stdout.
--project <arg> The name of the project. If not provided looks for env variable
VMLB_PROJECT.
--resource <arg> The name of the resource. If not provided looks for env variable
VMLB_RESOURCE.
--verbose Verbose display of results if available.
Downloading Log Files from a Remote Host for Analysis
The download command allows you to connect to a remote host, collect a particular type of log file from it, and open it for analysis:
$ vmwb-lbcli download --host=192.168.1.106 --htype=esx --user=root --project=test --type=hostd
[Enter password for connection:]
The command shares the workspace of the server it connects to, and by implication it also shares all projects, log analyses, and cached target credentials that the server has.
In this example, the user had not connected to this target yet, and because the command did not explicitly specify the password with the --password switch, it prompted the user for it.
For subsequent commands, the password does not have to be entered again because the credentials are cached in the servers secure storage. In the following example, a later download of a different log file type, it is not necessary to specify the user name and password. The cached ones from the connection above are used.
$ vmwb-lbcli download --host=192.168.1.106 --htype=esx --project=test --type=VMkernel
$
After downloading the files, if you have the Workbench IDE running, you will see projects that have been created as a result of these commands. The projects include the server it connects to, as well as a new remote systems target for the host that was specified in the command-line.
Discovering Logs on a Host
If you do not know the types of logs that your remote system supports, the download command can give you some guidance. Omitting the --type argument causes the system to return an error message that lists the allowable types:
$ vmwb-lbcli download --project=myProj --host=192.168.1.106 --htype=esx --user=root --password=VMwar3rules
ERROR: Log type must be supplied. Allowable values for this host include vmware,VMKernel,hostd,shell,syslog,vpxa,fdm,VMKwarning.
Downloading All Logs for a Host
The download command supports --type=all as a way to load all known log types for the specified host:
$ vmwb-lbcli download --project=myProj --host=192.168.1.106 --htype=esx --user=root --password=VMwar3rules --type=all
Loaded 8 log file types to project myProj:
vmware 192.168.1.106_vmware.logx
VMKernel 192.168.1.106_VMKernel.logx
hostd 192.168.1.106_hostd.logx
shell 192.168.1.106_shell.logx
syslog 192.168.1.106_syslog.logx
vpxa 192.168.1.106_vpxa.logx
fdm 192.168.1.106_fdm.logx
VMKwarning 192.168.1.106_VMKwarning.logx
Getting the Count of the Total Number of Visible Log Entries
The count command gives you the count of the number of log entries that are visible with the current filter applied (if there is one). There is an additional --nofilter command line option that will give you the unfiltered count if you wish to get that without removing the filter. In the example that follows, the number that shows below the command is the answer returned by the system.
$ vmwb-lbcli count --project=test --resource=192.168.1.106_hostd.logx
471686
Printing Log Entries to stdout
The print command, used to print log entries, is flexible in terms of the format of the reporting (txt, xml, json), as well as the number of entries it prints and the starting entry. You must specify at least the project and resource within the project as arguments to the command. Other arguments, such as formatting, are optional.
The following is an example of the default behavior, which is to print the first 30 entries matched by the currently applied filter, if one exists. In this example, there is no filter applied.
$ vmwb-lbcli print --project=test --resource=192.168.1.106_hostd.logx
1 | | | Section for VMware ESX, pid=2853, version=5.0.0, build=build-623860, option=Release | ------ In-memory logs start --------
2 | 2012-07-13 03:23:48.100 -0600 | FFE2BAC0 info 'Default' | Supported VMs 63 |
<snip...>
30 | 2012-07-13 03:23:48.104 -0600 | FFE2BAC0 info 'Default' | Trying hbrsvc |
Applying a Simple Filter
The filter command supports two kinds of filters: defining a simple filter dynamically with the --pattern option (a regex pattern), or applying a known named filter. In the following example, a simple filter is applied, the count of filtered entries is retrieved, and the entries are printed in XML format:
$ vmwb-lbcli filter --project=test --resource=192.168.1.106_hostd.logx --pattern="Event 157"
 
$ vmwb-lbcli count --project=test --resource=192.168.1.106_hostd.logx
2
 
$ vmwb-lbcli print --project=test --resource=192.168.1.106_hostd.logx --format=xml
<logItems>
<logItem>
<_>411049</_>
<Date>2012-08-03 16:25:32.215 -0600</Date>
<Source>47B01B90 info 'ha-eventmgr'</Source>
<Entry>Event 157 : User root logged out</Entry>
<EntryExtraLines/>
</logItem>
<logItem>
<_>471663</_>
<Date>2012-08-03 16:25:32.215 -0600</Date>
<Source>47B01B90 info 'ha-eventmgr'</Source>
<Entry>Event 157 : User root logged out</Entry>
<EntryExtraLines/>
</logItem>
</logItems>
Exporting Entries to a File
The print command is used to export entries. This can be done many different ways depending on your needs. Several examples are given.
stdout Redirection
The normal print command directs its output to stdout. You can redirect this to a file. This particular example also demonstrates the use of the --count and --format options:
$ vmwb-lbcli print --project=test --resource=192.168.1.106_hostd.logx --count=1 --format=json > myOutput.json
$ cat myOutput.json
{
"logItems": [
{
"#": "411049",
"Date": "2012-08-03 16:25:32.215 -0600",
"Source": "47B01B90 info 'ha-eventmgr'",
"Entry": "Event 157 : User root logged out",
"EntryExtraLines": ""
}
]
}
The --outfile Option
The print command also has an --outfile option for directly specifying the output file. This option has the advantage of being able to display a percentage complete status in the console as the download of the entries progresses. This may be of interest in the case of very large log files. The following example downloads a large number of log entries. (The --count=all option was used to specify all log entries.)
Note In this example, the filter was first removed with the filter command before printing. The --nofilter option on the print command could also have been used to do this without removing the filter.
$ vmwb-lbcli filter --project=test --resource=192.168.1.106_hostd.logx --remove
$ vmwb-lbcli print --project=test --resource=192.168.1.106_hostd.logx --format=xml --count=all --outfile=myFile.xml
Downloading log entries: 100% complete
Done writing to file /home/aspear/myFile.xml
downloaded 471686 entries in 62.909s (7497 entries/sec)
Finding Particular Entries and Printing Them
As an alternative to filtering, you can also use the find command to search for particular patterns. The find command by default returns the log entry number of the matching entries:
$ vmwb-lbcli find --project=test --resource=192.168.1.106_hostd.logx --pattern="Event 157"
411049
471663
You can print the entries in any given format using the --print option:
$ vmwb-lbcli find --project=test --resource=192.168.1.106_hostd.logx --pattern="Event 157" --print=txt
411049 | 2012-08-03 16:25:32.215 -0600 | 47B01B90 info 'ha-eventmgr' | Event 157 : User root logged out |
471663 | 2012-08-03 16:25:32.215 -0600 | 47B01B90 info 'ha-eventmgr' | Event 157 : User root logged out |
Finding Particular Entries and Failing if the Count is Not What You Expect
Both the find and count commands support a couple of additional options that can be useful for use cases such as automated regression testing:
--fail_if_count_equal <arg> Optional integer argument to check resulting line count                     against. If the count is equal to this number the command                     fails. Mutually exclusive with the fail_if_count_not_equal
                                    option.
--fail_if_count_not_equal <arg> Optional integer argument to check resulting line count                     against. If the count is NOT equal to this number the command                     fails. Mutually exclusive with the fail_if_count_equal
                                    option.
In the following example, Failure is used in a particular log file in the case of any error, and there are 17 instances of Failure that are known issues and always emitted in the log. As a part of an automated regression test, this log file could be checked and would fail if the count is more than 17 (failing in this case means that the vmwb-lbcli process returns an exit code of non-zero in addition to printing an error message to stderr).
$ vmwb-lbcli find --project=test --resource=192.168.1.106_hostd.logx --pattern="Failure" --fail_if_count_not_equal=17
1162
6916
(... 17 entry line numbers printed here)
464835
ERROR: Count 18 is not equal to fail_if_count_not_equal value 17.
Printing the Contents of a Local Log Bundle File
The bundle command allows printing of information on the contents of a log bundle, as well as loading all or a subset of the contained log file types in the bundle.
The following example prints the available log types in a bundle:
$ vmwb-lbcli bundle /home/aspear/logfiles/gss/vcsupport-2011-10-26.16479.zip
Examining log bundle /home/aspear/logfiles/gss/vcsupport-2011-10- 26.16479.zip ...
Available log types:
lookup Server
imsTrace
eam
stats
vpxd
jointool
ssoAdminServer
sso-service-cfg
SRM Recovery
Virgo Server
install
cim-dia
SRM Protected
sms
Loading Log Types from a Log Bundle
You can load log types from a bundle by adding one or more --load options to the bundle command. The load options specify the log types you wish to load. The command requires that you must specify a project name that you wish to load the given log types into. The following is an example of loading a couple of log types:
$ vmwb-lbcli bundle --project=test2 --load=vpxd --load=stats ~/logfiles/gss/vcsupport-2011-10-26.16479.zip
Loading log bundle /home/aspear/logfiles/gss/vcsupport-2011-10-26.16479.zip to project test2 ...
Loaded 2 log file types:
stats Local_stats_vmsp.logx
vpxd Local_vpxd_vmsp.logx
You can also specify --load=all to load all types in the bundle:
$ vmwb-lbcli bundle --project=test2 --load=all ~/logfiles/gss/vcsupport-2011-10-26.16479.zip
Loading log bundle /home/aspear/logfiles/gss/vcsupport-2011-10-26.16479.zip to project test2 ...
Loaded 14 log file types:
lookup Server Local_lookup_Server_vmsp.logx
imsTrace Local_imsTrace_vmsp.logx
eam Local_eam_vmsp.logx
stats Local_stats_vmsp.logx
vpxd Local_vpxd_vmsp.logx
jointool Local_jointool_vmsp.logx
ssoAdminServer Local_ssoAdminServer_vmsp.logx
sso-service-cfg Local_sso-service-cfg_vmsp.logx
SRM Recovery Local_SRM_Recovery_vmsp.logx
Virgo Server Local_Virgo_Server_vmsp.logx
install Local_install_vmsp.logx
cim-dia Local_cim-dia_vmsp.logx
SRM Protected Local_SRM_Protected_vmsp.logx
sms Local_sms_vmsp.logx
After the bundle is loaded, normal operations can be done against the file, such as finding, printing, and filtering, by referencing the project and resource names (printed in the previous example):
$ vmwb-lbcli print --project=test2 --resource=Local_vpxd_vmsp.logx --count=1 --first=10
10 | 2011-10-25 23:46:56.666 -0600 | EAFFF700 info 'ThreadPool' | Thread enlisted |