Commit 651381d1 authored by PENGUEN Julien's avatar PENGUEN Julien

ajout WARNING LEVEL + gestion info pour volume mont‚ ou volume par d‚faut

parent 59d75d38
......@@ -41,10 +41,12 @@ RESOLUTION_BY_COL=500
FORMAT_IMAGES=jpg
FORMAT_MONTAGES=jpg
CRITICAL_LEVEL_DISK_SPACE_PERCENTAGE=80
WARNING_LEVEL_DISK_SPACE_PERCENTAGE=90
CRITICAL_LEVEL_DISK_SPACE_PERCENTAGE=98
RED='\033[0;31m' #Red
GREEN='\033[0;32m' # Green
YELLOW='\033[0;33m' # Yellow
COLOR_OFF='\033[0m' # Text Reset
UNDERLINE_BEGIN='\e[4m'
UNDERLINE_END='\e[24m'
......
......@@ -1261,17 +1261,27 @@ case ${sort_arg_keys[0]} in
exit 0
else
info_volume_total=$(df -h ${VOLUME_MOUNT} | tail -n 1 | awk -F " " '{print $2}')
info_volume_free=$(df -h ${VOLUME_MOUNT} | tail -n 1 | awk -F " " '{print $4}')
info_percentage=$(df -h ${VOLUME_MOUNT} | tail -n 1 | awk -F " " '{print $5}')
info_percentage_number=$(df -h ${VOLUME_MOUNT} | tail -n 1 | awk -F " " '{print $5}'| sed 's/%//')
if [ $(( $info_percentage_number )) -lt ${CRITICAL_LEVEL_DISK_SPACE_PERCENTAGE} ]; then
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $VOLUME_MOUNT $GREEN "INFOS"
if [ $VOLUME_MOUNT == "NONE" ]; then
volume_used="/home/$USER"
else
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $VOLUME_MOUNT $RED "WARNING"
volume_used=$VOLUME_MOUNT
fi
info_volume_total=$(df -h ${volume_used} | tail -n 1 | awk -F " " '{print $2}')
info_volume_free=$(df -h ${volume_used} | tail -n 1 | awk -F " " '{print $4}')
info_percentage=$(df -h ${volume_used} | tail -n 1 | awk -F " " '{print $5}')
info_percentage_number=$(df -h ${volume_used} | tail -n 1 | awk -F " " '{print $5}'| sed 's/%//')
if [ $(( $info_percentage_number )) -lt ${WARNING_LEVEL_DISK_SPACE_PERCENTAGE} ]; then
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $volume_used $GREEN "INFOS"
elif [[ $(( $info_percentage_number )) -gt ${WARNING_LEVEL_DISK_SPACE_PERCENTAGE} && $(( $info_percentage_number )) -lt ${CRITICAL_LEVEL_DISK_SPACE_PERCENTAGE} ]]; then
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $volume_used $YELLOW "WARNING"
sleep 5
else
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $volume_used $RED "WARNING CRITICAL"
exit 0
fi
fi
......
......@@ -1277,17 +1277,27 @@ case ${sort_arg_keys[0]} in
exit 0
else
info_volume_total=$(df -h ${VOLUME_MOUNT} | tail -n 1 | awk -F " " '{print $2}')
info_volume_free=$(df -h ${VOLUME_MOUNT} | tail -n 1 | awk -F " " '{print $4}')
info_percentage=$(df -h ${VOLUME_MOUNT} | tail -n 1 | awk -F " " '{print $5}')
info_percentage_number=$(df -h ${VOLUME_MOUNT} | tail -n 1 | awk -F " " '{print $5}'| sed 's/%//')
if [ $(( $info_percentage_number )) -lt ${CRITICAL_LEVEL_DISK_SPACE_PERCENTAGE} ]; then
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $VOLUME_MOUNT $GREEN "INFOS"
if [ $VOLUME_MOUNT == "NONE" ]; then
volume_used="/Users/$USER"
else
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $VOLUME_MOUNT $RED "WARNING"
volume_used=$VOLUME_MOUNT
fi
info_volume_total=$(df -h ${volume_used} | tail -n 1 | awk -F " " '{print $2}')
info_volume_free=$(df -h ${volume_used} | tail -n 1 | awk -F " " '{print $4}')
info_percentage=$(df -h ${volume_used} | tail -n 1 | awk -F " " '{print $5}')
info_percentage_number=$(df -h ${volume_used} | tail -n 1 | awk -F " " '{print $5}'| sed 's/%//')
if [ $(( $info_percentage_number )) -lt ${WARNING_LEVEL_DISK_SPACE_PERCENTAGE} ]; then
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $volume_used $GREEN "INFOS"
elif [[ $(( $info_percentage_number )) -gt ${WARNING_LEVEL_DISK_SPACE_PERCENTAGE} && $(( $info_percentage_number )) -lt ${CRITICAL_LEVEL_DISK_SPACE_PERCENTAGE} ]]; then
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $volume_used $YELLOW "WARNING"
sleep 5
else
function_message "TYPE_MOUNT_INFOS" "Disk Space: $info_volume_total, Disk Space Free: $info_volume_free, Space disk pourcentage used: $info_percentage" $volume_used $RED "WARNING CRITICAL"
exit 0
fi
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment