Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Help in unix script

Re: Help in unix script

From: <Brian_P_MacLean_at_eFunds.Com>
Date: Thu, 28 Mar 2002 10:23:20 -0800
Message-ID: <F001.00436061.20020328102320@fatcity.com>

Oops, forgot the mail part.

change:

     echo "Greater than ${MAX} -> ${SIZE}:${COMMAND}"

to:

     echo "Process ${COMMAND} is above the ${MAX}M max size, currently ${SIZE}" | mailx -s "bad boy" Smelly_Cat_at_nbc.com

                                                                                                                          
                    Brian P                                                                                               
                    MacLean              To:     ORACLE-L_at_fatcity.com                                                     
                                         cc:     ashoke.k.mandal_at_medtronic.com                                            
                    03/28/02 11:05       Subject:     Re: Help in unix script(Document link: Brian P MacLean)             
                    AM                                                                                                    
                                                                                                                          
                                                                                                                          



#!/bin/ksh
MAX=40
top -b -U norad | grep norad | awk '{ print $6, $11 }' | \ while read SIZE COMMAND
do
  #echo "working with ${SIZE}:${COMMAND}" #DEBUG   WORK="${SIZE#*M}"

  #echo "1->${WORK}"                                 #DEBUG
  if [[ ${#WORK} -eq 0 ]]
  then
    WORK=${SIZE%%M}
    #echo "2->${WORK}"                               #DEBUG
    if [[ ${WORK} -ge ${MAX} ]]
    then
      echo "Greater than ${MAX} -> ${SIZE}:${COMMAND}"     fi
  fi
done

Brian P. MacLean
Oracle DBA, OCP8i

                                                                                                                                  
                    "Mandal, Ashoke"                                                                                              
                    <ashoke.k.mandal_at_medt       To:     Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>               
                    ronic.com>                  cc:                                                                               
                    Sent by:                    Subject:     Help in unix script                                                  
                    root_at_fatcity.com                                                                                              
                                                                                                                                  
                                                                                                                                  
                    03/28/02 09:28 AM                                                                                             
                    Please respond to                                                                                             
                    ORACLE-L                                                                                                      
                                                                                                                                  
                                                                                                                                  




Greetings all,

I need to do the following

unix> top -b -U norad

  PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND

12733 norad      1  60    2 3936K 3392K run     0:05  7.21% dbganlz
12747 norad      4  52    2   13M   10M sleep   0:05  4.20% dbgora
12721 norad      1  53    2 3160K 2584K sleep   0:00  0.12% dbgsam
12726 norad      1  52    2 3184K 2416K sleep   0:00  0.02% dbgalert
12740 norad      1  53    2 2992K 2128K sleep   0:00  0.02% dbgrepos
12594 norad      1  59    0 3200K 2544K sleep   0:00  0.01% dbgsam
12606 norad      1  59    0 4696K 4160K sleep   0:11  0.00% dbganlz
12620 norad      4  59    0   42M   13M sleep   0:06  0.00% dbgora
12599 norad      1  58    0 3216K 2400K sleep   0:00  0.00% dbgalert
12613 norad      1  59    0 3016K 2112K sleep   0:00  0.00% dbgrepos

I have to check the last character of SIZE column. If the size is in M(megabyte) then check if the value is > 40 then send an e-mail with the COMMAND name and the size. Something like "dbgora has a size of 42M"

I was trying the following script. But I am not sure how to get the last character of SIZE column from the above output and compare with 'M' and then compare with the value.

top -b -U norad | grep norad | awk '{ print $6, $11 }' | \ while read SIZE COMMAND
do
 echo "Command : $COMMAND Size : $SIZE" done

Any suggestions will be appreciated.

Thanks,
Ashoke

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Mandal, Ashoke
  INET: ashoke.k.mandal_at_medtronic.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author:
  INET: Brian_P_MacLean_at_eFunds.Com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Mar 28 2002 - 12:23:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US