I have an weired situation here. I have written a small script to query number of sessions comming in from app servers to my database as well as to display the sar 5 5 report.
Here is my script.
connections.sql
Code:
select username, COUNT(*), status, machine
from v$session
where username is not null
and machine in ('xxxxxx','xxxxxx','xxxxxx')
and username ='xxxxxx'
GROUP BY USERNAME, status, machine
order by username asc, count(*) desc
/
spool off
!echo `sar 5 5 >> ics_connections.log`
!echo `cat ics_connections.log|mailx -s "SESSIONS and CPU" vijay.x.tummala@xxxxx.com`
exit
connections.sh
Code:
#!/usr/bin/ksh
. ~/.profile
sqlplus '/as sysdba' << EOF
@connections.sql
when i run connections.sh manually, it is executing fine and emailing me the below output.
HTML Code:
USERNAME COUNT(*) STATUS MACHINE
------------------------------ ---------- -------- -------------------------
XXXXX 1668 INACTIVE xxxxxxxx
XXXXX 1548 INACTIVE xxxxxxxx
XXXXX 1370 INACTIVE xxxxxxxx
XXXXX 14 ACTIVE xxxxxxxx
XXXXX 8 ACTIVE xxxxxxxx
XXXXX 2 ACTIVE xxxxxxxx