0

Скрипт свободного места на диске/NAS

#!/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}"

Свежие комментарии

Подписка

Лучшие статьи


Fatal error: Uncaught Error: Call to a member function have_posts() on null in /home/host1867038/the-devops.ru/htdocs/www/wp-content/themes/fox/inc/blog.php:398 Stack trace: #0 /home/host1867038/the-devops.ru/htdocs/www/wp-content/themes/fox/widgets/latest-posts/widget.php(257): fox56_blog_grid(NULL, Array) #1 /home/host1867038/the-devops.ru/htdocs/www/wp-content/themes/fox/widgets/latest-posts/register.php(33): include('/home/host18670...') #2 /home/host1867038/the-devops.ru/htdocs/www/wp-includes/class-wp-widget.php(394): Wi_Widget_Latest_Posts->widget(Array, Array) #3 /home/host1867038/the-devops.ru/htdocs/www/wp-includes/widgets.php(845): WP_Widget->display_callback(Array, Array) #4 /home/host1867038/the-devops.ru/htdocs/www/wp-content/themes/fox/inc/single.php(418): dynamic_sidebar('sidebar') #5 /home/host1867038/the-devops.ru/htdocs/www/wp-content/themes/fox/inc/single.php(136): fox56_single_sidebar() #6 /home/host1867038/the-devops.ru/htdocs/www/wp-content/themes/fox/inc/single.php(7): fox56_single_inner() #7 /home/host1867038/the-devops.ru/htdocs/www/wp-content/themes/fox/single.php(23): fox56_single() #8 /home/host1867038/the-devops.ru/htdocs/www/wp-includes/template-loader.php(106): include('/home/host18670...') #9 /home/host1867038/the-devops.ru/htdocs/www/wp-blog-header.php(19): require_once('/home/host18670...') #10 /home/host1867038/the-devops.ru/htdocs/www/index.php(17): require('/home/host18670...') #11 {main} thrown in /home/host1867038/the-devops.ru/htdocs/www/wp-content/themes/fox/inc/blog.php on line 398