Ritesh
February 26, 2017, 3:21pm
#1
Script required,
I have 20-30 machine RHEL/Solaris. need to write the script for df -h, if any machine df -h output above: 70 % then send the alert.
note: every server Email alert send the specific/different person.
I have the server list in 2 different files - one for rhel and another solaris.
cat $BASE/fsmonhostlinux |awk ‘{print $1}’`
provide server list.
Ritesh
February 26, 2017, 3:45pm
#2
script will run from other server , that machine have password less for all.
Hi Ritesh,
Run the below script in all server and change the email id according to yours
#!/bin/bash
df -Ph | grep -v File | while read out
do
partuse=echo $out | awk '{print $5}' | cut -d'%' -f1
partdir=echo $out | awk '{print $6}'
if [ $partuse -ge 70 ]
then
echo "Partition $partdir Usage is more $partuse%" | mail -s "Disk Usage More" test@example.com
fi
done
Ritesh
March 18, 2017, 5:29pm
#4
hi @iamarunk1898 , thanks for reply,.
i want to run the the script from other server, from that server having password less connection(Normal user)
suppose i have server list in file_name.
and script.sh will check server list in “file_name” one by one.
Maybe this can help
Code:
awk ’ BEGIN {
“hostname” | getline host
recipient = “root”
threshold = “90%”
df = “/bin/df -k”
while ( ( df |getline line ) > 0 ) {
split(line,array," “)
if (array[5] > threshold && array[5] !~ /[a-zA-Z]/) {
email=”/usr/bin/mail "recipient
print "Filesystem " array[1] " hits the threshold " threshold ".Value: " array[5] | email
close(email)
}
}
close(df)
}’
bestwritingadvisor