Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1175
  • Last Modified:

Need help with script to monitor AIX process?

Hello,

I am trying to monitor some processes on my AIX box (memory usage) using SVMON -P.

Currently, I first find the PID of the process I want to monitor (this process always runs OptimoQueue:SYS:production).

# ps -ef | grep "PROJOB:OptimoQueue:SYS:production"
   braro 19988834        1  17   Aug 12      - 199:16 /usr1/dlc/bin/_progres -b -pf /usr1/appsrv/config/production.pf -p /usr1/appsrv/QueueSvc.p -param PROJOB:OptimoQueue:SYS:production

Open in new window


I then use svmon -P to get memory stats in AIX:

-------------------------------------------------------------------------------
     Pid Command          Inuse      Pin     Pgsp  Virtual 64-bit Mthrd  16MB
19988834 _progres       2623079    10112        0  1055804      Y     N     N

     PageSize                Inuse        Pin       Pgsp    Virtual
     s    4 KB             2606407          0          0    1039132
     m   64 KB                1042        632          0       1042

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
  632fe3         - clnt /dev/lv_usr1_dbs:25          s 440809     0    -       -
  552fd5         - clnt /dev/lv_usr1_dbs:17          s 422254     0    -       -
  ca274a         - clnt /dev/lv_usr1_dbs:19          s 119546     0    -       -
   72f87         - clnt /dev/lv_usr1_dbs:16          s 113737     0    -       -
  9c311c         - clnt /dev/lv_usr1_bi:7            s  92704     0    -       -
  2b85a1  a0000008 work N/A                         sm  65536     0    0   65536
  485ecd  a0000001 work N/A                         sm  65536     0    0   65536
   4a28c  a000000f work N/A                         sm  65536     0    0   65536
  e43861  a0000004 work N/A                         sm  65536     0    0   65536
  4130cb  a000000e work N/A                         sm  65536     0    0   65536
  8c7b0d  a0000006 work N/A                         sm  65536     0    0   65536
  83c00a  a0000005 work N/A                         sm  65536     0    0   65536
  4fc8c7  a000000c work N/A                         sm  65536     0    0   65536
  10fd96  a0000013 work N/A                         sm  65536     0    0   65536
  b57135  a0000000 work N/A                         sm  65536     0    0   65536
  2787a2  a0000009 work N/A                         sm  65536     0    0   65536
  c68646  a000000a work N/A                         sm  64667     0    0   64667
  8dd005  a0000002 work N/A                         sm  64667     0    0   64667
  e43064         - clnt /dev/lv_usr1_dbs:41          s  57186     0    -       -
  2d8ea7  a000000d work N/A                         sm  47374     0    0   47374
  2b47a3  a0000007 work N/A                         sm  45409     0    0   45409
  feff77  a0000011 work N/A                         sm  44826     0    0   44826
  c03140         - clnt /dev/lv_usr1_dbs:50          s  43644     0    -       -
  ab272b         - clnt /dev/lv_usr1_bi:4            s  33534     0    -       -
  dd265d         - clnt /dev/lv_usr1_bi:5            s  32540     0    -       -
  7b2ffb         - clnt /dev/lv_usr1_dbs:31          s  30289     0    -       -
   82f88         - clnt /dev/lv_usr1_dbs:18          s  29815     0    -       -
  e67f6e  a0000012 work N/A                         sm  27556     0    0   27556
  6127e1         - clnt /dev/lv_usr1_dbs:20          s  26070     0    -       -
  1e2f9e         - clnt /dev/lv_usr1_dbs:24          s  23275     0    -       -
  e33063         - clnt /dev/lv_usr1_dbs:40          s  22580     0    -       -
   a2f8a         - clnt /dev/lv_usr1_dbs:29          s  19163     0    -       -
  bf8538        11 work text data BSS heap          sm  16405     0    0   16405
  ce314e         - clnt /dev/lv_usr1_dbs:55          s  12269     0    -       -
   20002         0 work kernel segment               m    688   629    0     688
  9d311d         - clnt /dev/lv_usr1_dbs:35          s   7227     0    -       -
    2f80         - clnt /dev/lv_usr1_bi:6            s   6092     0    -       -
  d23152         - clnt /dev/lv_usr1_dbs:54          s   6088     0    -       -
  432fc3         - clnt /dev/lv_usr1_dbs:30          s   6032     0    -       -
  990019  90000000 work shared library text          m    349     0    0     349
  9e311e         - clnt /dev/lv_usr1_dbs:36          s   5416     0    -       -
  2f64a5        10 clnt text data BSS heap,          s   4155     0    -       -
                        /dev/lv_usr1:805769
  ae312e         - clnt /dev/lv_usr1_bi:11           s   4016     0    -       -
  b0b937  a0000014 work N/A                         sm   2617     0    0    2617
   50005  9ffffffd work shared library              sm   2431     0    0    2431
  ab312b         - clnt /dev/lv_usr1_bi:10           s   2400     0    -       -
  f5a174  a0000010 work N/A                         sm   1567     0    0    1567
  6e2fee         - clnt /dev/lv_usr1_dbs:15          s   1057     0    -       -
  d03050         - clnt /dev/lv_usr1_bi:8            s    784     0    -       -
  502fd0         - clnt /dev/lv_usr1_ai:8            s    576     0    -       -
  9b001b  90020014 work shared library               s    491     0    0     491
  df315f         - clnt /dev/lv_usr1_ai:38           s    320     0    -       -
  e63066         - clnt /dev/lv_usr1_ai:23           s    320     0    -       -
  a73127         - clnt /dev/lv_usr1_dbs:49          s    196     0    -       -
   f2f8f         - clnt /dev/lv_usr1_dbs:23          s    144     0    -       -
  c53045         - clnt /dev/lv_usr1_dbs:39          s    122     0    -       -
  873107         - clnt /dev/lv_usr1_dbs:53          s    114     0    -       -
  214ca8  9001000a work shared library data         sm     98     0    0      98
  7183f3         - clnt /dev/lv_usr1:587524          s     92     0    -       -
  3e2fbe         - clnt /dev/lv_usr1_dbs:33          s     88     0    -       -
  302fb0         - clnt /dev/lv_usr1_dbs:27          s     88     0    -       -
  d43054         - clnt /dev/lv_usr1_dbs:43          s     87     0    -       -
  183198         - clnt /dev/lv_usr1_dbs:48          s     87     0    -       -
  1d2998 f00000002 work process private              m      5     3    0       5
  5b27db         - clnt /dev/lv_usr1_ai:4            s     64     0    -       -
  dd275d         - clnt /dev/lv_usr1_ai:17           s     64     0    -       -
  1a319a         - clnt /dev/lv_usr1_ai:26           s     64     0    -       -
  742ff4         - clnt /dev/lv_usr1_ai:12           s     64     0    -       -
  c53145         - clnt /dev/lv_usr1_ai:30           s     64     0    -       -
  1d319d         - clnt /dev/lv_usr1_ai:25           s     64     0    -       -
  182f98         - clnt /dev/lv_usr1_ai:7            s     64     0    -       -
  1b319b         - clnt /dev/lv_usr1_ai:27           s     64     0    -       -
  e03060         - clnt /dev/lv_usr1_ai:19           s     64     0    -       -
  4c2fcc         - clnt /dev/lv_usr1_ai:13           s     64     0    -       -
  362fb6         - clnt /dev/lv_usr1_ai:18           s     64     0    -       -
  cc314c         - clnt /dev/lv_usr1_ai:31           s     64     0    -       -
  1c319c         - clnt /dev/lv_usr1_ai:24           s     64     0    -       -
  d93159         - clnt /dev/lv_usr1_ai:36           s     64     0    -       -
  cf314f         - clnt /dev/lv_usr1_ai:37           s     64     0    -       -
  e63166         - clnt /dev/lv_usr1_ai:34           s     64     0    -       -
  582fd8         - clnt /dev/lv_usr1_ai:6            s     64     0    -       -
  e13061         - clnt /dev/lv_usr1_ai:20           s     64     0    -       -
  2e2fae         - clnt /dev/lv_usr1_ai:11           s     64     0    -       -
  2e31ae         - clnt /dev/lv_usr1_ai:28           s     64     0    -       -
  d43154         - clnt /dev/lv_usr1_ai:29           s     64     0    -       -
  5e2fde         - clnt /dev/lv_usr1_ai:16           s     64     0    -       -
  b42834         - clnt /dev/lv_usr1_ai:15           s     64     0    -       -
  cb314b         - clnt /dev/lv_usr1_ai:33           s     64     0    -       -
  622fe2         - clnt /dev/lv_usr1_ai:14           s     64     0    -       -
  c83148         - clnt /dev/lv_usr1_ai:32           s     64     0    -       -
  312fb1         - clnt /dev/lv_usr1_ai:5            s     64     0    -       -
  e53065         - clnt /dev/lv_usr1_ai:22           s     64     0    -       -
  7a2ffa         - clnt /dev/lv_usr1_ai:10           s     64     0    -       -
  262fa6         - clnt /dev/lv_usr1_ai:9            s     64     0    -       -
  de305e         - clnt /dev/lv_usr1_ai:21           s     64     0    -       -
  d13151         - clnt /dev/lv_usr1_ai:35           s     64     0    -       -
  852805         - clnt /dev/lv_usr1_dbs:28          s     38     0    -       -
  4707cd         - clnt /dev/lv_usr1:818573          s     34     0    -       -
  1f319f         - clnt /dev/lv_usr1_dbs:45          s     32     0    -       -
  2766ad  a0000003 work N/A                         sm     30     0    0      30
  ab7729  a000000b work N/A                         sm     28     0    0      28
  b13131         - clnt /dev/lv_usr1_dbs:52          s     26     0    -       -
  ec276c         - clnt /dev/lv_usr1_dbs:22          s     26     0    -       -
  c43144         - clnt /dev/lv_usr1_dbs:57          s     26     0    -       -
  2491ac  80020014 work USLA heap                   sm     24     0    0      24
   e000e  9ffffffe work shared library              sm     22     0    0      22
  ffc576  ffffffff work application stack           sm     19     0    0      19
  b10031  9fffffff clnt USLA text,/dev/hd2:4254      s     17     0    -       -
  896a01         - clnt /dev/lv_usr1:818525          s     16     0    -       -
   d318d         - clnt /dev/lv_usr1_dbs:44          s     14     0    -       -
  8a310a         - clnt /dev/lv_usr1_dbs:34          s     14     0    -       -
  2631a6         - clnt /dev/lv_usr1_dbs:46          s      8     0    -       -
  153195         - clnt /dev/lv_usr1_bi:9            s      8     0    -       -
  9b311b         - clnt /dev/lv_usr1_dbs:38          s      6     0    -       -
  455ac7         - clnt /dev/lv_usr1:393250          s      6     0    -       -
  272fa7         - clnt /dev/lv_usr1_dbs:14          s      6     0    -       -
  c03040         - clnt /dev/lv_usr1_dbs:37          s      5     0    -       -
  1a2f9a         - clnt /dev/lv_usr1_dbs:26          s      5     0    -       -
  893109         - clnt /dev/lv_usr1_dbs:32          s      5     0    -       -
  6530e5         - clnt /dev/lv_usr1_dbs:51          s      5     0    -       -
  ea4262  8fffffff work private load data            s      5     0    0       5
  a43124         - clnt /dev/lv_usr1_dbs:47          s      5     0    -       -
  7e2ffe         - clnt /dev/lv_usr1_dbs:21          s      5     0    -       -
   c318c         - clnt /dev/lv_usr1_dbs:42          s      4     0    -       -
  11f490         - clnt /dev/lv_usr1:882405          s      0     0    -       -
  bf7537         - clnt /dev/lv_usr1:610347          s      0     0    -       -
  d92350         - clnt /dev/lv_usr1:355793          s      0     0    -       -

