Use UDCs to Collect Devices by Name Pattern in VirtualWisdom

Virtually all SAN devices that are zoned for traffic have names (in fact, if you have nicknames/aliases in your zone files, then you can directly convert zone info to nicknames). VirtualWisdom’s filtering capabilities allow you to restrict a Dashboard, Report, or Alarm Policy Ruleset to a specific datacenter or business unit, but often creating those UDCs can be cumbersome.

A recent customer created UDCs with 192 values across three metric sets, allowing him to group data by specific servers, storage, and virtualizers automatically; this “how-to” is intended to show how you can do the same.

Process Overview

For this process, we need only a set of nicknames; the simpler old-format nickname file looks like:

500604825D2E2144,"DMX1911_FA3AA"
2100001B329FE31D,"Billing44_HBA0"
10000000C741ABCD,"4241_7b1"

(Notice: WWN first, no spaces, optional quotes for safety)

Generate UDC Values from Nickname Pattern

Our flow for this process or pipeline looks like the following diagram:
Flow of a UDC generated by pattern from Nicknames

The tool we use here is “awk”, or “awk.exe”, or “gawk.exe”; in Solaris, look for “nawk”. It’s on virtually every non-Windows system, Microsoft has a version in its tools for UNIX, or Google may help you find a copy. As well, UnxUtils has a version.

Awk is an interpreter, so needs a script or program, and for that, we use TransformUDC.awk which takes the following parameters:

parameter Meaning
COL What column in the CSV input is the Nickname? (default: 1)
NAMEFCX_LINK Name of the ProbeFCX::Link UDC
NAMEFCX_SCSI Name of the ProbeFCX::SCSI UDC
NAMEFCX_SCSIINIT Name of the ProbeFCX::SCSI UDC, matching Initiators only
NAMEFCX_SCSITARG Name of the ProbeFCX::SCSI UDC, matching Targets only
NAMESW Name of the ProbeSW::Link UDC (default: Transformed_UDC)
TRANSFORM Transform (basically the ‘s/x/y/g’ in a “sed -e ‘s/x/y/g’” command) (default: remove last two _sect_sect: DC_Serv1_fcs0_SW12P121 –> DC_Serv1)
UDCDEFAULT Default value for UDCs (default: Unknown)

A simple command such as the following will generate our results:

gawk.exe -f TransformUDC.awk Nicknames.csv

In our nickname file, the older format (first and second variant up to VW-3.1) gave us the nickname as the second parameter, so let’s tell the script that the nickname is in column #2:

gawk.exe -v COL=2 -f TransformUDC.awk Nicknames.csv

The problem is: how do we want the UDC values defined? If you’ve used “sed” or “awk” before, there’s a basic replacement term that looks like s/dog/cat/g or gsub("dog","cat",$0) … this part really depends on your nickname format, but looking above, we have nicknames that look like:

500604825D2E2144,"DMX1911_FA3AA"
500604825D2E2145,"DMX1911_FA4AA"
500604825D2E7744,"DMX1927_FA3AA"
500604825D2E7745,"DMX1927_FA4AA"
500604825D2E7747,"DMX1927_FA6AA"
500604825D2E7748,"DMX1927_FA7AA"
500604825D2E774C,"DMX1927_FA13AA"
500604825D2E774D,"DMX1927_FA14AA"
2100001B329FE35D,"Billing43_HBA0"
2100001B329FE35E,"Billing43_HBA1"
2100001B329FE31D,"Billing44_HBA0"
2100001B329FE31E,"Billing44_HBA1"
10000000C741ABCD,"4241_7b1"

We see how, in this example, chopping off everything after the “_” gives names such as “Billing43″ and “DMX1927″. In see and awk, we would write: s/_.*$//g so we’ll use that as our transform. How can we test this?

Trim Quotation Marks

We could trim off the quotation marks around the second field using this: (“,” as field-separator, convert (“) to (), an empty replacement)

gawk -F, '{gsub("\"","",$2); print; }' Nicknames.csv

… unfortunately, we need to use quotation marks for the script, and then we need a bunch of “\” escape sequences, so it looks much more complex running it:

gawk.exe -F, "{gsub(\"\\\"\",\"\",$2); print; }" Nicknames.csv

… which looks like:

awk Transforms: Trim Quotations

Truncate All After “_”

