#!/bin/bash source /etc/profile cur_time=$(date "+%Y-%m-%d-%H-%M-%S") echo $cur_time "-1" >> /mnt/xyzshop/util/a.log df_dirs=(${XYZ_DF_DIRS//:/ }) du_dirs=(${XYZ_DU_DIRS//:/ }) echo $cur_time "-2" >> /mnt/xyzshop/util/a.log echo $XYZ_DF_DIRS "-2" >> /mnt/xyzshop/util/a.log echo $cur_time "-2" >> /mnt/xyzshop/util/a.log declare -A reports reports=(['cur_time']=$cur_time) function df_check() { # shellcheck disable=SC2068 for dir in ${df_dirs[@]} do ret=$(df -h | grep $dir | awk 'BEGIN{OFS=","}{print $2,$4}') key=${dir////_} reports[$key]=$ret done } function du_check() { # shellcheck disable=SC2068 for dir in ${du_dirs[@]} do cd $dir ret=$(du -h -d 0) key=${dir////_} reports[$key]=$ret done } df_check echo $cur_time "-3" >> /mnt/xyzshop/util/a.log du_check echo $cur_time "-4" >> /mnt/xyzshop/util/a.log str_report='' for key in $(echo ${!reports[*]}) do str_report="$str_report#$key:${reports[$key]}" done echo $str_report >> /mnt/xyzshop/util/a.log redis_host=$XYZ_REDIS_HOST netip=$XYZ_NETIP echo "HSET nc_disk_monitor $netip '$str_report'" | redis-cli -h $redis_host -p 6379 echo $cur_time "-6" >> /mnt/xyzshop/util/a.log