Go to main content

Oracle® ZFS Storage Appliance Administration Guide, Release OS8.7.x

Exit Print View

Updated: November 2018
 
 

Using the Children Function

Even in a context with static children, it can be useful to iterate over those children programmatically. This can be done by using the children function, which returns an array of static children.

  1. For example, here's a script that iterates over every service, printing out the status of the service:
    configuration services
    script
           var svcs = children();
           for (var i = 0; i < svcs.length; ++i) {
                    run(svcs[i]);
                    try {
                            printf("%-10s %s\n", svcs[i], get('<status>'));
                    } catch (err) { }
                    run("done");
           }
  2. Here's the output of running the script, assuming it were saved to a file named "svcinfo.aksh":
    % ssh root@koi < space.aksh
    Password: 
    cifs       disabled
    dns        online
    ftp        disabled
    http       disabled
    identity   online
    idmap      online
    ipmp       online
    iscsi      online
    ldap       disabled
    ndmp       online
    nfs        online
    nis        online
    ntp        online
    scrk       online
    sftp       disabled
    smtp       online
    snmp       disabled
    ssh        online
    tags       online
    vscan      disabled