From 57687ca1bdf7d8c0284e8b79276865480480a5ca Mon Sep 17 00:00:00 2001 From: caylakpenguen Date: Mon, 25 May 2020 00:27:39 +0300 Subject: [PATCH] =?UTF-8?q?disk=20kontrol=C3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit disk kontrol betiği --- disk-kontrol.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 disk-kontrol.sh diff --git a/disk-kontrol.sh b/disk-kontrol.sh new file mode 100644 index 0000000..6b673d2 --- /dev/null +++ b/disk-kontrol.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# caylakpenguen +# Paz 24 May 2020 17:18:38 +03 +# Disk Doluluk Kontrolu.... +# Disk dolulugu belirli seviyeyi gectiginde +# ilgili kisiye bildirim gonderir. +#cron gorevi icin girdi. 15 dakikada bir calisir. +# */15 * * * * /opt/disk.sh + +#Tarih +TARIH=$(date '+%F-%H-%M') +## Sistem Kok Bolumu +DISKADI="/dev/sda1" + +## Kime Eposta Gonderilecek... +KIME="admin@local.lan" + +#data dosyasi... +MAILFILE="/tmp/eposta.txt" +DISKUSE="/tmp/diskdf.txt" +# % de olarak hesaplanir. +SINIR="90" + +kontrol(){ + +df -h | grep "$DISKADI" | awk '{ print $5}' > $DISKUSE + +DURUM=$(cat $DISKUSE | cut -f1 -d\%) + +if [ $DURUM -ge $SINIR ]; then + echo "UYARI! Disk Kullanimi % $SINIR" > $MAILFILE + echo "" >> $MAILFILE + + echo "Sistem Disk doluluk orani. % $DURUM " >> $MAILFILE + echo "Sistem Diskinizi kontrol ediniz." >> $MAILFILE + echo "" >> $MAILFILE + echo "iyi calismalar..." >> $MAILFILE + echo "$(hostname)" >> $MAILFILE + echo "Tarih: $TARIH ." >> $MAILFILE + mail -s "UYARI! Disk Kullanimi 90%" $KIME < $MAILFILE + rm -f $MAILFILE $DISKUSE + +fi +} + +# +kontrol