How to Monitor Your Server Disk Usage with Discord? 🚀🌟

This is a tutorial to setup a daily notification of the remaining space of your server directly on discord !🌟

How to Monitor Your Server Disk Usage with Discord? 🚀🌟

How to Monitor Your Server Disk Usage with Discord? 🚀🌟

Ever thought your server could talk to you? Imagine receiving daily disk space updates directly on Discord. Sounds like magic, right? 🎩✨

Let’s dive in and set this up !

🕵️ Step 1: Create a Discord Webhook

Creating a Discord webhook is like assigning a secret agent to your server. It's the first step in enabling seamless communication between your server and your Discord channel.

How to Set Up Your Secret Agent

  1. Navigate to Discord: Choose the channel for updates and select Edit channel > Integrations.
  2. Webhook Setup: If you're a webhook newbie, click Create Webhook. Otherwise, hit View Webhooks and then New Webhook.
  3. Identity Assignment: Give your webhook a name and an avatar to make it recognizable.
  4. Secure the Code: Copy the WEBHOOK URL; this is your secret code for communication.
  5. Mission Save: Don’t forget to hit Save.

Pasted image 20240310013126.png

Pasted image 20240310013304.png

🚀 Connect to Your Server

It’s time to go undercover. SSH into your server because this operation requires some command-line finesse.

🌟 Step 2: The Magic Script

Create a script named check-disk.sh. This script is the heart of our operation, allowing your server to send those crucial disk space updates.

Craft Your Spell

bash
#!/bin/bash

# Insert your webhook URL here - it's the direct line to Discord.
DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/XXXXXXXX/XXXXXXXXXX"

# Capturing the free space on your server. Everyone loves a bit of freedom, right?
ESPACE=$(df -h | grep '/dev/sda2' | awk '{print $4}')

# Sending the update through the magical portal of the internet.
curl -H "Content-Type: application/json" -X POST -d "{\"content\": \"🗃️ Free disk space: $ESPACE\"}" "$DISCORD_WEBHOOK_URL"

This spell enables your server to whisper sweet nothings about its available disk space directly into your Discord.

⭐ Step 3: Bring the Magic to Life

  1. Embed the Secret Code: Replace DISCORD_WEBHOOK_URL with your unique webhook URL.
  2. Awaken the Script: Grant it the power to execute:
bash
sudo chmod +x ./check-disk.sh

🎥 Step 4: The Daily Ritual

We want this magical communication to be a daily delight. Let's automate it:

shell
crontab -e

Whisper this incantation at the document's end:

shell
0 12 * * * /bin/bash /home/username/check-disk.sh

Now, like clockwork, your server will serenade you with updates every noon. 🍽️🕛

❤️ Step 5: Reignite Cron’s Heart

Sometimes, even ancient spirits need a reminder:

shell
systemctl restart cron

🌍 Step 7: Bask in the Glory

Congratulations! You’ve successfully bridged worlds. Your server is now sending daily disk space updates directly to your Discord. Welcome to a future where technology connects more deeply with our lives. 🚀🔮

Pasted image 20240310013946.png


● brev.al / blog

  1. Auth is a Dumpster Fire. Can 'Better Auth' Put It Out?

    A critical look at the painful state of web authentication. We dive into the failures of Auth.js, the hidden traps of Supabase, and whether the new challenger, Better Auth, is the hero we've been waiting for.

    #Server#Front#Workflow#Database7 min read

    Auth is a Dumpster Fire. Can 'Better Auth' Put It Out?
  2. They Said It Would Burn: Tales from the Trenches of PC Enthusiasm

    A deep dive into the world of PC enthusiasm, where online theory clashes with real-world results. From underdog motherboards powering beastly CPUs to the surprising state of GPU virtualization, this is a guide for those who dare to experiment.

    #Experiment#Linux#Server#ART6 min read

    They Said It Would Burn: Tales from the Trenches of PC Enthusiasm
  3. Your Own Personal Jarvis (or maybe just a Smart Teacup): Building a Local, Private LLM

    A guide for non-developers on setting up private, local Large Language Models using tools like Ollama and Open WebUI, covering hardware, privacy, scaling, and pitfalls, inspired by a lawyer's journey.

    #AI#Server#Linux#Workflow#Database10 min read

    Your Own Personal Jarvis (or maybe just a Smart Teacup): Building a Local, Private LLM
  4. Mastering State and Data Synchronization in Modern React Applications

    Explore common challenges in syncing frontend state with backend data in React and learn about various strategies, from simple refetching to advanced sync engines and modern architectural patterns.

    #Front#Database#News#Experiment#Server7 min read

    Mastering State and Data Synchronization in Modern React Applications

Another way of looking at things.