Linux/Unix shell scripts monitor available disk space

Source: Internet
Author: User
Tags disk usage

Shell scripts used to monitor the free space of disks in Linux are required by system administrators or DBAs. The following is a sample shell script for monitoring disk space for your reference.

 

1. Monitor the free space shell script of the Disk

robin@SZDB:~/dba_scripts/custom/bin> more ck_fs_space.sh #!/bin/bash# ------------------------------------------------------------------------------+#                  CHECK FILE SYSYTEM SPACE BY THRESHOLD                        |#   Filename: ck_fs_space.sh                                                    |#   Desc:                                                                       |#       The script use to check file system space by threshold                  |#       Once usage of the disk beyond the threshold, a mail alert will be sent. |   #       Deploy it by crontab. e.g. per 15 min                                   |  #   Usage:                                                                      |#       ./ck_fs_space.sh <percent> </filesystem [/filesystem2]>                 |  #                                                                               |#   Author : Robinson                                                           | #   Blog   : http://blog.csdn.net/robinson_0612                                 |# ------------------------------------------------------------------------------+## -------------------------------#  Set environment here # ------------------------------if [ -f ~/.bash_profile ]; then    . ~/.bash_profilefiexport host=`hostname`export mail_dir=/users/robin/dba_scripts/sendEmail-v1.56export mail_list='Robinson.cheng@12306.com'export mail_fm='oracle@szdb.com'tmpfile=/tmp/ck_fs_space.txtalert=n# --------------------------------#  Check the parameter# --------------------------------max=$1if [ ! ${2} ]; then    echo "No filesystems specified."    echo "Usage: ck_fs_space.sh 90 / /u01"    exit 1fi# --------------------------------#  Start to check the disk space# --------------------------------while [ "${2}" ]    do        percent=`df -P ${2} | tail -1 | awk '{print $5 }' | cut -d'%' -f1`        if [ "${percent}" -ge "${max}" ]; then            alert=y            break        fi;        shift    done;# ------------------------------------------------------------------------#  When a partition was above the threshold then send mail with df output# ------------------------------------------------------------------------if [ ! "${alert}" = 'n' ];then    df -h >$tmpfile    mail_sub="Disk usage beyond the threshold ${max} on ${host}."    $mail_dir/sendEmail -u ${mail_sub} -f $mail_fm -t $mail_list -o message-file=${tmpfile}fi;exit;

2. Script description
A. The script uses the sendemail tool to send emails.
B. The usage is "Usage: ck_fs_space.sh 90 // u01 ".
C. a while loop is used in the script to determine whether the free space of all specified partitions exceeds the threshold value one by one.
D. send an email when the threshold value is exceeded and attach the disk space usage of the current server.

 

For more information, see:

For more information about Oracle RAC, see
Use crs_setperm to modify the resource owner and permissions of RAC.
Use crs_profile to manage RAC resource configuration files
RAC database startup and Shutdown
Oracle RAC services
Services in Oracle Database 10g
Migrate datbase from single instance to Oracle RAC
Connect Oracle RAC to a specified instance
Oracle RAC load balancing test (combined with server and client)
Oracle RAC server connection Load Balance)
Load Balance)
Non-Default port listening configuration in Oracle RAC (listener. ora tnsnames. ora)
Oracle RAC Listener Configuration (listener. ora tnsnames. ora)
Configure RAC load balancing and Failover
CRS-1006, CRS-0215 fault case
Installing Oracle 10g RAC Based on Linux (RHEL 5.5)
Use runcluvfy to verify the Oracle RAC installation environment

For more information about the basics and concepts of Oracle network configuration, see:
Configure dynamic service registration for non-default ports
Configure sqlnet. ora to restrict IP Access to Oracle
Configure and manage Oracle listener logs
Set the Oracle listener password (listener)
Configure the Oracle client to connect to the database

For more information about user-managed backup and recovery, see
Oracle cold backup
Oracle Hot Backup
Concept of Oracle backup recovery
Oracle instance recovery
Oracle recovery based on user management
System tablespace management and Backup Recovery
Sysaux tablespace management and recovery
Oracle backup control file recovery (unsing backup controlfile)

For information on RMAN backup recovery and management, see
RMAN overview and architecture
RMAN configuration, Monitoring and Management
Detailed description of RMAN backup
RMAN restoration and recovery
Create and use RMAN catalog
Create RMAN storage script based on catalog
Catalog-based RMAN backup and recovery
RMAN backup path confusion
Use RMAN for recovery from different machine backups (WIN platform)
Use RMAN to migrate a file system database to ASM
Linux RMAN backup shell script
Use RMAN to migrate the database to a different machine

For the Oracle architecture, see
Oracle tablespace and data files
Oracle Password File
Oracle parameter file
Oracle online redo log file)
Oracle Control File)
Oracle archiving logs
Oracle rollback and undo)
Oracle database instance startup and Shutdown Process
Automated Management of Oracle 10g SGA
Oracle instances and Oracle databases (Oracle Architecture)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.