Results 1 to 3 of 3

Thread: Process Statics from Process Name

  1. #1
    Join Date
    Dec 2013
    Posts
    1

    Default Process Statics from Process Name

    I Want to capture the current process details of JavaServer1 and JavaServer2 for 10Hr into outputlog in desire location. but every after 4 Hrs application server getting restarted as functionality.

    I am facing problem while using prstat command to get the process statics with "-p" option.

    for that I have written the small combination of command statement to get the process ID/PID through name of process as below.

    $ps |grep XYZ|grep "ZEE"| grep JavaServer1 | awk '{ print $1 }'
    #17763

    $ps |grep XYZ|grep "ZEE"| grep JavaServer1 | awk '{ print $1 }'
    #17763

    where XYZ is user Name ; ZZZ is Environment name; JavaServer1 and JavaServer2 is processNames; output values are PID of that process.

    Using PIDs for capturing process statics for both as below.
    $prstat -p 17763,17724 >> Output.log

    PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
    17763 ZYX 345M 142M sleep 59 0 0:00:29 0.0% java/1
    17724 ZYX 630M 308M sleep 59 0 0:00:11 0.0% java/1

    Above both process ids are for JavaServer1 and JavaServer2 which are getting changed after restarting the Server after 4 Hrs and output of file getting blank.

    To Serarch the PID with Process name and collect in log, for that I have written below statements.

    $prstat -p `ps |grep XYZ|grep "ZEE"|grep -v grep| grep JavaServer1 awk '{ print $1 }'`
    PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
    17763 ZYX 345M 142M sleep 59 0 0:00:29 0.0% java/1

    above statements are working for single process name.
    but while updating another process name in the same statement then getting output for last statement included instade of both PIDs.
    $prstat -p `ps |grep XYZ|grep "ZEE"|grep -v grep| grep JavaServer1 awk '{ print $1 }';ps |grep XYZ|grep "ZEE"|grep -v grep| grep JavaServer2 awk '{ print $1 }'`
    PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
    17724 ZYX 630M 308M sleep 59 0 0:00:11 0.0% java/1

    Please help to get process details of both the process names still if server got restarted.

  2. #2
    Join Date
    Jul 2008
    Location
    Greece
    Posts
    3,798

    Default

    The canonical way to do this is to write *.pid files in /run (like /run/javaserver1.pid) that contain the PID of the process. Read it from there.

  3. #3
    Join Date
    Nov 2008
    Location
    Manchester
    Posts
    103

    Default

    you might also be better off using "pgrep" instead of "ps -efZ" or suchlike:

    pgrep -u XYZ -z ZEE JavaServer1

    however writing the PID to a logfile, as RealNC suggested, or at least logging to a file and using "fuser" on the file might suit you better.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •