hdfs文件以千兆字节排序

inkz8wg9  于 2021-05-27  发布在  Hadoop
关注(0)|答案(1)|浏览(419)

我正在尝试自动化hdfs用户空间利用邮件。
除了以gb为单位对文件进行排序外,一切都是正确的。当我尝试使用字节时,它给出了正确的结果,但在另一方面,它没有达到预期的输出。
请帮我得到正确的输出。
我将提供在hdfs文件系统中以字节和可读的-h运行的脚本。


# !/bin/bash

# getting the current hdfs percentage in numeric value

CURRENT=$(hdfs dfs -df -h/ | grep / | awk '{ print $8}' | sed 's/%//g')

# current hdfs space utilisation

DiskFile=$(hdfs dfs -df -h)

HdfsReport=$(hdfs dfsadmin -report)

Diskuse=$(hdfs dfs -du  /user | sort -nr | head -10)

# To get results GB i have provided $(hdfs dfs -du -h  /user | sort -r | head -10)

THRESHOLD=70
Critical=90

if [ "$CURRENT" -gt "$THRESHOLD" ] ; then

mail -s 'HDFS Usage Housekeeping required' @abc.com, @abc.com << EOF
HDFS usage in Cluster is above the threshold please run the clean-up scripts asap. Used: $CURRENT%

Current disk utilization report is
$DiskFile

Please find the Utilisation report of top ten users consuming the cluster

$Diskuse

EOF
fi

if [ "$CURRENT" -gt "$Critical" ] ; then

mail -s 'HDFS Admin Report' yy@abc.com, yyy@abc.com << EOF
HDFS usage in Cluster is above critical storage, please Find the Cluster report below

$HdfsReport

EOF
fi
hrysbysz

hrysbysz1#

您是否尝试过在sort命令中使用“human”格式 sort -rh 我没有dfs,但下面的示例命令列出/排序我当前目录中最大的10个目录:

du -hsx * | sort -rh | head -10

相关问题