Go to main content

Oracle® ZFS Storage Appliance 管理指南,发行版 OS8.8.0

退出打印视图

更新时间: 2018 年 11 月
 
 

使用 Choices 函数

Choices 函数将返回一组值已知且可枚举的任何属性的有效属性值的数组。例如,以下脚本将使用 choices 函数检索共享资源节点上所有池的列表,然后迭代所有池来列出项目和共享资源以及可用空间。

  1. 例如,以下脚本将使用 choices 函数检索共享资源节点上所有池的列表,然后迭代所有池来列出项目和共享资源以及可用空间。
    fmt = '%-40s %-15s %-15s\n';
    printf(fmt, 'SHARE', 'USED', 'AVAILABLE');
    run('cd /');
    run('shares');
    pools = choices('pool');
    for (p = 0; p < pools.length; p++) {
            set('pool', pools[p]);
            projects = list();
            for (i = 0; i < projects.length; i++) {
                    run('select ' + projects[i]);
                    shares = list();
                    for (j = 0; j < shares.length; j++) {
                            run('select ' + shares[j]);
                            share = pools[p] + ':' + projects[i] + '/' + shares[j];
                            printf(fmt, share, get('space_data'),
                                get('space_available'));
                            run('cd ..');
                    }
                    run('cd ..');
            }
    }
  2. 以下是运行该脚本的输出:
    SHARE                                    USED            AVAILABLE     
    pond:projectA/fs1                        31744           566196178944  
    pond:projectA/fs2                        31744           566196178944  
    pond:projectB/lun1                       21474836480     587670999040  
    puddle:deptA/share1                      238475          467539219283
    puddle:deptB/share1                      129564          467539219283
    puddle:deptB/share2                      19283747        467539219283