OS 查询pid 对应的进程是什么进程

查看: 1873|回复: 8
OS PID 对应的是什么进程
论坛徽章:0
& &我在LIUNX下用TOP命令查看进程发现有许多ORACLE进关的进程
问题来了,我现在需要知道这些与PID所对应的ORACLE进程在做什么?
[root@xxx]# top
top - 12:54:46 up 3 days,&&3:08,&&6 users,&&load average: 4.72, 4.87, 4.62
Tasks: 754 total,& &2 running, 752 sleeping,& &0 stopped,& &0 zombie
Cpu(s):&&3.5%us,&&1.9%sy,&&0.0%ni, 90.3%id,&&4.1%wa,&&0.0%hi,&&0.1%si,&&0.0%st
Mem:&&k total, k used,& &108136k free,& & 80428k buffers
Swap: k total,&&6754760k used, k free, k cached
&&PID USER& && &PR&&NI&&VIRT&&RES&&SHR S %CPU %MEM& & TIME+&&COMMAND& && && && && && && && && && && && && && && && && && && &
8260 oracle& & 16& &0 19.1g 9.5g 9.4g S&&0.0 15.0& &2:36.50 oracle& && && && && && && && && && && && && && && && && && && &&&
8273 oracle& & 16& &0 19.1g 9.4g 9.4g S&&0.0 14.9& &2:33.33 oracle
我也在网上找了,但是没找到我想要的
SQL& select ses.sid from v$session ses,v$process pro where pro.spid=11156 and ses.paddr=pro.
& && & SID
----------
& && & 386
SQL& select sql_text from v$sqltext_with_newlines where (hash_value,address)
&&2&&in (select sql_hash_value,sql_address from v$session where sid=386) order by address,
no rows selected
我以为是执行完了,再回来用TOP命令发现PID 11156还在
求职 : 认证徽章论坛徽章:21
sid&&pid&&spid
(74.85 KB, 下载次数: 20)
16:42 上传
论坛徽章:1
这图不错,很直观。
认证徽章论坛徽章:3
select s.sid,s.username,s.event,s.wait_time,s.state,s.seconds_in_wait,p.PROGRAM,s.MACHINE,
(select&&c.SQL_FULLTEXT from v$sqlarea c where c.SQL_ID=s.SQL_ID) sql_fulltext,
(select&&c.BIND_DATA from v$sqlarea c where c.SQL_ID=s.SQL_ID) BIND_DATA,s.SQL_ID
from v$session s,v$process p
where s.PADDR=p.ADDR
and&&p.spid=&pid
再说也不是所有的oracle进程都在执行sql语句啊
论坛徽章:0
确实,所以我想知道的是,不包括正在执行的SQL。还包括比如说是在用RMAN备份之类的。
认证徽章论坛徽章:490
ses19828 发表于
sid&&pid&&spid
可以分享一下这个图不。
论坛徽章:1
这么好的图 顶起
求职 : 认证徽章论坛徽章:21
guoyJoe 发表于
可以分享一下这个图不。
保存下来就可以了&&
论坛徽章:2
itpub.net All Right Reserved. 北京皓辰网域网络信息技术有限公司版权所有    
 北京市公安局海淀分局网监中心备案编号: 广播电视节目制作经营许可证:编号(京)字第1149号用语言实现根据pid杀死相应进程,kill_process.py代码如下#! /usr/bin/python# -*- coding: utf-8 -*-import osimport sysimport signaldef kill(pid):& & try:& & & & a = os.kill(pid, signal.SIGKILL)& & & & # a = os.kill(pid, signal.9) # 与上等效& & & & print '已杀死pid为%s的进程, 返回值是:%s' % (pid, a)& & except OSError, e:& & & & print '没有如此进程!!!'if __name__ == '__main__':& & kill(8132)ok, Enjoy it !!!下面关于Python的您也可能喜欢,不妨看看:Python:在指定目录下查找满足条件的文件& Python2.7.7源码分析& 无需直接运行 Python 代码& CentOS上源码安装Python3.4& 《Python核心 第二版》.(Wesley J. Chun ).[高清PDF中文版] 《Python开发详解》.( 周伟,宗杰).[高清PDF扫描版+随书视频+代码] Python脚本获取系统信息 在下用Python搭建桌面算法交易研究环境 Python 语言的发展简史 本文永久更新链接地址:linux中通过进程PID,获取进程信息
