Sponsored Content
Top Forums Shell Programming and Scripting like to share this beautiful shell script Post 302171653 by girish.batra on Friday 29th of February 2008 06:22:39 AM
Old 02-29-2008
like to share this beautiful shell script

Hello Everybody

I recently got this beautiful shell script from my friend. I like to share it with every body as I am bit new to shell scripting enviorment. I hope people in this site will like it. It is related to checking the filesystem threshold limit. After getting threshold limit of particular server filesystems . This script will show amount of filesystem full on the servers listed in a file called Delhosts. This script must be running continously 24*7

Any modification in this shell script is always welcome, to impove it


kind regards to all



/export/home/scripts->cat fsmonitor
#!/bin/sh
#Script to check the Delhi (IDC) Server status
/usr/bin/clear
while :
do
BASE=/export/home/scripts
LOG=/export/home/scripts/log;export LOG
PERC="%";export PERC
SZ=94;export SZ
echo "|---------------------------------------------------------------------------------------------|"
echo "Time: `date +%H:%M:%S` \t\t\t Date: `date +%d/%m/%y`"
#echo " \t \033[7m \033[5m FileSystem CHK of IDC Servers Greater Than $SZ% \033[0m \t "
echo " \t FileSystem CHK of IDC Servers Greater Than \033[7m \033[5m $SZ% \033[0m \t "
echo "|---------------------------------------------------------------------------------------------|"
echo "Ip-Addr\t\t MountPoints > Threshold Limit\t\t %SIZE "
echo "|---------------------------------------------------------------------------------------------|"
#echo "|---------------------------------------------------------------------------------------------|"
#echo "Ip-Addr\t\t MountPoints Greater than Threshold Limit\t\t %SIZE CronDaemon"
#echo "|---------------------------------------------------------------------------------------------|"

for i in `cat $BASE/Delhosts |awk '{print $1}'`
do
/usr/bin/rsh $i /usr/bin/df -k |egrep -v 'proc|fd|mntt|File|mir|ori'|awk '{print $5 $6}'|awk -F"%" '{print $1"#"$2}' >$LOG/size.out
for j in `cat $LOG/size.out`
do
Z=`/usr/bin/rsh $i /usr/sbin/ifconfig -a|grep net|grep 10 |head -1 |awk '{print $2}'`
#C=`/usr/bin/ps -ef|grep cron|grep -v grep |wc -l'`
SZ=`echo $j |awk -F"#" '{print $1}'`
MNT=`echo $j |awk -F"#" '{print $2}'`
if [ $SZ -ge 94 ]
then
echo "$Z\t$MNT\t\t\t $SZ$PERC"
#echo "$Z\t$MNT\t\t\t\t\t\t $SZ\t$C"
# else
# echo " "
fi
done

done
echo "\t\t\t\t\t\t\t Maintained by super user\n"
sleep 5
clear
done


/export/home/scripts->cat Delhosts
10.1.0.84 cm01
10.1.0.85 cm02
10.1.0.87 htappcm03
10.1.0.88 htappcm04
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Watch for File on Windows share using Shell Script

Watch for File on Windows share using Shell Script I want to poll a particular file on a Windows shared drive using shell script and copy it to a Unix directory if present. Step wise execution: 1) Poll/watch for a file in the following location on Windows share:... (1 Reply)
Discussion started by: dharam_v
1 Replies

2. UNIX for Dummies Questions & Answers

Watch for File on Windows share using Shell Script

I want to poll a particular file on a Windows shared drive using shell script and copy it to a Unix directory if present. Step wise execution: 1) Poll/watch for a file in the following location on Windows share: (SRC_DIR=\\mum\dharmesh\research\ST_DXR_20080821 to DXR.xls) 2) If present,... (1 Reply)
Discussion started by: dharam_v
1 Replies

3. UNIX for Advanced & Expert Users

Share a space watcher shell program

Just try to contribute to the forum as a way of my think you to all people help me with questions that I posted. The space watcher shell allows you to define a list of file systems and percentage threshod and a list of email address that you want to send email when the threshod has been... (0 Replies)
Discussion started by: TheGunMan
0 Replies

4. Shell Programming and Scripting

Help with data reformat if share share content

Input data: read1_data1 read1_data1 read2_data1 read3_data1 read4_data1 read4_data1 read4_data1 read5_data1 . . Desired output result: read1_data1 read1_data2 read2_data1 read3_data1 read4_data1 (3 Replies)
Discussion started by: perl_beginner
3 Replies

5. Shell Programming and Scripting

share a shell script which can replace weird characters in directory or file name

I just finish the shell script . This shell can replace weird characters (such as #$%^@!'"...) in file or directory name by "_" I spent long time on replacing apostrophe in file/directory name added: 2012-03-14 the 124th line (/usr/bin/perl -i -e "s#\'#\\'#g" /tmp/rpdir_level$i.tmp) is... (5 Replies)
Discussion started by: begonia
5 Replies

6. Shell Programming and Scripting

On korn shell, how to share history between regular user and root?

I'm exploring OpenBSD and want to stick to its default shell, which is ksh. My goal is for my regular user ("bruno") and root user to have a shared history file. However, it seems that when running as root, ksh refuses to write to a HISTFILE that is owned by non-root user. This illustrates the... (3 Replies)
Discussion started by: DevuanFan
3 Replies

7. Web Development

Vue.js component: Beautiful code highlighter

Sooner than later I will render forum discussions in Vue.js to complement the standard way of showing forum threads. Today, I ran across this component, vue-code-highlight Beautiful code syntax highlighting as Vue.js component. https://www.unix.com/members/1-albums225-picture1199.jpg ... (1 Reply)
Discussion started by: Neo
1 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 03:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy