Home » Infrastructure » Unix » Unix Shell Script - No of users connected to oracle database
Unix Shell Script - No of users connected to oracle database [message #219592] Thu, 15 February 2007 01:35 Go to next message
prashanth_gs
Messages: 67
Registered: November 2005
Location: chennai
Member
Hello all,

I just want to create a script from unix to send a mail if the number of users connected to the oracle database exceeds some certain limit (for eg.100).

Can anyone please provide me the same.

DB: Oracle 10gR2
OS: Sun Solaris 5.8

Thanks and Regards,
Prashanth
Re: Unix Shell Script - No of users connected to oracle database [message #219667 is a reply to message #219592] Thu, 15 February 2007 06:44 Go to previous messageGo to next message
shahnazurs
Messages: 240
Registered: June 2005
Location: India
Senior Member
You said no. of users, not number os sessions roght?
Re: Unix Shell Script - No of users connected to oracle database [message #220542 is a reply to message #219592] Wed, 21 February 2007 03:10 Go to previous messageGo to next message
KCee
Messages: 16
Registered: October 2006
Junior Member
do a count(*) from V$SESSION;
Re: Unix Shell Script - No of users connected to oracle database [message #220609 is a reply to message #219592] Wed, 21 February 2007 06:55 Go to previous message
shahnazurs
Messages: 240
Registered: June 2005
Location: India
Senior Member
try out this

#!/bin/sh
result=`sqlplus -s xyz/xyz<<!
set heading off;
select count(*) from v$session
where type='USER';
exit;
!`
echo $result|grep "ORA-">/dev/null
if [ $? -eq 0 ];then
echo "Some orcle error"
exit 2
elsif [ $result -gt 100 ];then
cat message.txt|mailx -s "hi" abc@gmail.com
else
exit 1
fi

Thanks,
Shahnaz.
Previous Topic: using arrays
Next Topic: OS version
Goto Forum:
  


Current Time: Fri Apr 19 13:47:21 CDT 2024