Skip to content

Instantly share code, notes, and snippets.

@thinkier
Created June 1, 2023 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkier/d89786abd395044e7f5ceab83db10455 to your computer and use it in GitHub Desktop.
Save thinkier/d89786abd395044e7f5ceab83db10455 to your computer and use it in GitHub Desktop.
Discord webhook for reporting RAID drive failure(s)
#!/usr/bin/python3
from socket import gethostname
from requests import post
WEBHOOK_URL=''
USERNAME=gethostname() + ' /proc/mdstat'
with open('/proc/mdstat') as f:
mdstat = f.read()
if mdstat.find('active raid') >= 0:
for l in mdstat.split('\n'):
if l.find('active raid') >= 0 and l.find('(F)') >= 0:
post(WEBHOOK_URL, json={'username': USERNAME, 'content': '```\n' + mdstat + '\n```'})
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment