Skip to content

Instantly share code, notes, and snippets.

@elpatron68
Created November 25, 2023 17:43
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 elpatron68/a729e36632b7123664eae3b46e8d89b1 to your computer and use it in GitHub Desktop.
Save elpatron68/a729e36632b7123664eae3b46e8d89b1 to your computer and use it in GitHub Desktop.
SNMP2HTML Broker for Update-Kuma
# Webserver to check a device disk state by SNMP with Uptime-Kuma
# Requirements:
# pip install flask
# apt install snmp
#
# Run: python app.py
#
# Example: # 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
from flask import Flask, request
from subprocess import check_output
app = Flask(__name__)
@app.route('/check-qnap-disk-state')
def snmp_disk_status():
# 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():
if not 'good' in line.lower():
healthy = False
statuscode = 418
return f'SNMP result for IP {Ip}\nOID: {Oid}\nSNMP-Output: {decoded_string}\nHealthy: {healthy}\n', statuscode
if __name__ == '__main__':
app.run(debug=True, host='192.168.177.48')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment