Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a script sends an email message to the user specified on the command line

ID: 3849886 • 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". You may use any scripting language including /bin/sh, ksh, bash, awk or perl. Work done in the C-Shell (csh) will not be accepted.

Explanation / Answer

The required shell script is given as follows. Hope you will like it and understand it well.

shell.csh

#!/bin/sh

df -H | grep -vE '^Filesystem | none' | awk '{ print $0 " " $4 }' | while read
do
echo $op
capacity=$(echo $op | awk '{ print $0 }' | cut -d'%' –f1)
type=$(echo $op | awk '{ print $1 }' )

if [ $capacity -ge 90 ]; then
echo "Critical Warning: Filesystem "$type" at “$perc”% of capacity |
mail -s "Critical Warning: Filesystem ”$type” at “$perc”% of capacity” "Here add the email like abc@xyz.com"

elif [ $capacity -ge 60 && $capacity -lt 90 ]; then
echo "Warning: Filesystem "$type" at “$perc”% of capacity |
mail -s "Warning: Filesystem ”$type” at “$perc”% of capacity” "Here add the email like abc@xyz.com"

fi
done

Please rate the answer if it helped....Thankyou

Hope it helped....

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote