LINUX_SRV Telegram 328
Скрипт для мониторинга дискового пространства в Linux

Скрипт ниже предназначен для мониторинга использования дискового пространства на указанном разделе сервера. Настраиваемые параметры включают в себя максимально допустимый процент использования дискового пространства (`MAX`), адрес электронной почты для получения оповещений (`EMAIL`) и целевой раздел (`PARTITION`).

Скрипт использует команду df для сбора информации об использовании диска и отправляет предупреждения по электронной почте, если текущее использование превышает заданный порог.



#!/bin/bash

# Set the maximum allowed disk space usage percentage
MAX=90

# Set the email address to receive alerts
[email protected]

# Set the partition to monitor (change accordingly, e.g., /dev/sda1)
PARTITION=/dev/sda1

# Get the current disk usage percentage and related information
USAGE_INFO=$(df -h "$PARTITION" | awk 'NR==2 {print $5, $1, $2, $3, $4}' | tr '\n' ' ')
USAGE=$(echo "$USAGE_INFO" | awk '{print int($1)}') # Remove the percentage sign

if [ "$USAGE" -gt "$MAX" ]; then
# Send an email alert with detailed disk usage information
echo -e "Warning: Disk space usage on $PARTITION is $USAGE%.\n\nDisk Usage Information:\n$USAGE_INFO" | \
mail -s "Disk Space Alert on $HOSTNAME" "$EMAIL"
fi
👍32



tgoop.com/linux_srv/328
Create:
Last Update:

Скрипт для мониторинга дискового пространства в Linux

Скрипт ниже предназначен для мониторинга использования дискового пространства на указанном разделе сервера. Настраиваемые параметры включают в себя максимально допустимый процент использования дискового пространства (`MAX`), адрес электронной почты для получения оповещений (`EMAIL`) и целевой раздел (`PARTITION`).

Скрипт использует команду df для сбора информации об использовании диска и отправляет предупреждения по электронной почте, если текущее использование превышает заданный порог.



#!/bin/bash

# Set the maximum allowed disk space usage percentage
MAX=90

# Set the email address to receive alerts
[email protected]

# Set the partition to monitor (change accordingly, e.g., /dev/sda1)
PARTITION=/dev/sda1

# Get the current disk usage percentage and related information
USAGE_INFO=$(df -h "$PARTITION" | awk 'NR==2 {print $5, $1, $2, $3, $4}' | tr '\n' ' ')
USAGE=$(echo "$USAGE_INFO" | awk '{print int($1)}') # Remove the percentage sign

if [ "$USAGE" -gt "$MAX" ]; then
# Send an email alert with detailed disk usage information
echo -e "Warning: Disk space usage on $PARTITION is $USAGE%.\n\nDisk Usage Information:\n$USAGE_INFO" | \
mail -s "Disk Space Alert on $HOSTNAME" "$EMAIL"
fi

BY Типичный Сисадмин


Share with your friend now:
tgoop.com/linux_srv/328

View MORE
Open in Telegram


Telegram News

Date: |

A Telegram channel is used for various purposes, from sharing helpful content to implementing a business strategy. In addition, you can use your channel to build and improve your company image, boost your sales, make profits, enhance customer loyalty, and more. On June 7, Perekopsky met with Brazilian President Jair Bolsonaro, an avid user of the platform. According to the firm's VP, the main subject of the meeting was "freedom of expression." Earlier, crypto enthusiasts had created a self-described “meme app” dubbed “gm” app wherein users would greet each other with “gm” or “good morning” messages. However, in September 2021, the gm app was down after a hacker reportedly gained access to the user data. In 2018, Telegram’s audience reached 200 million people, with 500,000 new users joining the messenger every day. It was launched for iOS on 14 August 2013 and Android on 20 October 2013. Unlimited number of subscribers per channel
from us


Telegram Типичный Сисадмин
FROM American