Question
Hi i got the following code #!/bin/sh # Set to email address to send to EMAILADDR=test@test.com # Set warning percentage ALERT=10 # Set critical warning
Hi i got the following code
#!/bin/sh # Set to email address to send to EMAILADDR="test@test.com"
# Set warning percentage ALERT=10
# Set critical warning percentage CRITALERT=30
# Get the listing of filesystems and put in $output df -h |egrep -v '^Filesystem|tmpfs|cdrom|proc|ufs|ext2' | awk '{ print $5 " " $6}'|sed 's/%//g' | while read output; do echo $output # Grab just the percentage usep='echo $output | awk ' printf $1 '' # Grab the partition partition='echo $output | awk ' printf $2' ' # First check for critical since it's higher value if [[ "$usep" -ge "$CRITALERT" ]]; then # echo the body to the mail program (-s is subject) and send echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" | mail -s "Critical Warning: Warning: $partition is at $usep% of capacity" $EMAILADDR # If it's not above critical, test to see if it's above alert elif [[ "$usep" -ge "$ALERT" ]]; then echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" | mail -s "Warning: $partition is at $usep% of capacity" $EMAILADDR fi done
right now is sending multiple emails instead of those that only apply the 10 and 30 citeria and the email im gettign is blank where it should put the porcentage and the partition name
i think is because is not recognizing usep variable as a integer for the comparison done in the if and else statement
could anyone assist
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started