Open in new window


I want to automate this process so that I can cron the script for continuous memory monitoring of that PID..

Can someone help me write this in a shell script?

I need to be able to get the PID of the process running"OptimoQueue:SYS:production" then pass it to SVMON -P and finally push the result in a CSV.

Any expert shell/ksh gurus can show me?

Thank you.
0
mirde
Asked:
mirde
  • 6
  • 3
1 Solution
 
savoneCommented:
See if this get's you what you need.

#!/bin/bash
OUTPUT="/var/tmp/out"
PID=`ps -ef | grep "PROJOB:OptimoQueue:SYS:production" | awk '{ print $2}'`
svmon -P $PID > $OUTPUT
sed 's/ /,/g' "$OUTPUT" > "file.csv"

Open in new window

0
 
mirdeAuthor Commented:
Hi Savone,

That looks like its going to work, how could I also output the date/time into the CSV so that I know the time the sample was taken into the CSV (add it as a new line to the startof the output every time the script runs?)

Thanks.
0
 
mirdeAuthor Commented:
Looking at the output some more, I think its getting two PIDs?

# ./OppyMemCheck
# cat mem.csv

-------------------------------------------------------------------------------
     Pid Command          Inuse      Pin     Pgsp  Virtual 64-bit Mthrd  16MB
 3735872            *** process does not exist ***

