<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Need a shell script help! Tks! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864868#M97008</link>
    <description>Dear All,&lt;BR /&gt;&lt;BR /&gt;I need a shell script, I want to monitor top info , pls see attatch top.txt.&lt;BR /&gt;&lt;BR /&gt;We got BAD performance in PROD server ,&lt;BR /&gt;because lots of FNDLIBR processes exhausted CPUs and made idle almost 0%.&lt;BR /&gt;&lt;BR /&gt;If top 10 processes include any processes named "FNDLIBR" , I want to get the process id &lt;BR /&gt;and execute a select script to check pid status of database:&lt;BR /&gt;&lt;BR /&gt;select status from fnd_concurrent_process&lt;BR /&gt; where system_id = PID;&lt;BR /&gt;(PID = unix process id)&lt;BR /&gt;&lt;BR /&gt;If returned "Terminated" or "Deactivated" , shell couled exec "kill -9 PID"&lt;BR /&gt;&lt;BR /&gt;The shell flow is :&lt;BR /&gt;1.get top info&lt;BR /&gt;2.if top 10 processes include any FNDLIBR processes , run a SELECT script&lt;BR /&gt;  and check its status.&lt;BR /&gt;3.if returned status in "Terminated" or "Deactivated" , then kill -9 pid.&lt;BR /&gt;&lt;BR /&gt;If someone knows how to do it ,&lt;BR /&gt;please share any tips ,&lt;BR /&gt;Apprreciate for any helps.&lt;BR /&gt;Thanks in advance!&lt;BR /&gt;&lt;BR /&gt;Violin.&lt;BR /&gt;</description>
    <pubDate>Mon, 16 Dec 2002 09:25:02 GMT</pubDate>
    <dc:creator>violin_1</dc:creator>
    <dc:date>2002-12-16T09:25:02Z</dc:date>
    <item>
      <title>Need a shell script help! Tks!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864868#M97008</link>
      <description>Dear All,&lt;BR /&gt;&lt;BR /&gt;I need a shell script, I want to monitor top info , pls see attatch top.txt.&lt;BR /&gt;&lt;BR /&gt;We got BAD performance in PROD server ,&lt;BR /&gt;because lots of FNDLIBR processes exhausted CPUs and made idle almost 0%.&lt;BR /&gt;&lt;BR /&gt;If top 10 processes include any processes named "FNDLIBR" , I want to get the process id &lt;BR /&gt;and execute a select script to check pid status of database:&lt;BR /&gt;&lt;BR /&gt;select status from fnd_concurrent_process&lt;BR /&gt; where system_id = PID;&lt;BR /&gt;(PID = unix process id)&lt;BR /&gt;&lt;BR /&gt;If returned "Terminated" or "Deactivated" , shell couled exec "kill -9 PID"&lt;BR /&gt;&lt;BR /&gt;The shell flow is :&lt;BR /&gt;1.get top info&lt;BR /&gt;2.if top 10 processes include any FNDLIBR processes , run a SELECT script&lt;BR /&gt;  and check its status.&lt;BR /&gt;3.if returned status in "Terminated" or "Deactivated" , then kill -9 pid.&lt;BR /&gt;&lt;BR /&gt;If someone knows how to do it ,&lt;BR /&gt;please share any tips ,&lt;BR /&gt;Apprreciate for any helps.&lt;BR /&gt;Thanks in advance!&lt;BR /&gt;&lt;BR /&gt;Violin.&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Dec 2002 09:25:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864868#M97008</guid>
      <dc:creator>violin_1</dc:creator>
      <dc:date>2002-12-16T09:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need a shell script help! Tks!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864869#M97009</link>
      <description>Script attached.&lt;BR /&gt;&lt;BR /&gt;Haven't tested it so may need tweaking slightly, but the core functionality is there.&lt;BR /&gt;&lt;BR /&gt;Sounds like a bad thing to do though!  Then again, it is Financials ;)</description>
      <pubDate>Mon, 16 Dec 2002 10:10:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864869#M97009</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2002-12-16T10:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need a shell script help! Tks!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864870#M97010</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;You need something within the lines of the below&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;# First send the top output to a file&lt;BR /&gt;&lt;BR /&gt;top -f /tmp/top.out&lt;BR /&gt;&lt;BR /&gt;# Next grep for your pid's and output to file&lt;BR /&gt;grep FNDLIBR /tmp/top.out | awk '{print $3}' &amp;gt; /tmp/pids.out&lt;BR /&gt;&lt;BR /&gt;# Do we have a return from the grep&lt;BR /&gt;if [ $? != 0 ]&lt;BR /&gt;then&lt;BR /&gt;exit&lt;BR /&gt;else&lt;BR /&gt;for i in $(&lt;PIDS.OUT&gt;&lt;/PIDS.OUT&gt;do&lt;BR /&gt;export system_id=$i&lt;BR /&gt;&lt;BR /&gt;# 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&lt;BR /&gt;&lt;BR /&gt;if [ $status = TERMINATED || DEACTIVATED ]&lt;BR /&gt;then&lt;BR /&gt;kill -9 $status&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Steve&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Dec 2002 10:19:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864870#M97010</guid>
      <dc:creator>steven Burgess_2</dc:creator>
      <dc:date>2002-12-16T10:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need a shell script help! Tks!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864871#M97011</link>
      <description>&lt;BR /&gt;Violin,&lt;BR /&gt;&lt;BR /&gt;You aren't going to be killing terminated processes because they are already terminated.&lt;BR /&gt;&lt;BR /&gt;You really should look into glance/measureware.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Dec 2002 13:20:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864871#M97011</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-12-16T13:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need a shell script help! Tks!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864872#M97012</link>
      <description>Hi Simon, &lt;BR /&gt;&lt;BR /&gt;I'm testing your scripts now , but i got some problems,&lt;BR /&gt;&lt;BR /&gt;I have to run sqlplus in oracle user and kill process in root user,&lt;BR /&gt;(If I run sqlplus with root , I'll get error msg like "error.txt")&lt;BR /&gt;&lt;BR /&gt;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,&lt;BR /&gt;&lt;BR /&gt;I need some help!&lt;BR /&gt;&lt;BR /&gt;Thanks again,&lt;BR /&gt;and thanks for all kindly replies!&lt;BR /&gt;&lt;BR /&gt;Violin.</description>
      <pubDate>Tue, 17 Dec 2002 01:00:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864872#M97012</guid>
      <dc:creator>violin_1</dc:creator>
      <dc:date>2002-12-17T01:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need a shell script help! Tks!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864873#M97013</link>
      <description>Violin,&lt;BR /&gt;&lt;BR /&gt;A better way to do it would be to use a &amp;lt; su oracle -c 'script' &amp;gt; which would return a PID list to kill.&lt;BR /&gt;&lt;BR /&gt;Oracle script (tstpid.sh) :&lt;BR /&gt;&lt;BR /&gt;for PID in $*&lt;BR /&gt;do&lt;BR /&gt;  # check each status in sqlplus but run with oracle&lt;BR /&gt;  . /u04/prodora/8.1.7/PROD.env  PATH=/opt/java1.3/jre:opt/java/jre:$PATH:/usr/lib:/usr/contrib/bin; export PATH&lt;BR /&gt;  CONNECT=apps/apps&lt;BR /&gt; &lt;BR /&gt;  # Get its status from Oracle and run with oracle account&lt;BR /&gt;  sqlplus -s $CONNECT &amp;gt;$TMPFILE2 &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;  select process_status_code from fnd_concurrent_processes&lt;BR /&gt;  where os_process_id = $PID;&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;  # Check whether output from Oracle says 'Terminiated' or 'Deactivated'&lt;BR /&gt;  # The status : "K" means "Terminated" , "S" means "Deactivated"&lt;BR /&gt;  sed 's/K/S/g' $TMPFILE2 | grep -q Terminated&lt;BR /&gt;&lt;BR /&gt;  # If it does, kill the beast!&lt;BR /&gt;  if [ $? -eq 0 ]; then&lt;BR /&gt;  echo $PID&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;Then simon.sh could be :&lt;BR /&gt;&lt;BR /&gt;TMPFILE=/tmp/top.tmp&lt;BR /&gt;# Get top 10 processes.&lt;BR /&gt;top -n 10 -f $TMPFILE&lt;BR /&gt;PIDLIST=`cat $TMPFILE | grep FNDLIBR | awk '{print $3}'`&lt;BR /&gt;KILLLIST=$(su oracle -c "your_path/tstpid.sh $PIDLIST")&lt;BR /&gt;[ -z "$KILLLIST" ] || kill -9 $KILLLIST&lt;BR /&gt;&lt;BR /&gt;Regards.</description>
      <pubDate>Tue, 17 Dec 2002 08:52:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864873#M97013</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2002-12-17T08:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need a shell script help! Tks!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864874#M97014</link>
      <description>I've got a solution for killing the FNDLIBR processes.&lt;BR /&gt;&lt;BR /&gt;Now the FNDLIBR processes are all cleaned.&lt;BR /&gt;&lt;BR /&gt;Thanks for all replies.&lt;BR /&gt;&lt;BR /&gt;VIolin.</description>
      <pubDate>Wed, 25 Dec 2002 11:12:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-a-shell-script-help-tks/m-p/2864874#M97014</guid>
      <dc:creator>violin_1</dc:creator>
      <dc:date>2002-12-25T11:12:00Z</dc:date>
    </item>
  </channel>
</rss>

