Create a script sends an email message to the user specified on the command line
ID: 3849899 • Letter: C
Question
Create a script sends an email message to the user specified on the command line if any of the file systems at more than 60% of capacity. The script should not process special file systems as /proc on the ce.uml.edu. It should only process file systems which are either locally mounted or are mounted via NFS. An individual email should be sent for each filey system which is at the warning level (60%) There should be a subject on the email with a message "Warning: File system here is at % of capacity" If the files system is at greater than 90% of capacity, the "Warning" should be changed to "Critical Warning".
Explanation / Answer
1.cat /opt/scripts/fsused
#!/bin/sh
findused() {
value=`df -kP $fs|tail -1|awk {'print $5'}|sed s/%//g`
}
cat /opt/scripts/fsdata|
while read fs percent support
do
findused $fs
if [ $value -gt $percent ]
then
grep $fs /opt/scripts/fspaged > /dev/null
rcg=$?
if [ $rcg -ne 0 ]
then
/opt/scripts/pagesupp "`uname -n` $fs $value% full (threshold $percent%)" $support
echo "$fs $value `date +%y%m%d.%H%M`">> /opt/scripts/fspaged
echo "$fs $value `date +%y%m%d.%H%M`">> /opt/scripts/fspaged.history
fi
fi
done
----------------------------------------------------------------------------------------------------------------------------------------------------
2.
cat /opt/scripts/pagesupp
#!/bin/ksh
# script to page support personnel
# parm 1 is the message to send
# parm 2 is the area to page (unix, dazel, oracle)
message=$1
pagewho=mike
if [ $# -ge 2 ]
then
if [ -f /common/pager/$2 ]
then
pagewho=$2
fi
fi
number=`sed 's/-//g' < /common/pager/$pagewho`
echo $message > /tmp/pagemsg.$$
os=`uname -s`
if [ "$os" = "Linux" ]
then
server=`hostname -s`
else
server=`cat /etc/nodename`
fi
timestamp=`date +%m/%d/%y_%H:%M:%S`
echo "$server $timestamp $pagewho" > /tmp/pagehdr.$$
mailx -s . $number@myairmail.com < /tmp/pagemsg.$$
cat /tmp/pagehdr.$$ >> /common/pager/log
cat /tmp/pagemsg.$$ >> /common/pager/log
echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX >> /common/pager/log
rm /tmp/pagemsg.$$
rm /tmp/pagehdr.$$
----------------------------------------------------------------------------------------------------------------------------------------------------------------
3. cat /opt/scripts/fsdata
/ 60 unix
/ 90 unix
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.