-------------------------------------------------------------------------------
     Pid Command          Inuse      Pin     Pgsp  Virtual 64-bit Mthrd  16MB
19988834 _progres       2845670    10112        0  1056302      Y     N     N

     PageSize                Inuse        Pin       Pgsp    Virtual
     s    4 KB             2828998          0          0    1039630
     m   64 KB                1042        632          0       1042

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
  632fe3         - clnt /dev/lv_usr1_dbs:25          s 475003     0    -       -
  552fd5         - clnt /dev/lv_usr1_dbs:17          s 445560     0    -       -
   72f87         - clnt /dev/lv_usr1_dbs:16          s 126223     0    -       -
  ca274a         - clnt /dev/lv_usr1_dbs:19          s 121100     0    -       -
  9c311c         - clnt /dev/lv_usr1_bi:7            s 105204     0    -       -
  ce314e         - clnt /dev/lv_usr1_dbs:55          s  73538     0    -       -
  2b85a1  a0000008 work N/A                         sm  65536     0    0   65536
  485ecd  a0000001 work N/A                         sm  65536     0    0   65536
  e43861  a0000004 work N/A                         sm  65536     0    0   65536
  4fc8c7  a000000c work N/A                         sm  65536     0    0   65536
  2787a2  a0000009 work N/A                         sm  65536     0    0   65536
  4130cb  a000000e work N/A                         sm  65536     0    0   65536
   4a28c  a000000f work N/A                         sm  65536     0    0   65536
  8c7b0d  a0000006 work N/A                         sm  65536     0    0   65536
  b57135  a0000000 work N/A                         sm  65536     0    0   65536
  10fd96  a0000013 work N/A                         sm  65536     0    0   65536
  83c00a  a0000005 work N/A                         sm  65536     0    0   65536
  c68646  a000000a work N/A                         sm  64667     0    0   64667
  8dd005  a0000002 work N/A                         sm  64667     0    0   64667
  e43064         - clnt /dev/lv_usr1_dbs:41          s  57296     0    -       -
  c03140         - clnt /dev/lv_usr1_dbs:50          s  54530     0    -       -
  ab272b         - clnt /dev/lv_usr1_bi:4            s  48285     0    -       -
  2d8ea7  a000000d work N/A                         sm  47374     0    0   47374
  2b47a3  a0000007 work N/A                         sm  45409     0    0   45409
  feff77  a0000011 work N/A                         sm  44826     0    0   44826
   82f88         - clnt /dev/lv_usr1_dbs:18          s  33608     0    -       -
  dd265d         - clnt /dev/lv_usr1_bi:5            s  33068     0    -       -
  7b2ffb         - clnt /dev/lv_usr1_dbs:31          s  30049     0    -       -
  e67f6e  a0000012 work N/A                         sm  27556     0    0   27556
  d23152         - clnt /dev/lv_usr1_dbs:54          s  27030     0    -       -
  6127e1         - clnt /dev/lv_usr1_dbs:20          s  26326     0    -       -
  1e2f9e         - clnt /dev/lv_usr1_dbs:24          s  25441     0    -       -
   a2f8a         - clnt /dev/lv_usr1_dbs:29          s  25221     0    -       -
  e33063         - clnt /dev/lv_usr1_dbs:40          s  23834     0    -       -
  432fc3         - clnt /dev/lv_usr1_dbs:30          s  17650     0    -       -
  bf8538        11 work text data BSS heap          sm  16903     0    0   16903
   20002         0 work kernel segment               m    688   629    0     688
  9d311d         - clnt /dev/lv_usr1_dbs:35          s   8126     0    -       -
    2f80         - clnt /dev/lv_usr1_bi:6            s   7108     0    -       -
  9e311e         - clnt /dev/lv_usr1_dbs:36          s   6084     0    -       -
  990019  90000000 work shared library text          m    349     0    0     349
  ae312e         - clnt /dev/lv_usr1_bi:11           s   4864     0    -       -
  2f64a5        10 clnt text data BSS heap,          s   4155     0    -       -
                        /dev/lv_usr1:805769
  ab312b         - clnt /dev/lv_usr1_bi:10           s   3900     0    -       -
  b0b937  a0000014 work N/A                         sm   2617     0    0    2617
   50005  9ffffffd work shared library              sm   2431     0    0    2431
  f5a174  a0000010 work N/A                         sm   1567     0    0    1567
  d03050         - clnt /dev/lv_usr1_bi:8            s   1364     0    -       -
  6e2fee         - clnt /dev/lv_usr1_dbs:15          s   1063     0    -       -
  9b001b  90020014 work shared library               s    491     0    0     491
  a73127         - clnt /dev/lv_usr1_dbs:49          s    196     0    -       -
   f2f8f         - clnt /dev/lv_usr1_dbs:23          s    146     0    -       -
  873107         - clnt /dev/lv_usr1_dbs:53          s    124     0    -       -
  c53045         - clnt /dev/lv_usr1_dbs:39          s    122     0    -       -
  7183f3         - clnt /dev/lv_usr1:587524          s    113     0    -       -
  3e2fbe         - clnt /dev/lv_usr1_dbs:33          s    107     0    -       -
  d43054         - clnt /dev/lv_usr1_dbs:43          s    106     0    -       -
  302fb0         - clnt /dev/lv_usr1_dbs:27          s    106     0    -       -
  183198         - clnt /dev/lv_usr1_dbs:48          s    106     0    -       -
  214ca8  9001000a work shared library data         sm     98     0    0      98
  1d2998 f00000002 work process private              m      5     3    0       5
  de305e         - clnt /dev/lv_usr1_ai:21           s     64     0    -       -
  262fa6         - clnt /dev/lv_usr1_ai:9            s     64     0    -       -
  1f319f         - clnt /dev/lv_usr1_dbs:45          s     64     0    -       -
  d13151         - clnt /dev/lv_usr1_ai:35           s     64     0    -       -
  5b27db         - clnt /dev/lv_usr1_ai:4            s     64     0    -       -
  1a319a         - clnt /dev/lv_usr1_ai:26           s     64     0    -       -
  df315f         - clnt /dev/lv_usr1_ai:38           s     64     0    -       -
  dd275d         - clnt /dev/lv_usr1_ai:17           s     64     0    -       -
  1d319d         - clnt /dev/lv_usr1_ai:25           s     64     0    -       -
  c53145         - clnt /dev/lv_usr1_ai:30           s     64     0    -       -
  742ff4         - clnt /dev/lv_usr1_ai:12           s     64     0    -       -
  1b319b         - clnt /dev/lv_usr1_ai:27           s     64     0    -       -
  182f98         - clnt /dev/lv_usr1_ai:7            s     64     0    -       -
  e03060         - clnt /dev/lv_usr1_ai:19           s     64     0    -       -
  cc314c         - clnt /dev/lv_usr1_ai:31           s     64     0    -       -
  502fd0         - clnt /dev/lv_usr1_ai:8            s     64     0    -       -
  d93159         - clnt /dev/lv_usr1_ai:36           s     64     0    -       -
  e63066         - clnt /dev/lv_usr1_ai:23           s     64     0    -       -
  e63166         - clnt /dev/lv_usr1_ai:34           s     64     0    -       -
  4c2fcc         - clnt /dev/lv_usr1_ai:13           s     64     0    -       -
  362fb6         - clnt /dev/lv_usr1_ai:18           s     64     0    -       -
  2e2fae         - clnt /dev/lv_usr1_ai:11           s     64     0    -       -
  2e31ae         - clnt /dev/lv_usr1_ai:28           s     64     0    -       -
  1c319c         - clnt /dev/lv_usr1_ai:24           s     64     0    -       -
  cf314f         - clnt /dev/lv_usr1_ai:37           s     64     0    -       -
  582fd8         - clnt /dev/lv_usr1_ai:6            s     64     0    -       -
  cb314b         - clnt /dev/lv_usr1_ai:33           s     64     0    -       -
  622fe2         - clnt /dev/lv_usr1_ai:14           s     64     0    -       -
  e13061         - clnt /dev/lv_usr1_ai:20           s     64     0    -       -
  d43154         - clnt /dev/lv_usr1_ai:29           s     64     0    -       -
  e53065         - clnt /dev/lv_usr1_ai:22           s     64     0    -       -
  5e2fde         - clnt /dev/lv_usr1_ai:16           s     64     0    -       -
  b42834         - clnt /dev/lv_usr1_ai:15           s     64     0    -       -
  c83148         - clnt /dev/lv_usr1_ai:32           s     64     0    -       -
  312fb1         - clnt /dev/lv_usr1_ai:5            s     64     0    -       -
  7a2ffa         - clnt /dev/lv_usr1_ai:10           s     64     0    -       -
  852805         - clnt /dev/lv_usr1_dbs:28          s     38     0    -       -
  4707cd         - clnt /dev/lv_usr1:818573          s     36     0    -       -
  c43144         - clnt /dev/lv_usr1_dbs:57          s     32     0    -       -
  ec276c         - clnt /dev/lv_usr1_dbs:22          s     32     0    -       -
  b13131         - clnt /dev/lv_usr1_dbs:52          s     32     0    -       -
  2766ad  a0000003 work N/A                         sm     30     0    0      30
  ab7729  a000000b work N/A                         sm     28     0    0      28
  2491ac  80020014 work USLA heap                   sm     24     0    0      24
   e000e  9ffffffe work shared library              sm     22     0    0      22
  ffc576  ffffffff work application stack           sm     19     0    0      19
  b10031  9fffffff clnt USLA text,/dev/hd2:4254      s     17     0    -       -
  896a01         - clnt /dev/lv_usr1:818525          s     16     0    -       -
  2631a6         - clnt /dev/lv_usr1_dbs:46          s     16     0    -       -
  8a310a         - clnt /dev/lv_usr1_dbs:34          s     14     0    -       -
   d318d         - clnt /dev/lv_usr1_dbs:44          s     14     0    -       -
  153195         - clnt /dev/lv_usr1_bi:9            s      8     0    -       -
  9b311b         - clnt /dev/lv_usr1_dbs:38          s      7     0    -       -
  272fa7         - clnt /dev/lv_usr1_dbs:14          s      6     0    -       -
  455ac7         - clnt /dev/lv_usr1:393250          s      6     0    -       -
  c03040         - clnt /dev/lv_usr1_dbs:37          s      5     0    -       -
  1a2f9a         - clnt /dev/lv_usr1_dbs:26          s      5     0    -       -
  893109         - clnt /dev/lv_usr1_dbs:32          s      5     0    -       -
  6530e5         - clnt /dev/lv_usr1_dbs:51          s      5     0    -       -
  ea4262  8fffffff work private load data            s      5     0    0       5
  a43124         - clnt /dev/lv_usr1_dbs:47          s      5     0    -       -
  7e2ffe         - clnt /dev/lv_usr1_dbs:21          s      5     0    -       -
   c318c         - clnt /dev/lv_usr1_dbs:42          s      4     0    -       -
  11f490         - clnt /dev/lv_usr1:882405          s      0     0    -       -
  bf7537         - clnt /dev/lv_usr1:610347          s      0     0    -       -
  d92350         - clnt /dev/lv_usr1:355793          s      0     0    -       -

