Code:
#!/bin/ksh
# AIX Version 1.0 by Stryker Cain.
# With assistance from Sujith Achutan
# Jeyagopal Dharmalingham Daniel Thornton and Jamie Banas
## Comment out the top df portion to only get a csv report emailed to you. ##
## Comment out the bottom df portion to only get a script output ##
## Leave as is to get both screen output and emailed csv report ##
## Future parameters will be to add input of email address ##
cd /tmp
HOST1=$(hostname)
df -Pg | awk 'BEGIN{
print "\t SPACE OF IMPORTANT FILE SYSTEMS on '$HOST1'\t\n----------------------------------------------------------------------\nFILE-SYSTEM\t TOTAL-SPACE\t USED-SPACE\t FREE-SPACE\t %USED\n"}
function disp(v1,v2,v3,v4,v5){
printf "%-10s\t %-10s\t %-10s\t %-10s\t %-6s \n",v1,v2,v3,v4,v5
}
NR>2&&(($3>($2*.80)&&disp($6,$2,$3,$4,$5))||($3>($2*.40)&&$3<($2*.80)&&disp($6,$2,$3,$4,$5))||($3<($2*.40)&&disp($6,$2,$3,$4,$5)))
END{print "----------------------------------------------------------------------\n "}'
df -Pg | awk 'BEGIN{
print "FILE_SYSTEM,TOTAL_GB,USED_GB,FREE_GB,PERCENT_USED"}
function disp(v1,v2,v3,v4,v5){
printf "%-1s,%-1s,%-1s,%-1s,%-1s\n",v1,v2,v3,v4,v5
}
NR>2&&(($3>($2*.80)&&disp($6,$2,$3,$4,$5))||($3>($2*.40)&&$3<($2*.80)&&disp($6,$2,$3,$4,$5))||($3<($2*.40)&&disp($6,$2,$3,$4,$5)))
END{print "'$HOST1'-\n"}' > $HOST1-df_All.csv
uuencode $HOST1-df_All.csv $HOST1-df_All.csv | /bin/mailx -s "$HOST1 diskusage script by Stryker Cain" "email address"
rm -rf $HOST1-df_All.csv
#!/bin/ksh
# Linux Version 1.0 by Stryker Cain.
# With assistance from Sujith Achutan
# Jeyagopal Dharmalingham, Daniel Thornton and Jamie Banas
## uuencode must be installed for this script (bottom half) to work. ##
## If not you have to comment out the uuencode part and change ##
## the mailx to the cat mail command ##
## Comment out the top df portion to only get a csv report emailed to you. ##
## Comment out the bottom df portion to only get a script output ##
## Leave as is to get both screen output and emailed csv report ##
## Future parameters will be to add input of email address ##
cd /tmp
HOST1=$HOSTNAME
df -Ph | awk 'BEGIN{
print "\t SPACE OF IMPORTANT FILE SYSTEMS on '$HOST1'\t\n----------------------------------------------------------------------\n FILE-SYSTEM\t TOTAL-SPACE\t USED-SPACE\t FREE-SPACE\t %USED\n"}
function disp(v1,v2,v3,v4,v5){
printf "%-10s\t %-10s\t %-10s\t %-10s\t %-6s \n",v1,v2,v3,v4,v5
}
NR>2&&(($3>($2*.80)&&disp($6,$2,$3,$4,$5))||($3>($2*.40)&&$3<($2*.80)&&disp($6,$2,$3,$4,$5))||($3<($2*.40)&&disp($6,$2,$3,$4,$5)))
END{print "----------------------------------------------------------------------\n "}'
HOST1=$HOSTNAME
df -Ph | awk 'BEGIN{
print "FILE_SYSTEM,TOTAL_GB,USED_GB,FREE_GB,PERCENT_USED"}
function disp(v1,v2,v3,v4,v5){
printf "%-1s,%-1s,%-1s,%-1s,%-1s\n",v1,v2,v3,v4,v5
}
NR>2&&(($3>($2*.80)&&disp($6,$2,$3,$4,$5))||($3>($2*.40)&&$3<($2*.80)&&disp($6,$2,$3,$4,$5))||($3<($2*.40)&&disp($6,$2,$3,$4,$5)))
END{print "'$HOST1'-\n"}' > $HOST1-df_All.csv
uuencode $HOST1-df_All.csv $HOST1-df_All.csv | /bin/mailx -s "$HOST1 UNIX diskusage script by Stryker Cain" "email address"
# cat $HOST1-df_All.csv | /bin/mail -s "$HOST1 UNIX diskusage script by Stryker Cain" "email address"
rm -rf $HOST1-df_All.csv