rolle,
@rolle@mementomori.social avatar

So proud of my disk size monitoring script, so I'm just going to share it here as-is:

#!/bin/bash

diskspace.sh

Set up the mountpoint

MOUNTPOINT="/mnt/somethingsomething"

Get disk usage and total

DISK_USAGE=$(df -hk | grep "$MOUNTPOINT" | awk '{print $3}')
DISK_TOTAL=$(df -hk | grep "$MOUNTPOINT" | awk '{print $2}')

Convert from block sizes to GB

DISK_USAGE_GB=$((DISK_USAGE / 1024 / 1024))
DISK_TOTAL_GB=$((DISK_TOTAL / 1024 / 1024))

How much is allowed to be left

DISK_GB_LIMIT="8"

How much is left

DISK_GB_LEFT=$((DISK_TOTAL_GB - DISK_USAGE_GB))

if [ "$DISK_GB_LEFT" -lt "$DISK_GB_LIMIT" ]; then
echo "Less than ${DISK_GB_LIMIT} GB left! Only ${DISK_GB_LEFT} GB left!"
else
echo "There is still ${DISK_GB_LEFT} of ${DISK_TOTAL_GB} GB left. No need to be alarmed as the alarming size is ${DISK_GB_LIMIT} GB."

Your heartbeat curl here:

curl https://example.com/endpoint;
fi

Set up a cronjob:

Disk size heartbeat

*/3 * * * * bash /path/to/diskspace.sh >/dev/null 2>&1

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Bash
  • DreamBathrooms
  • InstantRegret
  • ethstaker
  • magazineikmin
  • GTA5RPClips
  • rosin
  • modclub
  • Youngstown
  • ngwrru68w68
  • slotface
  • osvaldo12
  • kavyap
  • mdbf
  • thenastyranch
  • JUstTest
  • everett
  • cubers
  • cisconetworking
  • normalnudes
  • Durango
  • anitta
  • khanakhh
  • tacticalgear
  • tester
  • provamag3
  • megavids
  • Leos
  • lostlight
  • All magazines