用于Oracle数据库巡检的示例脚本: 文章来源地址https://www.toymoban.com/news/detail-625001.html
#!/bin/bash
# 设置数据库连接信息
DB_USER="your_db_username"
DB_PASSWORD="your_db_password"
DB_HOST="your_db_host"
DB_PORT="your_db_port"
DB_SID="your_db_sid"
OUTPUT_FILE="/path/to/output.log"
# 巡检开始时间
start_time=$(date +"%Y-%m-%d %H:%M:%S")
echo "Start Time:" $start_time > $OUTPUT_FILE
echo "" >> $OUTPUT_FILE
# 检查数据库连接
echo "Database Connection:" >> $OUTPUT_FILE
sqlplus -S $DB_USER/$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_SID << EOF
SET PAGESIZE 0
SET FEEDBACK OFF
SELECT 'Connected to Oracle ' || version FROM dual;
EOF
echo "" >> $OUTPUT_FILE
# 检查数据库大小
echo "Database Size:" >> $OUTPUT_FILE
sqlplus -S $DB_USER/$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_SID << EOF
SET PAGESIZE 0
SET FEEDBACK OFF
SELECT ROUND(SUM(bytes)/1024/1024, 2) AS "Total Size(MB)" FROM dba_data_files;
文章来源:https://www.toymoban.com/news/detail-625001.html
到了这里,关于oracle数据库巡检脚本的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!