LINUX_SRV Telegram 299
Скрипт для мониторинга дискового пространства в 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
2



tgoop.com/linux_srv/299
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/299

View MORE
Open in Telegram


Telegram News

Date: |

Your posting frequency depends on the topic of your channel. If you have a news channel, it’s OK to publish new content every day (or even every hour). For other industries, stick with 2-3 large posts a week. Telegram iOS app: In the “Chats” tab, click the new message icon in the right upper corner. Select “New Channel.” Public channels are public to the internet, regardless of whether or not they are subscribed. A public channel is displayed in search results and has a short address (link). For crypto enthusiasts, there was the “gm” app, a self-described “meme app” which only allowed users to greet each other with “gm,” or “good morning,” a common acronym thrown around on Crypto Twitter and Discord. But the gm app was shut down back in September after a hacker reportedly gained access to user data. How to Create a Private or Public Channel on Telegram?
from us


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