Discord-Webhook-RAM-disk-check/main.py

26 lines
761 B
Python
Raw Normal View History

2024-09-08 17:40:53 -04:00
import psutil
from discord_webhook import DiscordWebhook
# Replace with your actual webhook URL
2024-09-11 09:20:19 -04:00
webhook_url = "https://discord.com/api/webhooks/1283416699403636788/fOdCjvFoLeb3GsOO-QzV0q-N9J6L8kg0jlXuOOx9qaIPYltzIkaPfkrN0nNyFrfVNHEz"
2024-09-08 17:40:53 -04:00
# Get RAM usage
ram = psutil.virtual_memory()
ram_usage = f"RAM Usage: {ram.percent}%"
# Get Disk usage
disk = psutil.disk_usage('/')
disk_usage = f"Disk Usage: {disk.percent}%"
# Prepare the content to send
content = f"{ram_usage}\n{disk_usage}"
# Create a webhook and send the data
webhook = DiscordWebhook(url=webhook_url, content=content)
response = webhook.execute()
# Check response
if response.status_code == 204:
print("Data sent successfully.")
else:
print(f"Failed to send data: {response.status_code}")