24 lines
570 B
Python
24 lines
570 B
Python
from flask import Flask, Response
|
|
import re
|
|
|
|
app = Flask(__name__)
|
|
|
|
HEALTHY_PATTERN = re.compile(r'\[UU\]')
|
|
|
|
@app.route('/')
|
|
def check_raid():
|
|
try:
|
|
with open('/proc_host/mdstat', 'r') as f:
|
|
mdstat = f.read()
|
|
|
|
if HEALTHY_PATTERN.search(mdstat):
|
|
return Response("RAID OK", status=200)
|
|
else:
|
|
return Response("RAID DEGRADED", status=500)
|
|
|
|
except Exception as e:
|
|
return Response(f"Error checking RAID status: {str(e)}", status=500)
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0', port=8000)
|