First commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.venv/
|
||||||
|
debugpy.py
|
26
app.py
Normal file
26
app.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from flask import Flask, request
|
||||||
|
from subprocess import check_output
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
# http://192.168.177.48:5000/check-qnap-disk-state?ip=192.168.177.61&oid=.1.3.6.1.4.1.24681.1.2.11.1.7
|
||||||
|
@app.route('/check-qnap-disk-state')
|
||||||
|
def snmpcheck():
|
||||||
|
# Die Parameter aus der URL abrufen
|
||||||
|
Ip = request.args.get('ip')
|
||||||
|
Oid = request.args.get('oid')
|
||||||
|
|
||||||
|
process = check_output(['/usr/bin/snmpwalk', '-v', '1', '-c', 'public', Ip, Oid])
|
||||||
|
decoded_string = process.decode('utf-8')
|
||||||
|
healthy = True
|
||||||
|
statuscode = 200
|
||||||
|
for line in decoded_string.splitlines():
|
||||||
|
print(line)
|
||||||
|
if not 'good' in line.lower():
|
||||||
|
healthy = False
|
||||||
|
statuscode = 418
|
||||||
|
|
||||||
|
return f'SNMP result for IP {Ip}\nHealthy: {healthy}\n', statuscode
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True, host='192.168.177.48')
|
Reference in New Issue
Block a user