- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need a shell script help! Tks!
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2002 01:25 AM
12-16-2002 01:25 AM
I need a shell script, I want to monitor top info , pls see attatch top.txt.
We got BAD performance in PROD server ,
because lots of FNDLIBR processes exhausted CPUs and made idle almost 0%.
If top 10 processes include any processes named "FNDLIBR" , I want to get the process id
and execute a select script to check pid status of database:
select status from fnd_concurrent_process
where system_id = PID;
(PID = unix process id)
If returned "Terminated" or "Deactivated" , shell couled exec "kill -9 PID"
The shell flow is :
1.get top info
2.if top 10 processes include any FNDLIBR processes , run a SELECT script
and check its status.
3.if returned status in "Terminated" or "Deactivated" , then kill -9 pid.
If someone knows how to do it ,
please share any tips ,
Apprreciate for any helps.
Thanks in advance!
Violin.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2002 02:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2002 02:19 AM
12-16-2002 02:19 AM
Re: Need a shell script help! Tks!
You need something within the lines of the below
#!/usr/bin/sh
# First send the top output to a file
top -f /tmp/top.out
# Next grep for your pid's and output to file
grep FNDLIBR /tmp/top.out | awk '{print $3}' > /tmp/pids.out
# Do we have a return from the grep
if [ $? != 0 ]
then
exit
else
for i in $(
export system_id=$i
# within the loop you then need to execute #your select script using system_id variable , #send the output of the select to another #variable and execute kill depending on #outcome
if [ $status = TERMINATED || DEACTIVATED ]
then
kill -9 $status
fi
fi
done
HTH
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2002 05:20 AM
12-16-2002 05:20 AM
Re: Need a shell script help! Tks!
Violin,
You aren't going to be killing terminated processes because they are already terminated.
You really should look into glance/measureware.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2002 05:00 PM
12-16-2002 05:00 PM
Re: Need a shell script help! Tks!
I'm testing your scripts now , but i got some problems,
I have to run sqlplus in oracle user and kill process in root user,
(If I run sqlplus with root , I'll get error msg like "error.txt")
please check my simon.sh , I could su oracle and run sqlplus for getting process status, but I don't know how to exit and back to root,
I need some help!
Thanks again,
and thanks for all kindly replies!
Violin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2002 12:52 AM
12-17-2002 12:52 AM
Re: Need a shell script help! Tks!
A better way to do it would be to use a < su oracle -c 'script' > which would return a PID list to kill.
Oracle script (tstpid.sh) :
for PID in $*
do
# check each status in sqlplus but run with oracle
. /u04/prodora/8.1.7/PROD.env PATH=/opt/java1.3/jre:opt/java/jre:$PATH:/usr/lib:/usr/contrib/bin; export PATH
CONNECT=apps/apps
# Get its status from Oracle and run with oracle account
sqlplus -s $CONNECT >$TMPFILE2 <
where os_process_id = $PID;
EOF
# Check whether output from Oracle says 'Terminiated' or 'Deactivated'
# The status : "K" means "Terminated" , "S" means "Deactivated"
sed 's/K/S/g' $TMPFILE2 | grep -q Terminated
# If it does, kill the beast!
if [ $? -eq 0 ]; then
echo $PID
fi
Then simon.sh could be :
TMPFILE=/tmp/top.tmp
# Get top 10 processes.
top -n 10 -f $TMPFILE
PIDLIST=`cat $TMPFILE | grep FNDLIBR | awk '{print $3}'`
KILLLIST=$(su oracle -c "your_path/tstpid.sh $PIDLIST")
[ -z "$KILLLIST" ] || kill -9 $KILLLIST
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2002 03:12 AM
12-25-2002 03:12 AM
Re: Need a shell script help! Tks!
Now the FNDLIBR processes are all cleaned.
Thanks for all replies.
VIolin.