2023-01-22 16:56:00 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2023-04-10 15:20:52 +02:00
|
|
|
# Replace the URL below with your Discord webhook URL
|
|
|
|
|
WEBHOOK_URL="https://discord.com/api/webhooks/"
|
|
|
|
|
|
|
|
|
|
# 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}')
|
2023-01-22 16:56:00 +01:00
|
|
|
running_processes=$(ps aux | wc -l)
|
2023-04-10 15:20:52 +02:00
|
|
|
uptime=$(uptime -p | cut -d " " -f 2-)
|
2023-01-22 16:56:00 +01:00
|
|
|
cpu_name=$(lscpu | grep "Model name" | awk -F: '{print $2}')
|
2023-04-10 15:20:52 +02:00
|
|
|
distro_full_name=$(lsb_release -s -d)
|
|
|
|
|
network_bandwidth_usage=$(ifstat -i enp6s18 1 1 | awk 'NR==3{print $1, $3}') # enp6s18 = network interface
|
2023-01-22 16:56:00 +01:00
|
|
|
|
2023-04-10 15:20:52 +02:00
|
|
|
# Creating JSON data for the Discord embed
|
|
|
|
|
timestamp=$(date +%s)
|
|
|
|
|
time_string=$(date --date="@${timestamp}" +%H:%M)
|
|
|
|
|
title="Linux Server Statistics ➜ <t:${timestamp}:f>"
|
|
|
|
|
json_data=$(cat <<EOF
|
|
|
|
|
{
|
|
|
|
|
"embeds": [
|
2023-01-22 16:56:00 +01:00
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"title": "$title",
|
|
|
|
|
"color": 65407,
|
|
|
|
|
"fields": [
|
2023-01-22 16:56:00 +01:00
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"name": "💻・CPU Name",
|
|
|
|
|
"value": "$cpu_name",
|
|
|
|
|
"inline": true
|
2023-01-22 16:56:00 +01:00
|
|
|
},
|
|
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"name": "📂・Distribution",
|
|
|
|
|
"value": "$distro_full_name",
|
|
|
|
|
"inline": true
|
2023-01-22 16:56:00 +01:00
|
|
|
},
|
|
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"name": "📡・Uptime",
|
|
|
|
|
"value": "$uptime",
|
|
|
|
|
"inline": true
|
2023-01-22 16:56:00 +01:00
|
|
|
},
|
|
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"name": "🖧・Network Bandwidth Usage (RX/TX)",
|
|
|
|
|
"value": "$network_bandwidth_usage GiB",
|
|
|
|
|
"inline": true
|
2023-01-22 16:56:00 +01:00
|
|
|
},
|
|
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"name": "💽・Used RAM Memory",
|
|
|
|
|
"value": "$used_ram%",
|
|
|
|
|
"inline": true
|
2023-01-22 16:56:00 +01:00
|
|
|
},
|
|
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"name": "💾・Disk Usage",
|
|
|
|
|
"value": "$disk_usage",
|
|
|
|
|
"inline": true
|
2023-01-22 16:56:00 +01:00
|
|
|
},
|
|
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"name": "⏳・Server Response Time",
|
|
|
|
|
"value": "$server_response_time ms",
|
|
|
|
|
"inline": true
|
2023-01-22 16:56:00 +01:00
|
|
|
},
|
|
|
|
|
{
|
2023-04-10 15:20:52 +02:00
|
|
|
"name": "📇・Running Processes",
|
|
|
|
|
"value": "$running_processes",
|
|
|
|
|
"inline": true
|
2023-01-22 16:56:00 +01:00
|
|
|
}
|
2023-04-10 15:20:52 +02:00
|
|
|
],
|
|
|
|
|
"thumbnail": {
|
|
|
|
|
"url": "$IMAGE_URL"
|
|
|
|
|
},
|
|
|
|
|
"footer": {
|
|
|
|
|
"text": "Copyright UltraLion#0404 © $(date +%Y)"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Sending the embed to the Discord webhook
|
|
|
|
|
curl -X POST -H "Content-Type: application/json" -d "$json_data" $WEBHOOK_URL
|
|
|
|
|
|
|
|
|
|
# Exit the script
|
|
|
|
|
exit
|