最近遇到個小需求,在內網區測試數據庫機器 129上用linux shell 腳本查詢 出正式庫 141 的數據,得到變量的值後將它輸入到文件file中,並將文件ftp 長傳到外網區的 35,這塊我不是很熟,話不多說,直接上腳本了
#!/bin/bash
#. /etc/profile
. ~/.bash_profile
set serveroutput on
set timing on
dblink="hlwsb_sjfx/hlwsb_sjfx@wssbdb_new"
weblogic_thread_count="select count(1) from hlwsb_sjfx.dzswj_monitor_weblogic_thread t where t.mon_date>sysdate - (30/1440) and t.hoggingthreadcount>30"
weblogic_thread_mx="select to_char(wmsys.wm_concat(t.serverport)) from hlwsb_sjfx.dzswj_monitor_weblogic_thread t where t.mon_date>sysdate - (30/1440) and t.hoggingthreadcount>30 group by t.serverport"
VALUE_COUNT=/orahome/app/oracle/product/11.2.0/oracle/bin/sqlplus -silent ${dblink}<<EOF<br/>set pagesize 0 feedback off verify off heading off echo off<br/>${weblogic_thread_count}<br/>/<br/>exit;<br/>EOF
VALUE_MX=/orahome/app/oracle/product/11.2.0/oracle/bin/sqlplus -silent ${dblink}<<EOF<br/>set pagesize 0 feedback off verify off heading off echo off<br/>${weblogic_thread_mx}<br/>/<br/>exit;<br/>EOF
echo "VALUE_COUNT:"$VALUE_COUNT > ./zabbix.file
echo "VALUE_MX:"$VALUE_MX >> ./zabbix.file
############################################################ FTP 上傳至 外網35 #####################################################
ctldir=/home/oracle/logstail/weblogic/ctl
USER=weblogic
#密碼
PASSWORD=Hlwsb101#%
#下載文件目錄1
SRCDIR=/home/weblogic/zabbix/zabbix_check_weblogic_thread
#FTP目錄(待下載文件目錄)
DESDIR=/home/oracle/zabbix/zabbix_check_weblogic_thread
#銀聯IP
IP=87.16.16.218
#端口
PORT=3522
lftp -u ${USER},${PASSWORD} sftp://${IP}:${PORT}<<EOF
lcd ${DESDIR}
cd ${SRCDIR}
mput *.file
by
EOF