CEK DISK USAGE and SEND with mail from shell script

Berikut ini script untuk melakukan monitoring diskspace di server yang bar os linux
 LANGSUNG COPAS aja
## scenario : soft alert akan dikirim via email jika disk usage mencapai  80% - 89%, jika mencapai 90% maka dikirim hard alert

#!/bin/bash
## Created By: yudi.ariestya@live.com
## Enjoy

CSP=$(df -lh | awk '{print $5}' |sed 's/%//g'| awk 'NR!=1 {print $1}'|awk '$0>x{x=$0};END{print x}')
CSPD=$(df -lh | grep $CSP"%")
CSPS=$(df -lh | grep $CSP"%"| awk '{print $6}')
host=$(hostname)
if [ $CSP -ge 90 ]; then
   echo -e "WARNING EMERGENCY,\n\ndisk space $host sudah mencapai $CSP% \n\nDetails : \n\n$CSPD \n\nSEGERA lakukan maintenance"| mail -s "***WARNING EMERGENCY***, Disk Space Full" it@yudikeren.com
        elif [ $CSP -ge 80 ] && [ $CSP -lt 90 ];then
             echo -e "WARNING,\n\nDisk space $host sudah mencapai $CSP% \n\nDetails \n$CSPD \n\nsegera lakukan maintenance"| mail -s "***WARNING***, Disk Space -- $CSPS" it@yudikeren.com
                else
                        exit 0
fi

Comments

Popular posts from this blog

Configure Open Smtp google with Postfix

membuat random password di linux

ISCSI