AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
  • 1.  how write automated script for dbx thread

    Posted Tue July 29, 2008 05:40 AM

    Originally posted by: chandru0078


    Dear Gurus

    Can anyone help me write a script for below steps? Expect the PID others are static
    statement .Do anyone know how to wite below 4 steps into script ??? PLEASE HELP.THANK YOU IN ADVANCE
    1 steps : Grep mfcs32 process and get the PID

    1. ps -ef|grep mfcs32
    root 479392 1179864 0 17:20:18 - 0:00 /opt/microfocus/cobol/bin/mfcs32
    root 1851532 552982 0 17:23:34 pts/1 0:00 grep mfcs32

    2 steps : Execute dbx -a <PID of mfcs32>

    1. dbx -a 479392
    Waiting to attach to process 479392 ...
    Successfully attached to mfcs32.
    warning: Directory containing mfcs32 could not be determined.
    Apply 'use' command to initialize source path.

    Type 'help' for help.
    reading symbolic information ...
    stopped in _p_pause at 0xd0128060 ($t2)
    0xd0128060 (_p_pause+0x80) 80410014 lwz r2,0x14(r1)

    3 Steps :dbx will requested for input and input will be "thread"
    (dbx) thread

    4 Steps : dbx will requested for input and input will be "quit"
    (dbx) quit

    chandru0078


  • 2.  Re: how write automated script for dbx thread

    Posted Tue July 29, 2008 05:59 AM

    Originally posted by: CRM


    Reading through that it looks like you are requiring program interaction - to do this it is my understanding that you will need expect installed, do you have this on the system?

    http://en.wikipedia.org/wiki/Expect

    regards

    Chris


  • 3.  Re: how write automated script for dbx thread

    Posted Tue July 29, 2008 06:13 AM

    Originally posted by: tony.evans


    dbx can run the contents of command files (dbx -c I believe), so you probably won't need an expect script.


  • 4.  Re: how write automated script for dbx thread

    Posted Tue July 29, 2008 06:23 AM

    Originally posted by: tony.evans


    ps -ef | grep mfcs32 | grep -v grep | awk '{print $2}'

    Will return the PID of the mfcs32 process. If there are more than one mfcs32 processes running then you'll get more than one line returned, so you may want to either detect for that or deal with it another way.

    Create a file with

    thread
    quit

    in it, and then use

    pid=$(ps -ef | grep mfcs32 | grep -v grep | awk '{print $2}')
    dbx -a ${pid} -c filename

    That should achieve what you want, assuming I understand the man page for dbx, I've never used the -c option.

    Writing shell scripts is programming, and I would recommend anyone who wants to write them learns how to write structured procedural programming. One you've learned the basics of programming you can choose any language to achieve your goals.


  • 5.  Re: how write automated script for dbx thread

    Posted Wed July 30, 2008 05:02 AM

    Originally posted by: chandru0078


    Dear tony.evans and CRM

    THANK YOU VERY MUCH FOR THE FEEDBACK. its works perfectly as i wanted.

    Anyway i just curious whether possible or not to grab value from the log file and
    Execute your script only if meet condition. Example

    i have log.html under /var/mfcobol/es/ELSAG/ and log.html will show current thread value .This value are variable so whenever this value reach 200 or more below script need to executed from cron.

    #!/bin/ksh

    pid=$(ps -ef | grep mfcs32 | grep -v grep | awk '{print $2}')
    dbx -a ${pid} -c thread.txt

    #
    log.html

    li>2008-07-30 14:27:51.396 [1] CAS interface: Attempting to connect to region "ELSAG "
    • 2008-07-30 14:27:51.524 [1] Startup
      ---------------------------------------------------
      Micro Focus ES Communications Process 1.6.1 starting instance 01
      ---------------------------------------------------
    • 2008-07-30 14:27:51.524 [1] MFCS running in directory /var/mfcobol/es/ELSAG, in Enterprise Server mode
    • 2008-07-30 14:27:51.524 [1] MFCS server "ELSAG" running as process 1720366
    • 2008-07-30 14:27:51.662 [1] Warning: This server (named ELSAG) is listed as "Started" in DS.
      It should be listed as "stopped". Proceeding anyway.
    • 2008-07-30 14:27:51.977 [1] MFDS control channel open at tcp:10.200.208.17:*
    • 2008-07-30 14:27:52.262 [1] ExtractRegisteredListeners: got listener #1: Web Services->soap (tcp:10.200.208.17:9003)
    • 2008-07-30 14:27:52.262 [1] ExtractRegisteredListeners: got listener #2: Web->http-switch (tcp:10.200.208.17:9005)
    • 2008-07-30 14:27:53.127 [1] 2 application listeners started
    • 2008-07-30 14:28:00.186 [1] SOAP Cas interface: Attempting to connect to region "ELSAG "
    • 2008-07-30 14:28:00.186 [1] Loaded connector "soap", version 1.1.0 (updated for MFCS 1.6)
      ConnectorMain at f19deb2c
    • 2008-07-30 14:28:52.208 [1] New thread high-water mark: 21 threads are now running
    • 2008-07-30 14:29:53.806 [1] New thread high-water mark: 22 threads are now running
    • 2008-07-30 14:31:05.841 [1] New thread high-water mark: 25 threads are now running
    • 2008-07-30 14:33:01.881 [1] New thread high-water mark: 29 threads are now running
    • 2008-07-30 14:34:05.846 [1] New thread high-water mark: 33 threads are now running
    • 2008-07-30 14:35:36.009 [1] New thread high-water mark: 38 threads are now running
    • 2008-07-30 14:36:49.363 [1] New thread high-water mark: 41 threads are now running
    • 2008-07-30 14:38:05.854 [1] New thread high-water mark: 43 threads are now running
    • 2008-07-30 15:21:05.924 [1] New thread high-water mark: 44 threads are now running