Open in new window


 3735872            *** process does not exist ***

Could this be the PID that spawns when we run this script? Anyway we can discard this one?

When I add:

echo $PID

In the script I get two PIDs "28573940" and  "19988834".

Thanks.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
savoneCommented:
I think the other PID is the actual grep, so change the script to this:

#!/bin/bash
OUTPUT = "/var/tmp/out"
PID= `ps -ef |grep -v "grep" | grep "PROJOB:OptimoQueue:SYS:production" | awk '{ print $2}'`
svmon -P $PID > $OUTPUT
sed 's/ /,/g' "$OUTPUT" > "file.csv"

Open in new window


NOTICE: edit to line 3
0
 
mirdeAuthor Commented:
Hi Savone,

I tried your latest suggestion, no luck.. here is some more information..

$ ./OppyMemCheck
$ cat mem.csv

-------------------------------------------------------------------------------
     Pid Command          Inuse      Pin     Pgsp  Virtual 64-bit Mthrd  16MB
19988834            *** process does not exist ***
$ ps -ef | grep "PROJOB:OptimoQueue:SYS:production"
   mirde  9568346 35127512   0 10:18:19  pts/2  0:00 grep PROJOB:OptimoQueue:SYS:production
   braro 19988834        1   7   Aug 12      - 214:54 /usr1/dlc/bin/_progres -b -pf /usr1/appsrv/config/production.pf -p /usr1/appsrv/QueueSvc.p -param PROJOB:OptimoQueue:SYS:production

