We need to see the existing script to help you further!!! Can you share the SQL query? What do you mean by "automate this task and pass the top processes" if the SQL script can derive the CPU eating processes using by itself as you mentioned?
Please clarify your goal, so that we can help you!!
1) Issue Top command manually
2) Pass the PID of the top consuming processes to the sql statement to get the SQL_TEXT
GOAL:
1) In a single shell script, capture all the top CPU consuming processes
2) Pass such captured all the top CPU consuming processes i.e PID to the sql statement to get the SQL_TEXT
I am including my sq statement for your Ref please.
Thanks,
---------- Post updated at 11:49 PM ---------- Previous update was at 11:46 PM ----------
Hi admin_xor,
Please find the sql statement:
cat unixpid.sql
rem -----------------------------------------------------------------------
rem Filename: unixusr.sql
rem Purpose: Lookup database details for a given Unix process id
rem Date: 06-Oct-1998
rem Author: Frank Naude, Oracle FAQ
rem -----------------------------------------------------------------------
set serveroutput on size 50000
set echo off feed off veri off
accept 1 prompt 'Enter Unix process id: '
DECLARE
v_sid number;
s sys.v_$session%ROWTYPE;
p sys.v_$process%ROWTYPE;
BEGIN
begin
select sid into v_sid
from sys.v_$process p, sys.v_$session s
where p.addr = s.paddr
and (p.spid = &&1
or s.process = '&&1');
exception
when no_data_found then
dbms_output.put_line('Unable to find process id &&1!!!');
return;
when others then
dbms_output.put_line(sqlerrm);
return;
end;
select * into s from sys.v_$session where sid = v_sid;
select * into p from sys.v_$process where addr = s.paddr;
dbms_output.put_line('Current SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.sql_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Previous SQL statement:');
for c1 in ( select * from sys.v_$sqltext
where HASH_VALUE = s.prev_hash_value order by piece) loop
dbms_output.put_line(chr(9)||c1.sql_text);
end loop;
dbms_output.put_line('Session Waits:');
for c1 in ( select * from sys.v_$session_wait where sid = s.sid) loop
dbms_output.put_line(chr(9)||c1.state||': '||c1.event);
end loop;
-- dbms_output.put_line('Connect Info:');
-- for c1 in ( select * from sys.v_$session_connect_info where sid = s.sid) loop
-- dbms_output.put_line(chr(9)||': '||c1.network_service_banner);
-- end loop;
---------- Post updated at 11:50 PM ---------- Previous update was at 11:49 PM ----------
Quote:
Originally Posted by a1_win
Hi admin_xor,
Thanks for your time and attention to the issue.
Sorry let me be more clear here please:
Presently what we are doing is:
1) Issue Top command manually
2) Pass the PID of the top consuming processes to the sql statement to get the SQL_TEXT
GOAL:
1) In a single shell script, capture all the top CPU consuming processes
2) Pass such captured all the top CPU consuming processes i.e PID to the sql statement to get the SQL_TEXT
I am including my sq statement for your Ref please.
Thanks,
---------- Post updated at 11:49 PM ---------- Previous update was at 11:46 PM ----------
hi all
sleeping processes in the following output , are they doing anything , but consuming lot of sources, should I need to kill them , how to know , , what they are doing
and the output says out of 260 processes only 9 are running , and 251 are sleeping , what does the sleeping means, can... (8 Replies)
Platform: Oracle Linux 6.4
To find the most memory consuming processes, I tried the following 2 methods
1. Method1
# ps aux | head -1 ; ps aux | sort -nk +4 | tail -7
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 95 0.0 0.0 0 0 ? ... (2 Replies)
Hi All,
I am new to Scripting , please give me guidance to write the script to see top processes on the Linux operating system.
I executed this script on my Virtual Server(Linux)
DATE=`date +%Y%m%d%H%M%S`
HOME=/home/xmp/testing/xmp_report
RADIUS_PID=`xms -xmp sh pr | grep... (2 Replies)
When I run 'top' command,I see the following
Memory: 32G real, 12G free, 96G swap free
Though it shows as 12G free,I am not able to account for processes that consume the rest 20G.
In my understanding some process should be consuming atleast 15-16 G but I am not able to find them.
Is... (1 Reply)
I m using following command to find top 10 cpu consuming processes.
However whenever i execute the command i get
following warning.
What can be done to avoid it?
# ps -auxf | sort -nr -k 3 | head -10
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root ... (6 Replies)
Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold
I use top on other... (5 Replies)
HI All,
Can anyone send me a command to find TOP 5 Memory consuming process.
It would be lelpful if I get output something like below
processname - pid - memory(in MB) - command
I tried few commands from the internet but the result only give the real memory usage or pagging, I want total... (4 Replies)
I need to write a Unix shell script which will list top 10 files in a directory tree on basis of size. i.e. first file should be the biggest in the whole directory and all its sub directories.
Please suggest any ideas (10 Replies)
Dear all
I want to execute some isql command from unix shell script. Kindly suggest me. isql command mention below.
isql -U -P
use gdb_1
go
select count (*) from table_x
go (3 Replies)