EMC has added a hidden query option on some of the nas commands that allows you to directly query the NAS database. I’ve tested the ‘-query’ option n the nas_fs, nas_server, nas_slice and nas_disk commands, however it may be available on other commands as well. It’s a powerful command with a lot of options, so I took some time to play around with it today. The EMC documentation on this option in their command line reference guide is very sparse and I haven’t done much experimentation with it yet, but I thought I’d share what I’ve found so far.
You can view all of the possible query tags by typing in the commands below. There are dozens of tags available for query. The output list for all the commands is large enough that it’s not practical to add it into this blog post.
nas_fs -query:tagsnas_server -query:tags
nas_slice -query:tags
nas_disk -query:tags
Here’s a snippet of the tags available for nas_fs (the first seven):
Supported Query Tags for nas_fs:Tag Synopsis
———————————————————–
ACL The Access Control List of the item
ACLCHKInProgress Is ACLCHK running on this fs?
ATime The UTC date of the item’s table last access
AccessPolicyTranslationErrorMessage The error message of the MPD translation error, if any.
AccessPolicyTranslationPercentComplete The percentage of translation that has been completed by the Access Policy translation thread for this item.
AccessPolicyTranslationState The state of the Access Policy translation thread for this item.
AutoExtend Auto extend True/False
The basic syntax for a query looks like this:
nas_fs -query:inuse==y:type=uxfs:IsRoot=False -Fields:Name,Id,StoragePoolName,Size,SizeValues -format:’%s,%s,%s,%d,%d\n’
In the above example, we are running the query based on three options. We want the file system to be in use, be of the type uxfs, and not be root. In the fields parameter, we want the file system’s name, ID, Storage Pool name, size, and size values. Because our output has five fields, and we want each file system to have it’s own line in the output, we add five formatting options separated by commas (for a csv type output), followed by a ‘\n’ to create a carriage return after each file system’s information has been outputted.
Here are the valid query operators:
= pattern match
== exact match
=- not less than
=+ not more than
=* any
=^ not having pattern
=^= not an exact match
=^- is less than
=^+ is greater than
=^* not any (none)
The format option is not well documented. The only parameters I’ve used for the format option are q and s. From what I’ve seen from testing the options, The tag used in the ‘-fields’ parameter is either simple or complex. A complex tag must be formatted with q, a simple tag must be formatted with s. Adding the ‘\n’ to the format option adds a carriage return to the output. If you use the wrong format parameter, it will display an error like this: “Error 2110: Invalid query syntax: the tag (‘[Tag Option]‘) corresponding to this format specifier (“%q”) is not a complex tag”.
-format:’%s’ : Simple Formatting
-format:’%q’ : Complex Formatting
Below are some examples of using the query option. I will add more useful examples in the future after I’ve had more time to dive in to it.
To get the file system ID:
nas_fs -query:Name==[file system name] -format:’%s\n’ -fields:VolumeID
List all file systems with their sizes:
nas_fs -query:inuse==y:type=uxfs:IsRoot=False -Fields:Name,Id,StoragePoolName,Size,SizeValues -format:’%s,%s,%s,%d,%d\n’
List all file system quotas on the array:
nas_fs -query:\* -fields:ID,TreeQuotas -format:’%s:\n%q#\n’ -query:\* -fields:FileSystem,Path,BlockHardLimit,BlockSoftLimit,BlockGracePeriod,BlockUsage -format:’%s : %s : %s : %s : %s : %s\n’
List all quotas for a specific file system:
nas_fs -query:name=[File System] -fields:TreeQuotas -format:’%q’ -query:\* -fields:FileSystem,Path,BlockHardLimit,BlockSoftLimit,BlockGracePeriod,BlockUsage -format:’%s : %s : %s : %s : %s : %s\n’
List all Checkpoint file systems:
nas_fs -query:inuse=y:type=ckpt:isroot=false -fields:ServersNumeric,Id,Name,SizeValues -format:’%s,%s,%s,%s\n’
List all the Server_params for a specific server_X:
nas_server -query:Name==server_2 -format:’%q’ -fields:ParamTable -query:Name== -fields:ChangeEffective,ConfiguredDefaultValue,ConfiguredValue,Current,CurrentValue,Default,Facility,IsRebootRequired,IsVisible,Name,Type,Description -format:’%s|%s|
%s|%s|%s|%s|%s|%s|%s|%s|%s|%s\n’
List the current Wins/DNSDomain Config:
nas_server -query:Name=server -fields:Name,DefaultWINS,DNSDomain -format:”%s,%s,%s\n”