0 Replies Latest reply: Aug 12, 2013 7:49 AM by 745825 RSS

    How to find Open Files by a Process Solaris 10

    745825

      Hi,

       

      Hope you are doing well.

       

      I'm trying to get open files by a process in solaris 10 using "pfiles" with below command:

       

      pfiles -n `ps | grep -i "data -log"  | grep -v grep | grep -i uatrate | awk '{print $2}'` | wc –l

       

      When I put this in some shell script like below then this command is not giving any output. Your assistance is required in this. Please guide me so that I can get the Count of Open files by some process.

       

      I made some script, Its working fine but its giving the output for whole processes:

       

      #!/bin/ksh

      let "TOTAL_OPENED=0"

      for A_PID in `ps | grep -i "data -log"  | grep -v grep | grep -i uatrate | awk '{print $1}'`; do

      FILES_OPENED=`/usr/proc/bin/pfiles -n $A_PID 2>/dev/null| grep "ino:" | wc -l`

      let "TOTAL_OPENED = TOTAL_OPENED + $FILES_OPENED"

      done

      echo "Opened files = $TOTAL_OPENED"

       

      Many Thanks in advance.

       

      Imran Qasim.