如何导出Linux下磁盘信息
–将disk使用信息保存到数据库中
create table disk_status(snap_id date,USED_STATUS varchar2(4000));
alter table disk_status add constraint pk_ds_snapid primary key(snap_id);
[Oracle@data1 backup]$ more auto_collect_disk.sh
#!/bin/bash
rm /home/oracle/sql/backup/disk_status.lst
df>/home/oracle/sql/backup/disk_status.lst
DISK_STATUS=`cat /home/oracle/sql/backup/disk_status.lst`
echo $DISK_STATUS
sqlplus -s xxxx/yyyy<<!;
insert into disk_status values(trunc(sysdate),’$DISK_STATUS’);
commit;
exit
!
[oracle@data1 oracle]$ crontab -l
# DO NOT EDIT THIS FILE – edit the master and reinstall.
# (/tmp/crontab.21703 installed on Mon Nov 22 09:46:47 2004)
# (Cron version — $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
00 05 * * * /home/oracle/sql/backup/auto_collect_disk.sh >> /home/oracle/sql/backup/tmp.lst 2>&1
[oracle@www1 sql]$ more backup/auto_send_disk.sh
#!/bin/sh
. ~oracle/.bash_profile
/home/oracle/product/9.2.0/bin/sqlplus -s xxxx/yyyy@zzzz<<!
set timing off
spool /home/oracle/sql/backup/disk_status.lst
set linesize 81
col used_status format a69
select to_char(snap_id,’yyyy-mm-dd’) snap_id,used_status from disk_status where snap_id = trunc(sysdate);
set linesize 101
set pagesize 999
col “表空间名” format a12
col mbytes format 9999.99
col “已使用空间(M)” format 99999.99
col 使用比 format a8
col “空闲空间(M)” format 9999.99
col “最大块(M)” format 9999.99
SELECT F.TABLESPACE_NAME “表空间名”,
D.TOT_GROOTTE_MB “表空间大小(M)”,
D.TOT_GROOTTE_MB – F.TOTAL_BYTES “已使用空间(M)”,
TO_CHAR(ROUND((D.TOT_GROOTTE_MB – F.TOTAL_BYTES)/D.TOT_GROOTTE_MB*100,2),’990.99′) 使用比,
F.TOTAL_BYTES “空闲空间(M)”,F.MAX_BYTES “最大块(M)”
FROM (SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2) TOTAL_BYTES,ROUND(MAX(BYTES)/(1024*1024),2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,ROUND(SUM(DD.BYTES)/(1024 * 1024), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME ORDER BY 4 DESC;
spool off
exit
!
mail -s “磁盘信息发布” ####@###.## < /home/oracle/sql/backup/disk_status.lst
rm /home/oracle/sql/backup/disk_status.lst
[oracle@www1 sql]$crontab -l
# DO NOT EDIT THIS FILE – edit the master and reinstall.
# (/tmp/crontab.32619 installed on Mon Nov 22 09:51:02 2004)
# (Cron version — $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
30 05 * * * /home/oracle/sql/backup/auto_send_disk.sh >> /home/oracle/sql/backup/disk.lst 2>&1
如何导出Linux下磁盘信息
转载请注明出处:服务器评测 » 如何导出Linux下磁盘信息
相关推荐
- *SiliconCloud✅QualityGuardian✅LAX/TYO✅VDS⚡1C/4G🔥$24.19 /3Mo🔥
- DACENTEC >>> 专用服务器 – E5 RTO 套餐 – 24/7/365 现场支持 – 99.99% SLA
- *降价!!每月仅需 65 美元!英特尔至强 E3-1230 v6 – 欧盟和美国 – 1 Gbps
- *双 Xeon 512GB RAM | 1/2.5/10Gbps 端口,首月优惠 30% | SSD、NVME!
- MechanicWeb:美国/欧盟/英国/亚太地区 – 2024 年黑色星期五!Ryzen 9950X 托管和非托管 | 10 Gbps
- 使用 Intel Xeon、AMD Ryzen 或 AMD EPYC 可免费获得一个月。抓住您的🔥黑色星期五优惠!
- *🍂 黑色星期五前促销🔥30% 折扣!👉 即时服务器!💎 不限流量!💎 Ryzen 9 ECC
- *PLiKhost:廉价且可靠的印度尼西亚 (IIX) 专用服务器 – 雅加达