贴一个干活用的Shell(关于oracle的,分享)

#!/bin/bash    
#tnslsnr   
SERVERNAME=$(uname -a | awk '{ print $2}')
filename=$SERVERNAME"_PROCESSMONITOR.sql"
echo "connect pmsadmin/pmsadmin" >>${filename}
while read line
do      
   PROCESS_PATH=$(echo ${line}|awk '{print $2}')
   PID=$(ps -ef | grep $PROCESS_PATH |grep -v grep| awk '{print $2}' | head -1)
   Pcpu=$(ps -p $PID -o pcpu| tail -1)
   Pmem=$(ps -p $PID -o pmem| tail -1)
   Pmemused=$(echo $Pmem  /*  8388608 | bc)
   SERVERNAME=$(uname -a | awk '{ print $2}')
   if [ -z $PID ]
   then
     echo $PROCESS_PATH"DOWN" >./PROCESS.LOG
     echo "insert into tab_processmonitor values (0,'"$PROCESS_PATH"','"$Pcpu"','"$Pmem"','"$Pmemused"','"$SERVERNAME"');">>${filename}
     echo "commit;">>${filename}
   else
     echo "insert into tab_processmonitor values ("$PID",'"$PROCESS_PATH"','"$Pcpu"','"$Pmem"','"$Pmemused"','"$SERVERNAME"');">>${filename}
     echo "commit;">>${filename}
   fi
done < processmonitor.conf
echo "exit">>${filename}  
ftp -i -n 10.43.94.15 <<! user root root cd /export/home/monitorsh/sql lcd /export/home/monitorsh binary prompt put ${filename} bye !
rm ${filename}

你可能感兴趣的:(oracle,shell,user,insert,Path)