Based on the example above, we can now test whether our transform (“s/._*$//g”, or gsub(“._*$”,””,…) ) gives us the results we want, such as (notice: “print $2″, so we’ll only see the second field):

gawk.exe -F, "{gsub(\"\\\"\",\"\",$2); gsub(\"_.*$\",\"\",$2); print $2; }" Nicknames.csv

… which looks like:
awk Transforms: Trim Quotations, Trim Nickname

This means our transform works, so let’s use it in the script:

gawk.exe -v TRANSFORM="s/_.*$//g" -v COL=2 -f TransformUDC.awk Nicknames.csv

Unfortunately, “4241″ is not worthwhile to us because it’s only one matching name, so let’s trim that one off by saying “minimum of 2 matching names per UDC value”:

gawk.exe -v MIN=2 -v TRANSFORM="s/_.*$//g" -v COL=2 -f TransformUDC.awk Nicknames.csv

Finally, What do we want to call the UDC? The tool always generates a ProbeSW::Link UDC, and if unnamed, defaults to “Transformed_UDC”. The Name of the UDC is limited to 32 characters, and values themselves to 24 characters; the name of the UDC becomes the name of the “metric” or context that we are generating. Suppose while working at XYZ Cheese and Dairy Distributors, we want a UDC called xyz-SW-BizUnit (we need to use “_” rather than “-”):

gawk.exe -v NAMESW="xyz_SW_BizUnit" -v MIN=2 -v TRANSFORM="s/_.*$//g" -v COL=2 -f TransformUDC.awk Nicknames.csv

Let’s run this with a redirection (“>”) to store the results to a file:

gawk.exe -v NAMESW="xyz_SW_BizUnit" -v MIN=2 -v TRANSFORM="s/_.*$//g" -v COL=2 -f TransformUDC.awk Nicknames.csv > \VirtualWisdomData\UDCImport\xyz-UDCs.udc

Running this as a command in cmd.exe is relatively quiet because this is a non-interactive command. It tends to look like the following:

gawk -f TransformUDC Nicknames.csv to xyz-UDC.udc

Importing this example, we see the following (you’ll note: the default has also been set using “-v UDCDEFAULT=Other”) :

Generated UDC values as viewed in VW Views

Schedule UDC Import

Creating the schedule is relatively straight-forward: although there is some strong guidance in the VirtualWisdom User Guide, a complete example would like like the following:

  1. Views Application, Setup tab: Views Application, Setup Tab
  2. “Schedules” page, roughly 5th item down: Views Application, Setup Tab, Schedules page
  3. Create a new Schedule, with the action “Import UDC configurations”: Import xyz-UDCs Schedule in Views
  4. …and configure it to use a new UDC Importing Configuration, as follows. NOTE we only use a local filename, all files are in the \UDCImport\ directory of your VirtualWisdomData folder:Vies Application, Setup Tab, UDC Import Configuration (shortened)

The benefit here is that the UDC always replaces existing values without prompting. As well, after import, a UDC re-calculates values for both past summaries and new summaries. This allows you to “fix history” if your UDC is not quite correct the first time.

Convert Zone Info to Nicknames for VirtualWisdom

VirtualWisdom uses “Nicknames” or “Aliases” to give human-readable names to attached SAN devices, reducing the time to locate a problem device, but also to help group devices logically as being the same server or storage, and into business units for SLAs and escalation of issues.

We know that Nickname management can be a hassle, but the obvious gains make it worthwhile, so some of our work in Services is helping customers draw this data from existing repositories such as fabric Zoning information. Maintaining aliases in your zones, then converting those to nicknames, means that you only need to maintain one repository of names.

This “How-to” article is targeted at showing how to do this in common environments. As a VI Application Engineer, my content on this feed tends to be more of a lower-level “how to” in nature. This content has been in our internal self-help content, but may be difficult to find.

Collection, then Conversion

Diagram of data-flow of nicknames from switches to VirtualWisdom

The general process tends to be collecting the data, then converting to a compatible format for import. Let’s focus first on Collection, which tends to be a script running at scheduled times during the day or week.

Scripting under Schedule

This tends to be done as a batch file that is triggered through a scheduler such as the Windows Scheduler running a BAT file, or a UNIX-like OS running a shell script from cron or as a passive check under tools such as Icinga.

Where fabric-wide data is used, only one switch per fabric needs be queried. I tend to use the least-busy switch to avoid adding any load to Core switches or other busy switches.

Will DBTools Work for You?
The easiest method if you have small switches is to use \Program FilesVirtual Instruments\VirtualWisdom\UnSupported\DBTools\DBTools.exe tool, but running it as a batch command. This tool will connect to the switch using SSH, query the information, and convert it to the right format for import. In essence, the collection and conversion is a single step. For example, using the example username “scott”, password “tiger”, switch IP 192.168.0.1, to a file FabricA.csv in the import directory:

Brocade “alishow”: (the command is all on one line)
DBToolScript.bat -n -st brocade -u scott -p tiger -ip 192.168.0.1 D:\VirtualWisdomData\DeviceNickname\FabricA.csv

Cisco “fcalias”:
DBToolScript.bat -n -st cisco -u scott -p tiger -ip 192.168.0.1 D:\VirtualWisdomData\DeviceNickname\FabricA.csv

For example:

screen cap of the DBToolScript -n run
(In this example, my demo server has the database on the C: drive; this is not the recommended config for production servers! Also, notice how the DBToolScript cannot open a log file — running this command in your VirtualWisdomData directory will allow it to write a log to .\Log\DBToolLog\ )

Putting commands such as this into a batch file running daily via Windows Scheduler, and configuring a scheduled Import via the VirtualWisdom Scheduler, your job is complete!

The DBTools command doesn’t understand all possible nickname sources, and may have problems on some switches; if this method doesn’t work for you, then we resort to the two-stage process. This less-polished method is a bit more versatile, but isn’t as pretty. Once configured, though, it tends to work reliably.

Collection

The more manual collection can be done from four different sources:

  1. Brocade Switch using “zoneshow”
  2. Brocade Switch using “alishow”
  3. Cisco Switch using “show device-alias database”
  4. Cisco Switch using “show fcalias”

Collection requires non-interactive SSH tools such as plink.exe available from the makers of Putty; google should help you find it, but if you cannot, VI can help redirect you. The general command is:

plink.exe -l username -pw password IP.IP.IP.IP "command" > intermediate.file

For example: (using scott, tiger, 192.168.0.1, and a Brocade/zoneshow switch)

plink.exe -l scott -pw tiger 192.168.0.1 zoneshow > sw-192.168.0.1.zone

… and a Cisco/”show device-alias database” at 192.168.0.3:

plink.exe -l scott -pw tiger 192.168.0.3 "show device-alias database" > sw-192.168.0.3.cisco

These commands give no output when they run, except the first time: the plink.exe command wants you to accept a key to later ensure you are not vulnerable to a man-in-the-middle attack, which looks like the following: (accept the key once, later you won’t be asked unless it changes)

Again, you only need to collect zoning information or fabric-wide alias information from one switch per zone. With a unique filename per fabric, you’re ready to convert these files.

Conversion

Brocade and Cisco tend to use consistent formats for their outputs, but they are in text format. Most times, the two scripts work for this. These are scripts for the “awk” tool, which can be extracted from the UnxUtils project, or using Microsoft’s tools for UNIX. Either method gives you a “awk.exe” or a “gawk.exe”, which will execute these scripts:

  1. brocade-alishow2wwncsv.awk
  2. cisco-devicealias2wwncsv.awk

Conversion of a Brocade zonecfg or alishow is done as:

gawk.exe -f brocade-alishow2wwncsv.awk sw-192.168.0.1.zone > D:\VirtualWisdomData\DeviceNickname\FabricA.csv

Whereas conversion of a Cisco device-alias database or fcalias is done as:

gawk.exe -f cisco-devicealias2wwncsv.awk sw-192.168.0.3.cisco > D:\VirtualWisdomData\DeviceNickname\FabricB.csv

Note: these runs are redirecting output to files, so these commands give no visible output to the cmd.exe screen except in the case of errors.

Complete Example

A complete example of collection and conversion may look like the following code. Be aware, we tend to recommend using full pathnames (i.e. C:\Program Files\something\else\plink.exe) to ensure the commands are found regardless %PATH% variable and working directory. This example is simplified to be more readable but does run as-is given the right environment and working directory.

@echo off

plink.exe -l scott -pw tiger 192.168.0.1 "show device-alias database" > sw-192.168.0.1.cisco
plink.exe -l scott -pw tiger 192.168.0.2 "show fcalias" > sw-192.168.0.2.cisco
plink.exe -l scott -pw tiger 192.168.0.3 "zoneshow" > sw-192.168.0.3.zone
plink.exe -l scott -pw tiger 192.168.0.4 "alishow" > sw-192.168.0.4.zone

gawk.exe -f brocade-alishow2wwncsv.awk sw-192.168.0.3.zone sw-192.168.0.4.zone > nicknames.csv
gawk.exe -f cisco-devicealias2wwncsv.awk sw-192.168.0.1.cisco sw-192.168.0.2.cisco >> nicknames.csv

This example generates a single file; the configuration to import this one file is as follows (briefly shown here because the User Guide has more detail regarding Schedules):

  1. Views Application, Setup tab: Views Application, Setup Tab
  2. “Schedules” page, roughly 5th item down: Views Application, Setup Tab, Schedules page
  3. Create a new Schedule, with the action “Import WWN Nicknames”: Views Application, Setup Tab, Nickname Import Schedule
  4. …and configure it to use a new WWN Importing Configuration, as follows. NOTE we only use a local filename, all files are in the \DeviceNickname directory of your VirtualWisdomData folder:Nickname Import configuration, nicknames.csv