Script in Solaris when usage in all filesystem >90% & send a mail i don't know how to send mail from script
#!/bin/bash
# Outputs alert if filesystem is above 90%
{
for fs in $(df -hk | awk '{print $6}' | sed '1 d'); do
chk=$(df -hk ${fs} | sed '1 d' | awk '{print $5}' | awk -F\% '{print $1}')
if [ ${chk} -gt ${threshold} ]; then
echo "$(hostname): Alert Fileystem ${fs} is above ${threshold}%."
fi
done
It's getting "unary operator expected".
ssmtp
. It has simple configuration. After you've properly configuredssmtp
you can parse output ofdf
withawk
and executesendmail -t
with here-doc structure as input text. Unfortunately, I've no solaris box at hand to provide a complete answer on how to installssmtp
in the first place, so that's some research you'll have to do yourself probably, or wait for someone to expand on this comment as a proper answer – Sergiy Kolodyazhnyy Feb 26 '19 at 07:53"$fs"
,"$chk"
and"$threshold"
; see ${variable_name} doesn’t mean what you think it does … – G-Man Says 'Reinstate Monica' Feb 26 '19 at 08:40