[oracle@redhat ~]$ vi
base/diag/rdbms/jiagulun/jiagulun/trace/alert_jiagulun.log
Thu Jun 20 21:09:15
2013&&&&&&&&&&
//这些是startup nomount时,数据库在后台启动的进程ID信息
PMON started with pid=2, OS id=6014
Thu Jun 20 21:09:16 2013
VKTM started with pid=3, OS id=6016 at elevated priority
VKTM running at (10)millisec precision with DBRM quantum
Thu Jun 20 21:09:16 2013
GEN0 started with pid=4, OS id=6020
Thu Jun 20 21:09:16 2013
DIAG started with pid=5, OS id=6022
Thu Jun 20 21:09:16 2013
DBRM started with pid=6, OS id=6024
Thu Jun 20 21:09:16 2013
PSP0 started with pid=7, OS id=6026
Thu Jun 20 21:09:16 2013
DIA0 started with pid=8, OS id=6028
Thu Jun 20 21:09:16 2013
MMAN started with pid=9, OS id=6030
Thu Jun 20 21:09:16 2013
DBW0 started with pid=10, OS id=6032
Thu Jun 20 21:09:16 2013
LGWR started with pid=11, OS id=6034
Thu Jun 20 21:09:16 2013
CKPT started with pid=12, OS id=6036
Thu Jun 20 21:09:17 2013
SMON started with pid=13, OS id=6038
Thu Jun 20 21:09:17 2013
RECO started with pid=14, OS id=6040
Thu Jun 20 21:09:17 2013
MMON started with pid=15, OS id=6042
starting up 1 dispatcher(s) for network address
'(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
Thu Jun 20 21:09:17 2013
MMNL started with pid=16, OS id=6044
starting up 1 shared server(s) ...
ORACLE_BASE from environment = /u01/app/oracle
查看/proc目录下内容
[oracle@redhat ~]$ ls
/proc&&&&&&&&&&&&&&
//从这可以看出,对应oracle启动的每一个后台进程,这里都有
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//一个对应的目录存在,目录名就是进程ID
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//目录结构是:
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//cwd:运行路径
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//exe:程序名
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//fd:目录,里面是进程所打开的文件描述符
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//stat/status:各种信息
254&& 3087&
3377& 3620&
3718& 3859&
6040&&&&&&
driver&&&&&&
loadavg&&&&
2657& 3096&
3438& 3641&
3746& 3862&
6042&&&&&&
execdomains&
locks&&&&&&
2765& 3097&
3443& 3642&
3747& 3863&
6044&&&&&&
fb&&&&&&&&&&
mdstat&&&&&
181&& 2919&
3105& 3444&
3649& 3754&
6047&&&&&&
filesystems&
meminfo&&&&
sysrq-trigger
184&& 2921&
3111& 3445&
3652& 3757&
4519& 6016&
6049&&&&&&
fs&&&&&&&&&&
misc&&&&&&&
186&& 2938&
3119& 3449&
3654& 3781&
4522& 6020&
6164&&&&&&
ide&&&&&&&&&
modules&&&&
2947& 3151&
3450& 3674&
3783& 4555&
acpi&&&&&&
interrupts&&
mounts&&&&&
1940& 2950&
3171& 3451&
3678& 3785&
4556& 6024&
buddyinfo&
iomem&&&&&&&
mpt&&&&&&&&
1941& 2970&
3188& 3452&
3680& 3789&
459&& 6026&
bus&&&&&&&
ioports&&&&&
mtrr&&&&&&&
1967& 2996&
3202& 3540&
3684& 3791&
489&& 6028&
cmdline&&&
irq&&&&&&&&&
net&&&&&&&&
3291& 3542&
3686& 3794&
490&& 6030&
cpuinfo&&&
kallsyms&&&&
partitions& vmstat
2358& 3002&
3300& 3545&
3691& 3795&
493&& 6032&
crypto&&&&
kcore&&&&&&&
schedstat&& zoneinfo
251&& 3026&
3329& 3569&
3698& 3802&
494&& 6034&
devices&&&
keys&&&&&&&&
252&& 3041&
3346& 3571&
3699& 3804&
6036& diskstats&
key-users&&&
253&& 3077&
3376& 3582&
3715& 3850&
501&& 6038&
dma&&&&&&&
kmsg&&&&&&&&
以PMON为例,id=6014
[oracle@redhat ~]$ ls /proc/6014
coredump_filter& environ&
mountstats& oom_score&
smaps& status
cpuset&&&&&&&&&&
numa_maps&&
root&&&&&&
stat&& task
cwd&&&&&&&&&&&&&
loginuid& mounts&
oom_adj&&&&
schedstat& statm& wchan
[oracle@redhat ~]$ ll /proc/6014/
lrwxrwxrwx 1 oracle oinstall 0 Jun 20 21:26 cwd -&
/u01/app/oracle/product/11.2.0.1/db_1/dbs
lrwxrwxrwx 1 oracle oinstall 0 Jun 20 21:26 exe -&
/u01/app/oracle/product/11.2.0.1/db_1/bin/oracle
dr-x------ 2 oracle oinstall 0 Jun 20 21:09 fd
-r--r--r-- 1 oracle oinstall 0 Jun 20 21:09 stat
-r--r--r-- 1 oracle oinstall 0 Jun 20 21:26 status
[oracle@redhat ~]$ ls
/proc/6014/cwd/&&&&&&&&&
//cwd:一个指负dbs的指针
hc_DBUA0.dat& hc_jiagulun.dat&
init.ora& lkJIAGULUN&
orapwjiagulun& pfile.ora&
spfilejiagulun.ora
[oracle@redhat ~]$ ls
/u01/app/oracle/product/11.2.0.1/db_1/dbs/
hc_DBUA0.dat& hc_jiagulun.dat&
init.ora& lkJIAGULUN&
orapwjiagulun& pfile.ora&
spfilejiagulun.ora
[oracle@redhat ~]$ ll
/u01/app/oracle/product/11.2.0.1/db_1/bin/oracle&&
//exe:指向oracle应用程序
-rwsr-s--x 1 oracle oinstall
02:01 /u01/app/oracle/product/11.2.0.1/db_1/bin/oracle
[oracle@redhat ~]$ ls /proc/6014/fd
11& 12& 13&
14& 15& 16&
17& 18& 2&
6& 7& 8& 9
[oracle@redhat ~]$ ll
/proc/6014/fd/&&&&&&&&&&
//用 ll,可以看到fd目录下,全部是指针
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 0 -&
l-wx------ 1 oracle oinstall 64 Jun 20 21:27 1 -&
l-wx------ 1 oracle oinstall 64 Jun 20 21:27 10 -&
/u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_ora_5962.trc
l-wx------ 1 oracle oinstall 64 Jun 20 21:27 11 -&
/u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_ora_5962.trm
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 12 -&
/u01/app/oracle/product/11.2.0.1/db_1/rdbms/mesg/orazhs.msb
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 13 -&
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 14 -&
/proc/6014/fd
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 15 -&
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 16 -&
/u01/app/oracle/product/11.2.0.1/db_1/rdbms/mesg/oraus.msb
lrwx------ 1 oracle oinstall 64 Jun 20 21:27 17 -&
/u01/app/oracle/product/11.2.0.1/db_1/dbs/hc_jiagulun.dat
lrwx------ 1 oracle oinstall 64 Jun 20 21:27 18 -&
socket:[24022]
l-wx------ 1 oracle oinstall 64 Jun 20 21:27 2 -&
l-wx------ 1 oracle oinstall 64 Jun 20 21:27 3 -&
/u01/app/oracle/product/11.2.0.1/db_1/rdbms/log/jiagulun_ora_5962.trc
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 4 -&
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 5 -&
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 6 -&
lrwx------ 1 oracle oinstall 64 Jun 20 21:27 7 -&
/u01/app/oracle/product/11.2.0.1/db_1/dbs/hc_jiagulun.dat
lrwx------ 1 oracle oinstall 64 Jun 20 21:27 8 -&
/u01/app/oracle/product/11.2.0.1/db_1/dbs/lkinstjiagulun
lr-x------ 1 oracle oinstall 64 Jun 20 21:27 9 -&
/proc/6014/fd
[oracle@redhat ~]$
[oracle@redhat ~]$ ll /proc/6014/status
-r--r--r-- 1 oracle oinstall 0 Jun 20 21:26 /proc/6014/status
[oracle@redhat ~]$ ll /proc/6014/stat
-r--r--r-- 1 oracle oinstall 0 Jun 20 21:09 /proc/6014/stat
[oracle@redhat ~]$ cat /proc/6014/status
Name:&& oracle
State:& S (sleeping)
SleepAVG:&&&&&&
Tgid:&& 6014
TracerPid:&&&&&
FDSize: 64
Groups: 501 502
VmPeak:&& 671300 kB
VmSize:&& 671296 kB
VmLck:&&&&&&&&
VmHWM:&&&&
VmRSS:&&&&
VmData:&&&&
VmStk:&&&&&&&
VmExe:&&& 155140
VmLib:&&&&
VmPTE:&&&&&&
StaBrk: 130d7000 kB
StaStk: 7fff70654c30 kB
Threads:&&&&&&&
SigQ:&& 0/8192
SigPnd: 0000
ShdPnd: 0000
SigBlk: 0000
SigIgn: 5207
SigCgt: 2cf8
CapInh: 0000
CapPrm: 0000
CapEff: 0000
Cpus_allowed:&&
00,00,ffffffff,ffffffff
Mems_allowed:&&
[oracle@redhat ~]$ cat /proc/6014/stat
6014 (oracle) S 1
-1 7 0 0 0 12 25 0 0 18 0
0 0 0 17 0 0 0 0
初步猜测:stat 中内容,就是status中值的集合
另外后台进程分配到的PID,在每次启动oracle时都不同,但有个规律——PID相差为2,像6月21日的
Fri Jun 21 06:07:11 2013
PMON started with pid=2, OS id=4029
Fri Jun 21 06:07:11 2013
VKTM started with pid=3, OS id=4031 at elevated priority
VKTM running at (10)millisec precision with DBRM quantum
Fri Jun 21 06:07:11 2013
GEN0 started with pid=4, OS id=4035
Fri Jun 21 06:07:11 2013
DIAG started with pid=5, OS id=4037
Fri Jun 21 06:07:11 2013
DBRM started with pid=6, OS id=4039
Fri Jun 21 06:07:12 2013
PSP0 started with pid=7, OS id=4041
Fri Jun 21 06:07:12 2013
DIA0 started with pid=8, OS id=4043
Fri Jun 21 06:07:12 2013
MMAN started with pid=9, OS id=4045
Fri Jun 21 06:07:12 2013
DBW0 started with pid=10, OS id=4047
Fri Jun 21 06:07:12 2013
CKPT started with pid=12, OS id=4051
Fri Jun 21 06:07:12 2013
LGWR started with pid=11, OS id=4049
Fri Jun 21 06:07:12 2013
SMON started with pid=13, OS id=4053
Fri Jun 21 06:07:13 2013
RECO started with pid=14, OS id=4055
Fri Jun 21 06:07:13 2013
MMON started with pid=15, OS id=4057
Fri Jun 21 06:07:13 2013
starting up 1 dispatcher(s) for network address
'(ADDRESS=(PARTIAL=YES)(PROTOCOL
=TCP))'...
Fri Jun 21 06:07:13 2013
MMNL started with pid=16, OS id=4059
starting up 1 shared server(s) ...
ORACLE_BASE from environment = /u01/app/oracle
[oracle@redhat ~]$
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。david_bj 的BLOG
用户名:david_bj
文章数:78
评论数:62
访问量:117391
注册日期:
阅读量:5863
阅读量:12276
阅读量:416609
阅读量:1104053
51CTO推荐博文
&&&&&&&&有两种方式来实现并发性,一种方式是让每个“任务&或“进程”在单独的内在空间中工作,每个都有自已的工作内存区域。不过,虽然进程可在单独的内存空间中执行,但除非这些进程在单独的处理器上执行,否则,实际并不是“同时”运行的。是由操作系统把处理器的时间片分配给一个进程,用完时间片后就需退出处理器等待另一个时间片的到来。另一种方式是在在程序中指定多个“执行线程”,让它们在相同的内存空间中工作。这称为“多线程处理”。线程比进程更有效,因为操作系统不必为每个线程创建单独的内存空间。&&&&新建进程用os.fork函数。但它只在POSIX系统上可用,在windows版的python中,os模块没有定义os.fork函数。相反,windows程序员用多线程技术来完成并发任务。&&&os.fork函数创建进程的过程是这样的。程序每次执行时,操作都会创建一个新进程来运行程序指令。进程还可调用os.fork,要求操作系统新建一个进程。父进程是调用os.fork函数的进程。父进程所创建的进程叫子进程。每个进程都有一个不重复的进程ID号。或称pid,它对进程进行标识。子进程与父进程完全相同,子进程从父进程继承了多个值的拷贝,如全局变量和环境变量。两个进程的唯一区别是fork的返回值。子进程接收返回值0,而父进程接收子进程的pid作为返回值。一个现有进程可以调用fork函数创建一个新进程。由fork创建的新进程被称为子进程(child&process)。fork函数被调用一次但返回两次。两次返回的唯一区别是子进程中返回0值而父进程中返回子进程ID。&对于程序,只要判断fork的返回值,就知道自己是处于父进程还是子进程中。&&&子进程是父进程的副本,它将获得父进程数据空间、堆、栈等资源的副本。注意,子进程持有的是上述存储空间的“副本”,这意味着父子进程间不共享这些存储空间,它们之间共享的存储空间只有代码段。&&&用os.fork创建的子进程和父进程作为异步的并发进程而单独执行。异步是指它们各行其是,相互间不进行同步;并发是指它们可同时执行。所以我们无法知道子进程和父进程的相对速度。&&&&os.wait函数用于等待子进程结束(只适用于UNIX兼容系统)。该函数返回包含两个元素的元组,包括已完成的子进程号pid,以及子进程的退出状态,返回状态为0,表明子进程成功完成。返回状态为正整数表明子进程终止时出错。如没有子进程,会引发OSError错误。os.wait要求父进程等待它的任何一个子进程结束执行,然后唤醒父进程。&&&&要指示父进程等候一个指定的子进程终止,可在父进程中使用os.waitpid函数(只适用于unix兼容系统)。它可等候一个指定进程结束,然后返回一个双元素元组,其中包括子进程的pid和子进程的退出状态。函数调用将pid作为第一个参数传递,并将一个选项作为第二个选项,如果第一个参数大于&0,则waitpid会等待该pid结束,如果第一个参数是-1,则会等候所有子进程,也就和os.wait一样。&&&&用os.system&和&os.exec函数族来执行系统命令和其它程序。os.system使用shell来执行系统。
了这篇文章
类别:┆阅读(0)┆评论(0)

我要回帖

更多关于 进程的pid是什么 的文章

 

随机推荐