Shell脚本实现硬盘空间和表空间的使用情况统计并邮件通知
网络编程
#/bin/bash #该脚本用于统计硬盘空间和表空间的使用情况,并邮件发出 #初始化环境变量 source /home/oracle/.bash_profile #获得本机ip ip=`/sbin/ifconfig eth0 | grep Bcast | cut -d : -f 2 | cut -d " " -f 1` #切换到本脚本目录 cd /home/oracle/shell/ #删除之前该脚本产生的日志文件 rm -rf $ip.txt #统计硬盘空间 echo -e "您好! $ip统计信息如下:nn" >> $ip.txt echo "硬盘空间统计:" >> $ip.txt /bin/df -Th >> $ip.txt #统计表空间 echo -e "nnn表空间统计:" >> $ip.txt sqlplus -s scott/tiger << EOF >> $ip.txt set feed off set lines 400 set pages 900 col 表空间名 for a20 select x.tablespace_name 表空间名,已用,已分配,已用占已分配的比例,空闲的已分配空间,最大可用空间,已分配占最大可用比例,可自动扩展的空间 from (select TABLESPACE_NAME,round(sum(BYTES) / 1024 / 1024 / 1024, 9) 已分配, round(sum(MAXBYTES - BYTES) / 1024 / 1024 / 1024,2) 可自动扩展的空间, round(sum(MAXBYTES) / 1024 / 1024 / 1024) 最大可用空间, to_char(round(sum(BYTES) / sum(MAXBYTES) * 100, 2), '990.99') || '%' 已分配占最大可用比例 from dba_data_files group by TABLESPACE_NAME) x, (select a.tablespace_name, round(a.bytes / 1024 / 1024 / 1024, 9) 已用, round(b.bytes / 1024 / 1024 / 1024, 9) 空闲的已分配空间, to_char(round(a.bytes / (a.bytes + b.bytes) * 100, 2), '990.99') || '%' 已用占已分配的比例 from sys.sm$ts_used a, sys.sm$ts_free b where a.tablespace_name = b.tablespace_name) y where x.tablespace_name = y.tablespace_name order by 1; exit EOF #把统计结果邮件发出 mutt -s "$ip统计信息" -- zhangwz@xx.net < $ip.txt
加到操作系统的定时任务中:
每周五的15:30执行此脚本
[oracle@ ~]$ crontab -l 30 15 * * 5 /home/oracle/shell/weekcheck.sh
shell脚本实现linux系统文件完整性检测
今天发现个可以检测系统文件完整性的shell脚本,自己试了下还可以吧,介绍给大家。系统:centos5.x脚本内容:catmy_filecheck.sh#!/bin/bash##变量首先声明才能使
shell实现自动adsl拨号并检测连接状况脚本分享
今天公司同事要我整个adsl自动重拨的shell,并检测是否连上了,这样才能保证内部测试服务器不掉网,好吧,下面我把脚本发出来.系统:centos5.x脚本1:cat/root/sof
shell中嵌套执行expect命令实例
一直都想把expect的操作写到bash脚本里,这样就不用我再写两个脚本来执行了,搞了一下午终于有点小成就,给大家看看吧.系统:centos5.x1.先安装expectyum-yinstall
标签:脚本,空间,分配,已用,比例