#!/bin/bash
#Скрипт для мониторинга свободного места на NAS
_ssh_key=''
_ssh_user=''
_ssh_host=''
_ssh_disk=''
_ssh_opt='-oKexAlgorithms=diffie-hellman-group14-sha1 -oHostKeyAlgorithms=ssh-rsa'
if [[ -z "$1" ]]; then
echo "You need to add an argument to run this script"
exit 1
fi
case "$1" in
"total")
_number=1
;;
"used")
_number=2
;;
"free")
_number=3
;;
"precent")
_number=4
;;
"mount")
_number=5
;;
"full")
_number=0
;;
*)
_number=9
;;
esac
#echo "${_number}"
if [[ ${_number} -eq 9 ]]; then
echo "You need to use the correct argument to run this script"
echo -e "total - total dick space\nused - dick space used\nfree - free dick space\nprecent - precentage of free dick space\nmount - disk mounting locations"
exit 1
fi
_command="df |grep \"${_ssh_disk}\""
#echo "${_command}"
_df=`ssh -i ${_ssh_key} ${_ssh_opt} ${_ssh_user}@${_ssh_host} "${_command}"`
#echo "${_df}"
_print=`echo ${_df}| awk '{print $'${_number}'}'`
if [[ ${_number} -eq 0 ]]; then
echo "1K-blocks Used Available Use% Mounted on"
fi
echo "${_print}"
Понравилось это:
Нравится Загрузка...
Похожее
Свежие комментарии