Open in new window


If you look above, running only the ps-ef with the grep, it shows two PIDS, I think its looking at:

 mirde  9568346 35127512   0 10:18:19  pts/2  0:00 grep PROJOB:OptimoQueue:SYS:production

instead of..

braro 19988834        1   7   Aug 12      - 214:54 /usr1/dlc/bin/_progres -b -pf /usr1/appsrv/config/production.pf -p /usr1/appsrv/QueueSvc.p -param PROJOB:OptimoQueue:SYS:production

Any idea?
0
 
mirdeAuthor Commented:
Nevermind, the issue is svmon can only run as root :)
0
 
mirdeAuthor Commented:
Works as expected, thanks :)
0
 
mirdeAuthor Commented:
It works great, now I can use it to monitor the PID in question via CRON :)

# Set log path
SVMONLOG="/home/nagios/counters/OppyMemStats.svmon"
PSLOG="/home/nagios/counters/OppyMemStats.ps"

# Get Process PID
PID=`ps -ef |grep -v "grep" | grep "PROJOB:OptimoQueue:SYS:production" | awk '{ print $2}'`

# Collect Stats and output to log path
echo "Sampled on:" `date` >> $SVMONLOG
svmon -P $PID -O unit=KB,segment=on,sortentity=virtual,sortseg=inuse,timestamp=on >> $SVMONLOG
echo "Sampled on:" `date` >> $PSLOG
ps wwv $PID >> $PSLOG

Open in new window

0
 
savoneCommented:
sure, you can run the script from cron if you like.

For example if you want to run it every 5 minutes:

*/5 * * * * /path/to/script
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now