Sponsored Content
Top Forums Shell Programming and Scripting Can I improve this script ??? Post 30399 by Cameron on Monday 21st of October 2002 06:57:31 PM
Old 10-21-2002
Hi Perderabo,

Thanks for the reply - 10 months?!? - doesn't time fly Smilie

Below is a copy of my script (sad as it is) which I should have really posted initially - it's to check the disc space on the system (intended to be checked every 5 minutes via cron). The help you gave me was invaluble, but I was using bash for that task, this system does not have bash installed (doh!).

Hope the following is of help, as I'm going around the twist trying to get this to work...
Code:
# File location/assignments.

# %Threshold required to send email.
xdfThold=95%
xtmp=/usr/local/bin/space_chk.tmp
echo $xtmp
xemail="cyoung@????.com.au"
xemailsub="WARNING: MDProd Space Shortage."

# - START-OF-SCRIPT ------------------------------------#
##

toobig=0
echo "$toobig = "$toobig
df -k | grep "/" > $xtmp
cat $xtmp

while read f1 f2 f3 f4 xspace xmounts
  do
    echo "1-"$f1 "2-"$f2 "3-"$f3 "4-"$f4 "5-"$xspace "6-"$xmounts
    echo ">"$xspace"<"

    #xspace=${xspace%%%}
    
    friend gave me this idea(below) - sadly, no success either.
    #xspace=`echo $xspace | awk -F%'{ print $1 }'`   

    echo ">"$xspace"<"
    if [ "$xspace" -ge "$xdfThold" ]
      then
        if [ "$xmounts" != "/proc" ]
          then
            echo "It's ok.."
          else
            toobig=$toobig + 1
        fi
    fi
  done < $xtmp

if [ $toobig -gt 0 ] ; then
  # Send email of mount
  mailx -s "$xemailsub" $xemail <<END
!!!! WARNING !!!! WARNING !!!! WARNING !!!! WARNING !!!! WARNING !!!!
                THERE ARE MOUNTS SHORT OF SPACE.
     System Performance will be affected if not investigated.
----------------------------------------------------------------------
date ; df -k
----------------------------------------------------------------------
.End-of-Message.
END
fi

##

And the output from the above...
Code:
# space_chk
/usr/local/bin/space_chk.tmp
0 = 0
root_domain#root        209080       92893      108224    47%    /
/proc                        0           0           0   100%    /proc
usr_domain#usr         1555360     1269513      285847    82%    /usr
data_domain#apps      30720000     6181410     3063952    67%    /u01
data_domain#app7      30720000     2706775     3063952    47%    /u07
data_domain#data02    30720000    10503493     3063952    78%    /u02
data_domain#data03    30720000     7210616     3063952    71%    /u03
data_domain#data04    30720000     1002608     3063952    25%    /u04
scratch_domain#fs0     8886760     6375532     2482408    72%    /scratch
data_domain#tmp       30720000         290     3063952     1%    /tmp
1-root_domain#root 2-209080 3-92893 4-108224 5-47% 6-/
>47%<
>47%<
/usr/local/bin/space_chk[56]: 47%: more tokens expected
1-/proc 2-0 3-0 4-0 5-100% 6-/proc
>100%<
>100%<
/usr/local/bin/space_chk[56]: 100%: more tokens expected
1-usr_domain#usr 2-1555360 3-1269513 4-285847 5-82% 6-/usr
>82%<
>82%<
/usr/local/bin/space_chk[56]: 82%: more tokens expected
1-data_domain#apps 2-30720000 3-6181410 4-3063952 5-67% 6-/u01
>67%<
>67%<
/usr/local/bin/space_chk[56]: 67%: more tokens expected
1-data_domain#app7 2-30720000 3-2706775 4-3063952 5-47% 6-/u07
>47%<
>47%<
/usr/local/bin/space_chk[56]: 47%: more tokens expected
1-data_domain#data02 2-30720000 3-10503493 4-3063952 5-78% 6-/u02
>78%<
>78%<
/usr/local/bin/space_chk[56]: 78%: more tokens expected
1-data_domain#data03 2-30720000 3-7210616 4-3063952 5-71% 6-/u03
>71%<
>71%<
/usr/local/bin/space_chk[56]: 71%: more tokens expected
1-data_domain#data04 2-30720000 3-1002608 4-3063952 5-25% 6-/u04
>25%<
>25%<
/usr/local/bin/space_chk[56]: 25%: more tokens expected
1-scratch_domain#fs0 2-8886760 3-6375532 4-2482408 5-72% 6-/scratch
>72%<
>72%<
/usr/local/bin/space_chk[56]: 72%: more tokens expected
1-data_domain#tmp 2-30720000 3-290 4-3063952 5-1% 6-/tmp
>1%<
>1%<
/usr/local/bin/space_chk[56]: 1%: more tokens expected
#

