From Wiki-UX.info

Wiki-UX / File Systems / How to check which processes have open files
Jump to: navigation, search

How to check which processes have open files

Abstract

This article describes a Postfix Shell script that allows to determine which processes have open files in an specific file system. It uses the HP-UX Operating Environment fuser command to probe a backing storage device, like a logical volume, to collect which process are attached to those files.

for pid in `fuser </dev/<vgname>/<lvol_name>`
do
ps -fp $pid | grep -v UID
done

Example:

for pid in `fuser /dev/vg00/lvol7`
do
ps -fp $pid | grep -v UID
done
 
daemon    1166     1  0 15:34:20 ?        00:00:00 /usr/sbin/rpc.statd
root       928     1  0 15:34:04 ?        00:00:00 /usr/sbin/syslogd -D
root       947     1  0 15:34:06 ?        00:00:00 /usr/sbin/hotplugd /var/adm/hotplugd.log trunc
root      1699     1  0 15:34:45 ?        00:00:01 /usr/sbin/pwgrd
root       750   730  0 15:33:56 ?        00:00:00 /usr/sbin/evmchmgr -l /var/evm/adm/logfiles/evmchmgr.log
root       749   730  0 15:33:56 ?        00:00:00 /usr/sbin/evmlogger -o /var/run/evmlogger.info -l /var/evm/adm/logfiles/evmlogger.log
root       971     1  0 15:34:09 ?        00:00:00 /usr/lbin/ntl_reader 0 1 1 1 1000 2 /var/adm/nettl /var/adm/conslog.opts
root       730     1  0 15:33:56 ?        00:00:00 /usr/sbin/evmd
root      1172     1  0 15:34:20 ?        00:00:00 /usr/sbin/rpc.lockd
root       933     1  0 15:34:06 ?        00:00:00 /usr/sbin/ptydaemon
root      1529     1  0 15:34:25 ?        00:00:01 /usr/sbin/snmpdm
root       972   971  0 15:34:09 ?        00:00:02 /usr/sbin/netfmt -C -F -f /var/adm/nettl.LOG000 -c /var/adm/conslog.opts
root      1509     1  0 15:34:25 ?        00:00:12 sendmail: accepting connections
root      1191     1  0 15:34:20 ?        00:00:00 /usr/sbin/nfs4cbd
root      1850     1  0 15:34:49 ?        00:00:00 /usr/sbin/swagentd -r
root      1211     1  0 15:34:20 ?        00:00:06 /usr/sbin/automountd
root      1197     1  0 15:34:20 ?        00:00:00 /usr/sbin/nfsmapid
root      1125     1  0 15:34:20 ?        00:00:00 /opt/ssh/sbin/sshd
root      1617  1613  0 15:34:42 ?        00:00:01 /opt/wbem/lbin/cimprovagt 16 14 HPUXFCIndicationProviderModule
root      1616  1613  0 15:34:39 ?        00:00:13 /opt/wbem/lbin/cimprovagt 14 11 SFMProviderModule
root      1615  1613  0 15:34:38 ?        00:00:00 /opt/wbem/lbin/cimprovagt 11 10 EMSHAProviderModule
root      1614  1613  0 15:34:37 ?        00:00:00 /opt/wbem/lbin/cimservera
root      1613     1  0 15:34:36 ?        00:02:22 /opt/wbem/lbin/cimserver
sfmdb     1646  1645  0 15:34:44 ?        00:00:00 postgres: stats collector process
root      1607     1  0 15:34:31 ?        00:00:00 /opt/dce/sbin/rpcd
root      1618  1613  0 15:34:43 ?        00:00:14 /opt/wbem/lbin/cimprovagt 18 16 HPUXIOTreeIndicationProviderModule
root      1875  1851  0 15:34:50 ?        00:00:00 /opt/OV/bin/ovbbccb -nodaemon
root      1805     1  0 15:34:48 ?        00:00:22 /opt/perf/bin/scopeux
sfmdb     1642     1  0 15:34:43 ?        00:00:00 /opt/sfmdb/pgsql/bin/postmaster -i -D /var/opt/sfmdb/pgsql
root      1710     1  0 15:34:45 ?        00:00:01 /usr/sbin/cron
root      1783     1  0 15:34:45 ?        00:00:00 /opt/perf/bin/ttd
sfmdb     1645  1642  0 15:34:44 ?        00:00:00 postgres: stats buffer process
root      1730     1  0 15:34:45 ?        00:00:00 /usr/sbin/envd
root      1727     1  0 15:34:45 ?        00:00:02 /usr/sbin/stm/uut/bin/sys/diagmond
root      2042     1  0 15:34:54 ?        00:00:00 /usr/sbin/rpc.mountd
root      1898  1851  0 15:34:51 ?        00:00:03 /opt/OV/lbin/perf/coda
root      1838     1  0 15:34:49 ?        00:00:11 /opt/perf/bin/perfalarm
root      1851     1  0 15:34:50 ?        00:00:06 /opt/OV/bin/ovcd
root      2006     1  0 15:34:54 ?        00:00:04 vxsvc -r /opt/VRTSob/config/Registry -e
root      1798     1  0 15:34:46 ?        00:00:14 /opt/perf/bin/midaemon
root      2509     1  0 15:35:48 ?        00:00:25 /usr/sbin/stm/uut/bin/tools/monitor/ia64_corehw
root      2048     1  0 15:34:54 ?        00:00:00 /usr/sbin/nfsd
root      2126     1  0 15:34:56 ?        00:00:01 /usr/lbin/kcmond
root      2189  1727  0 15:35:02 ?        00:00:00 diaglogd
sfmdb    19697  1642  0 23:41:14 ?        00:00:00 postgres: sfmdb evweb [local] idle
sfmdb    19695  1642  0 23:41:14 ?        00:00:00 postgres: sfmdb evweb [local] idle
root      2314     1  0 15:35:42 ?        00:00:01 /usr/sbin/stm/uut/bin/tools/monitor/dm_core_hw
root      2234     1  0 15:35:21 ?        00:00:12 /usr/sbin/stm/uut/bin/tools/monitor/disk_em
root      2389     1  0 15:35:43 ?        00:00:01 /usr/sbin/stm/uut/bin/tools/monitor/dm_ql_adapter
root     16430  1222  0 13:13:57 pts/ta   00:00:00 telnetd
sfmdb    19696  1642  0 23:41:14 ?        00:00:00 postgres: sfmdb evweb_history [local] idle
root      2587     1  0 15:35:52 ?        00:00:00 /usr/sbin/stm/uut/bin/tools/monitor/sysstat_em
root      2542     1  0 15:35:50 ?        00:00:08 /usr/sbin/stm/uut/bin/tools/monitor/lpmc_em
sfmdb    19694  1642  0 23:41:13 ?        00:00:00 postgres: sysadmin cer [local] idle

Authors

This page was last modified on 17 July 2010, at 03:39. This page has been accessed 4,761 times.