Created
June 1, 2023 07:59
-
-
Save thinkier/d89786abd395044e7f5ceab83db10455 to your computer and use it in GitHub Desktop.
Discord webhook for reporting RAID drive failure(s)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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