Фрілансер: e73kiel
Поділитися:
Доповісти про конкурсну роботу

Disk state alert

İt should be added to crontab in the required period and server smtp settings should be done. Checks all mountpoints in the server and sends individual mails for the mounted partitions which exceeds the %80 of its capacity.

Конкурсна заявка №1 для                                                 Bash script, full disk warning by mail

Публічна роз'яснювальна дошка

  • bodahlstrom
    Організатор конкурсу
    • 4 роки(ів) тому

    Looks nice. Can I get the script in a message so I can test it?

    • 4 роки(ів) тому
    1. e73kiel
      e73kiel
      • 4 роки(ів) тому

      #!/bin/sh
      df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 " " $6}' | while read output;
      do
      mount=$(echo $output | awk '{ print $3}' | cut -d'%' -f1 )
      usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
      partition=$(echo $output | awk '{ print $2 }' )

      if [ $usep -ge 80 ]; then

      echo "Disk almost full on $(hostname) \"$partition mounted on $mount ($usep%)\" as on $(date)"|
      mail -s "Disk almost full on $(hostname) on $mount " firatyilmazz@gmail.com
      fi
      done

      • 4 роки(ів) тому