I was asked to create the script as the File System filled on mounts /u01, /u02, /u03, /u04, /u07 and /tmp (all 101%)without any notice given - to my surprise too.

Last edited by Cameron; 10-21-2002 at 09:20 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Any way to improve performance of this script

I have a data file of 2 gig I need to do all these, but its taking hours, any where i can improve performance, thanks a lot #!/usr/bin/ksh echo TIMESTAMP="$(date +'_%y-%m-%d.%H-%M-%S')" function showHelp { cat << EOF >&2 syntax extreme.sh FILENAME Specify filename to parse EOF... (3 Replies)
Discussion started by: sirababu
3 Replies

2. Shell Programming and Scripting

Improve the performance of a shell script

Hi Friends, I wrote the below shell script to generate a report on alert messages recieved on a day. But i for processing around 4500 lines (alerts) the script is taking aorund 30 minutes to process. Please help me to make it faster and improve the performace of the script. i would be very... (10 Replies)
Discussion started by: apsprabhu
10 Replies

3. Shell Programming and Scripting

Want to improve the performance of script

Hi All, I have written a script as follows which is taking lot of time in executing/searching only 3500 records taken as input from one file in log file of 12 GB Approximately. Working of script is read the csv file as an input having 2 arguments which are transaction_id,mobile_number and search... (6 Replies)
Discussion started by: poweroflinux
6 Replies

4. UNIX for Dummies Questions & Answers

[please] improve my shell/SQL*Plus script

Hi We generate with PL/SQL *.csv files, archive them and mail to the customer. Here is my script (Solaris 10, ksh): #!/bin/ksh # Unix Shell Script Structure for PL/SQL queries with SQL*Plus . ~/.profile scriptdir=/opt/ora/scripts queryname1=example... (1 Reply)
Discussion started by: slashdotweenie
1 Replies

5. Shell Programming and Scripting

Var Check Script (Help improve if possible)

I am working on a script to check the var on all of my systems. Can someone help me fix it to work better or give me suggestions. #!/bin/ksh IN=/path/to/list_of_workstations.txt while read hostnames do if ping $hostnames 1 | grep alive > /dev/null then percent=`ssh -q... (3 Replies)
Discussion started by: whotippedmycow
3 Replies

6. UNIX for Dummies Questions & Answers

How to improve the performance of this script?

Hi , i wrote a script to convert dates to the formate i want .it works fine but the conversion is tkaing lot of time . Can some one help me tweek this script #!/bin/bash file=$1 ofile=$2 cp $file $ofile mydates=$(grep -Po '+/+/+' $ofile) # gets 8/1/13 mydates=$(echo "$mydates" | sort |... (5 Replies)
Discussion started by: vikatakavi
5 Replies

7. Shell Programming and Scripting

Improve sftp script

Dear all, I have written two scripts to transfer files to another server outside the company. One is a batch script , and the other script calls the batch script, send the files and archive the file sent. The problem is, that I want to get the list of files which have been uploaded the the... (10 Replies)
Discussion started by: arrals_vl
10 Replies

8. Shell Programming and Scripting

How to improve an script?

Gents. I have 2 different scripts for the same purpose: raw2csv_1 Script raw2csv_1 finish the process in less that 1 minute raw2csv_2 Script raw2csv_2 finish the process in more that 6 minutes. Can you please check if there is any option to improve the raw2csv_2. To finish the job... (4 Replies)
Discussion started by: jiam912
4 Replies

9. Shell Programming and Scripting

Improve script and get new output file

Gents, Using the following script, I got the changes as desired in the output file called (spread_2611.x01.new). Complete file as input (spread_2611.x01). Can you please have a look to my script and improve it please. :b: Also I would like to I get a additional selecting only the records... (21 Replies)
Discussion started by: jiam912
21 Replies

10. Shell Programming and Scripting

Improve script

Gents, Is there the possibility to improve this script to be able to have same output information. I did this script, but I believe there is a very short code to get same output here my script awk -F, '{if($10>0 && $10<=15) print $6}' tmp1 | sort -k1n | awk '{a++} END { for (n in a )... (23 Replies)
Discussion started by: jiam912
23 Replies
All times are GMT -4. The time now is 09:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy