Administering TCP/IP Networks, IPMP, and IP Tunnels in Oracle® Solaris 11.2

Exit Print View

Updated: July 2014
 
 

Using the ipmpstat Command in Scripts

The –o option is useful when you run the ipmpstat command from a script or by using a command alias, particularly if you also want to generate machine-parsable output.

To generate machine-parsable information, you combine the –P and –o options with one of the other main ipmpstat options, along with the specific fields that you want to display.

    A machine-parsable output differs from normal output in the following ways:

  • Column headers are omitted.

  • Fields are separated by colons (:).

  • Fields with empty values are empty rather than filled with the double dash (--).

  • When multiple fields are requested, if a field contains a literal colon (:) or backslash (\), you can escape or exclude these characters by prefixing them with a backslash (\).

    To correctly use the ipmpstat –P command, observe the following rules:

  • Use the –o option field option with the –P option. Separate multiple option fields with commas.

  • Never use the –o all option with the –P option.


Caution

Caution  -  Ignoring either one of these rules causes ipmpstat –P to fail.


The following example shows the correct syntax for using the –P option:

% ipmpstat -P -o -g groupname,fdt,interfaces
ipmp0:10.00s:net0 net1
acctg1::[net3 net4]
field2:20.00s:net2 net7 (net5) [net6]

The group name, failure detection time, and underlying interfaces are group information fields. Thus, you use the –o and –g options along with the –P option.

The –P option is intended for use in scripts. The following example shows how you would run the ipmpstat command from a script. The script displays the failure detection time for an IPMP group.

getfdt() {
ipmpstat -gP -o group,fdt | while IFS=: read group fdt; do
[[ "$group" = "$1" ]] && { echo "$fdt"; return; }
done
}