Sponsored Content
Top Forums Shell Programming and Scripting File system capacity meter in shell Post 302432310 by bejo4ever on Thursday 24th of June 2010 04:35:13 PM
Old 06-24-2010
im trying to merge the code with the below script

Code:
#!/usr/bin/ksh
clear
echo
echo
echo "\t\t\t\t                   **** Critical File system at : `date` **** "
echo
echo "                                            Hostname              Owner        Capacity         Free Space        Path " 
echo "                                        ----------------------------------------------------------------------------------------------------"

cat  crtl_fs |awk -F\t '{print $1}' >host_srvs1
cat  crtl_fs |awk -F\t '{print $2}' >host_srvs2
cat  crtl_fs |awk -F\t '{print $3}' >host_srvs3
cat  crtl_fs |awk -F\t '{print $4}' >host_srvs4
cat  crtl_fs |awk -F\t '{print $5}' >host_srvs5
cat  crtl_fs |awk -F\t '{print $6}' >host_srvs6

arr_set(){
file_name='host_srvs'$1''
k=0
while read file_line
do
f=$1
if [ $f -eq 1 ]
then
arry1[$k]=${file_line}
fi
if [ $f -eq 2 ]
then
arry2[$k]=${file_line}
fi
if [ $f -eq 3 ]
then
arry3[$k]=${file_line}
fi
if [ $f -eq 4 ]
then
arry4[$k]=${file_line}
fi
if [ $f -eq 5 ]
then
arry5[$k]=${file_line}
fi
if [ $f -eq 6 ]
then
arry6[$k]=${file_line}
fi
k=`expr $k + 1`
done < ${file_name}
}
arr_set 1  
arr_set 2
arr_set 3
arr_set 4
arr_set 5
arr_set 6
##########################
RED="echo \\033[0;31m\c"
NORMAL="echo  \\033[0;39m"
GREEN="echo  \\033[0;32m\c"
BLUE="echo \\033[0;35m\c" 
n=0
while [ $n -lt $k ]
do
i=${arry3[$n]}
sun=`echo "${arry1[$n]}" |awk '{print $1}'`
if [ "$sun" == "Sun" -o $sun == "TABS" ]
then 
is=`rsh ${arry2[$n]} 2>/dev/null df -k $i | awk '{print $5}' | cut -f1 -d% | grep -v capacity`
else
is=`rsh ${arry2[$n]} 2>/dev/null df -k $i | awk '{print $5}' | cut -f1 -d% | grep -v capacity`
fi
if [ "$is" -ge "${arry6[$n]}"  ]
                        then
                                $RED
echo "\t\t\t\t\t\t  ${arry2[$n]}\t\t${arry1[$n]}\t\t$is %\t\t`rsh ${arry2[$n]} 2>/dev/null df -h $i | awk '{print $4}' | cut -f1 -dG | grep -v avail` "GB"\t\t$i \c"
                                $NORMAL
fi

n=`expr $n + 1 `
done 
echo
rm  host_srvs1 host_srvs2 host_srvs3 host_srvs4 host_srvs5 host_srvs6 2>/dev/null
echo  "\n\t\t\t\t\t\t\t  ****  Press \"Enter To \"  Quit ****"
read a


KSH Version M-11/16/88i

Moderator's Comments:
Mod Comment Please use code tags, and indent your code

Last edited by Scott; 06-24-2010 at 06:12 PM.. Reason: Code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to mount a file system of a remote machine to local file system

Hi friends, In my case, there are serveral PCs running Linux in a LAN. I would like to to mount the directory /A_river of machine-A to the file system of another machine machine-B so that I can access files in that directory. I do not know how to do this. The situation is complicated by... (2 Replies)
Discussion started by: cy163
2 Replies

2. Shell Programming and Scripting

File System Check using shell script !!!

Hi Guys I m posing this new thread as I didnt get satisfactory result after running search here. My requirement is very simple (using shell script) I need to findout what all file systems are mounted -> Then I need check the health of that file system - by disk usage & by doing a simple... (8 Replies)
Discussion started by: csaha
8 Replies

3. UNIX for Dummies Questions & Answers

File Size Capacity

How to view file size limit in unix.. From my case is when the file size over 80% full is has to be an alert. Thank you (3 Replies)
Discussion started by: tanjonathan
3 Replies

4. Shell Programming and Scripting

Shell Script for monitoring File system.

Hi, need help to write one shell script to monitor UNIX file systems and if any changes happend like deletion of any file, adding new file, time stamp changed, permisson changed etc. Script need to send alert mail to defined person/mail id. I request someone to help me to create the... (1 Reply)
Discussion started by: vjauhari
1 Replies

5. Shell Programming and Scripting

Shell script to find filesystem capacity on 50 servers

Hi all, I am new to Unix and I want to write a shell script in a jumpbox for finding the filesystem capacity on 50 unix servers ( by ssh ) and then email the result in HTML format with server name and capacity % to a specific outlook distribution list. any suggestion would be of great help. (17 Replies)
Discussion started by: amitbisht9
17 Replies

6. Shell Programming and Scripting

Running remote system shell script and c binary file from windows machine using java

Hi, I have an shell script program in a remote linux machine which will do some specific monitoring functionality. Also, have some C executables in that machine. From a windows machine, I want to run the shell script program (If possible using java). I tried with SSH for this. but, in... (1 Reply)
Discussion started by: ram.sj
1 Replies

7. Shell Programming and Scripting

Help with a shell script to check /var file system

deleting (0 Replies)
Discussion started by: fretagi
0 Replies

8. Homework & Coursework Questions

Disk Capacity Shell Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! I am pretty close I think, but stuck. I don't know how to send an email to the user specified on the command line, and I receive an error stating -ge expecting a unary value(lines... (14 Replies)
Discussion started by: polyglot0727
14 Replies

9. OS X (Apple)

Text mode dual _LED_ VU meter.

Hi guys... Finally decided to release this, I have a python version too but that is unimportant to me. It is a text mode "Dual_VU.sh" meter. It actually calls dash as the interpreter but change the shebang to suit yourselves. It uses the bell character for overload per channel and... (1 Reply)
Discussion started by: wisecracker
1 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.11 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 02:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy