From 4eb1ce04f2c03bc618cacabb04a17037c4d15531 Mon Sep 17 00:00:00 2001 From: UltraLion <49597041+UltraLionfr@users.noreply.github.com> Date: Mon, 10 Apr 2023 15:20:52 +0200 Subject: [PATCH] Update script.sh --- script.sh | 127 +++++++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 59 deletions(-) diff --git a/script.sh b/script.sh index 3c3fb1c..4be86a8 100644 --- a/script.sh +++ b/script.sh @@ -1,79 +1,88 @@ #!/bin/bash -# Récupération des données -mem_usage=$(free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }') -disk_usage=$(df -h | awk '$NF=="/"{printf "%s\t", $5}') -net_usage=$(ifstat -i enp6s18 1 1 | awk 'NR==3{print $1, $3}') # enp6s18 = interface réseau -server_response=$(ping -c 1 google.com | awk -F '/' 'END {print $5}') -running_processes=$(ps aux | wc -l) -uptime=$(uptime -p) -cpu_name=$(lscpu | grep "Model name" | awk -F: '{print $2}') -distrib_name=$(lsb_release -s -d) +# Replace the URL below with your Discord webhook URL +WEBHOOK_URL="https://discord.com/api/webhooks/" -# Envoi des données à Discord en utilisant jq -data=$(jq -n \ ---arg title "Statistiques du VPS" \ ---arg color "10281099" \ ---arg mem_usage "$mem_usage" \ ---arg disk_usage "$disk_usage" \ ---arg net_usage "$net_usage %" \ ---arg server_response "$server_response ms" \ ---arg running_processes "$running_processes" \ ---arg uptime "$uptime" \ ---arg cpu_name "$cpu_name" \ ---arg distrib_name "$distrib_name" \ ---arg thumbnail_url "https://i.imgur.com/XT82bq2.png" \ # Image du système d'exploitation -'{ - embeds: [ +# Replace the URL below with the desired image URL +IMAGE_URL="https://i.imgur.com/XT82bq2.png" + +# Collecting server information +used_ram=$(free -m | awk 'NR==2{printf "%.2f", $3*100/$2}') +disk_usage=$(df -h | awk '$NF=="/"{printf "%s", $5}') +server_response_time=$(ping -c 1 google.com | awk -F '/' 'END {print $5}') +running_processes=$(ps aux | wc -l) +uptime=$(uptime -p | cut -d " " -f 2-) +cpu_name=$(lscpu | grep "Model name" | awk -F: '{print $2}') +distro_full_name=$(lsb_release -s -d) +network_bandwidth_usage=$(ifstat -i enp6s18 1 1 | awk 'NR==3{print $1, $3}') # enp6s18 = network interface + +# Creating JSON data for the Discord embed +timestamp=$(date +%s) +time_string=$(date --date="@${timestamp}" +%H:%M) +title="Linux Server Statistics ➜ " +json_data=$(cat <