sh BrickstorOS的容量,使用和配额

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh BrickstorOS的容量,使用和配额相关的知识,希望对你有一定的参考价值。

#!/bin/sh
# Copyright 2017 RackTop Systems Inc. and/or its affiliates.
# http://www.racktopsystems.com
#
# The methods and techniques utilized herein are considered TRADE SECRETS
# and/or CONFIDENTIAL unless otherwise noted. REPRODUCTION or DISTRIBUTION
# is FORBIDDEN, in whole and/or in part, except by express written permission
# of RackTop Systems.
#
###############################################################################
# Script: getquota.sh
###############################################################################
# Description: Obtains quota and refquota information for datasets listed in
# the $DATASETS list and reports infromation using machine-parceable CSV.
# The header is expected to print at all times, but there may not always be
# data following it.

DEBUG=0 # Flip this to >0 to enable debugging, not much to debug yet!

[ ${DEBUG} -gt 0 ] && set -o xtrace
ROOT=p01/global # Default root, should be changed based on pool name.
# These are paths relative to ${ROOT}. In other words real path might look
# like this: p01/global/afp/010.
DATASETS=( "${ROOT}/afp/00" "${ROOT}/nfs/00" "${ROOT}/smb/00/02" )
TRIMNAME=1 # If we want to trim all but the last part of zfs path set to 1.

# getDataFromDataset: Queries ZFS and obtains jason-formatted
# information for given dataset which contains only columns of
# interest to us. Data is properly arranged and printed to stdout.
function getDataFromDataset {
    [ ${DEBUG} -gt 0 ] && set -o xtrace
    
    typeset -A a
    dataset=$1
    result=`/usr/racktop/sbin/fsadm -j zp get \
      --fields name,used,avail,refquota,quota \
      -r \
      -f \
      ${dataset}`

    # This will happen if a given dataset name is not valid,
    # or not legal. We don't even want to attempt to print out
    # anything, since really we'll get commas.
    if [ "${result}" == "null" ] ; then return ; fi

    # There are 5 columns in output. We want to create a hash/map
    # of names of those columns to their values.
    for (( i = 0 ; i < 5 ; i++ )) ; do
        name=`jq -r ".[$i].Name" <<< "${result}"`
        value=`jq -r ".[$i].Value" <<< "${result}"`
        if [[ $name == "name" && ${TRIMNAME} -eq 1 ]]; then
            value=`basename ${value}`
        fi
        a[${name}]=${value}
    done

    # Print values in predictable order, separated with commas,
    # terminated with a newline `\n`.
    printf "%s,%s,%s,%s,%s\n" \
        ${a["name"]} ${a["used"]} ${a["avail"]} \
        ${a["refquota"]} ${a["quota"]}
}

echo "NAME,USED,AVAIL,REFQUOTA,QUOTA"
# For each valid dataset listed in the DATASETS list, print out
# a line, CSV-formatted containing quota information.
for ds in ${DATASETS[@]}; do
    getDataFromDataset ${ds}
done

以上是关于sh BrickstorOS的容量,使用和配额的主要内容,如果未能解决你的问题,请参考以下文章

sh BrickstorOS启动池(bp)设置和修改

sh 控制BrickstorOS上的活动核心

sh BrickStorOS配置调整脚本

sh BrickstorOS过程信息

sh BrickstorOS安装程序

quota磁盘配额