From c891408efc2cc6d7231454da00273e538cc66e87 Mon Sep 17 00:00:00 2001 From: Y0zhyck Date: Wed, 19 Mar 2025 15:12:52 +0300 Subject: [PATCH] russ fix --- load-info-telegram.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/load-info-telegram.sh b/load-info-telegram.sh index c36015d..884e8f2 100644 --- a/load-info-telegram.sh +++ b/load-info-telegram.sh @@ -2,17 +2,17 @@ #This script monitors server load and memory usage for every 10 seconds and sends notification to telegram in case of high usage. #Include telegram chat id and bot token ID here -chat_id="" -token="" +chat_id="-4224655517" +token="6978729637:AAHTyZ6W4I7DxRVmf5K_Wc4nvIWfarZ7x_Y" host=$HOSTNAME ip=($(hostname -I)) -#Temporary files to store data +#Временные файлы для хранения данных resource_usage_info=/tmp/resource_usage_${host}.txt msg_caption=/tmp/telegram_msg_caption.txt -#Set threshold levels for memory usage and load here. If the usage exceeds these values, the notification will be sent. -mem_threshold=80 #Should be interger. This is in percentage -load_threshold=$(nproc) #Should be integer. Usually total number of cores. +#Установите пороговые значения для использования памяти и загрузки здесь. Если использование превысит эти значения, будет отправлено уведомление. +mem_threshold=80 #Должно быть целым числом. Это в процентах +load_threshold=1(nproc) #Должно быть целым числом. Обычно это общее количество ядер. #Telegram API to send notificaiton. function telegram_send @@ -26,7 +26,7 @@ do min_load=$(cat /proc/loadavg | cut -d . -f1) if [ $min_load -ge $load_threshold ] then - echo -e "⚠️High CPU usage detected⚠️\n🖥$(hostname)\n🌎$ip\n⏱$(uptime)\n#CPU" > $msg_caption + echo -e "⚠️Обнаружена высокая загрузка процессора⚠️\n🖥$(hostname)\n🌎$ip\n⏱$(uptime)\n#CPU" > $msg_caption echo -e "CPU usage report from $(hostname)\nServer Time : $(date +"%d%b%Y %T")\n\n\$uptime\n$(uptime)\n\n%CPU %MEM USER\tCMD" > $resource_usage_info ps -eo pcpu,pmem,user,cmd | sed '1d' | sort -nr >> $resource_usage_info caption=$(<$msg_caption) @@ -42,7 +42,7 @@ do mem_usage=$(echo "$mem" | awk 'NR==2{printf "%i\n", ($3*100/$2)}') if [ $mem_usage -gt $mem_threshold ] then - echo -e "⚠️High Memory usage detected⚠️\n🖥$(hostname)\n🌎$ip\n🔸$(echo $mem_usage% memory usage)\n#RAM" > $msg_caption + echo -e "⚠️Обнаружен высокий уровень использования памяти⚠️\n🖥$(hostname)\n🌎$ip\n🔸$(echo $mem_usage% memory usage)\n#RAM" > $msg_caption echo -e "Memory consumption Report from $(hostname)\nServer Time : $(date +"%d%b%Y %T")\n\n\$free -m output\n$mem\n\n%MEM %CPU USER\tCMD" > $resource_usage_info ps -eo pmem,pcpu,user,cmd | sed '1d' | sort -nr >> $resource_usage_info caption=$(<$msg_caption)