added debug for api calls
This commit is contained in:
39
app.py
39
app.py
@ -119,17 +119,15 @@ class UnifiAPI:
|
||||
|
||||
# Monitoring functions
|
||||
def run_diagnostics(device):
|
||||
config = load_config()
|
||||
unifi = UnifiAPI(config)
|
||||
|
||||
diagnostics = unifi.get_device_diagnostics(device)
|
||||
|
||||
if device['connection_type'] == 'fiber':
|
||||
# Add fiber-specific diagnostics
|
||||
sfp_data = get_sfp_diagnostics(device['ip'])
|
||||
diagnostics['sfp'] = sfp_data
|
||||
|
||||
return diagnostics
|
||||
try:
|
||||
config = load_config()
|
||||
unifi = UnifiAPI(config)
|
||||
diagnostics = unifi.get_device_diagnostics(device)
|
||||
logger.debug(f"Got diagnostics for {device['name']}: {diagnostics}")
|
||||
return diagnostics
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting diagnostics for {device['name']}: {str(e)}")
|
||||
return {"error": str(e)}
|
||||
|
||||
def update_status():
|
||||
while True:
|
||||
@ -160,14 +158,17 @@ def status():
|
||||
|
||||
@app.route('/api/diagnostics')
|
||||
def get_diagnostics():
|
||||
config = load_config()
|
||||
diagnostics = {}
|
||||
for device in config['devices']:
|
||||
if device.get('device_id'):
|
||||
logger.debug(f"Fetching diagnostics for device: {device['name']}")
|
||||
diagnostics[device['name']] = run_diagnostics(device)
|
||||
logger.debug(f"Returning diagnostics: {diagnostics}")
|
||||
return jsonify(diagnostics)
|
||||
try:
|
||||
config = load_config()
|
||||
diagnostics = {}
|
||||
for device in config['devices']:
|
||||
if device.get('device_id'):
|
||||
logger.debug(f"Fetching diagnostics for device: {device['name']}")
|
||||
diagnostics[device['name']] = run_diagnostics(device)
|
||||
return jsonify(diagnostics)
|
||||
except Exception as e:
|
||||
logger.error(f"Error in diagnostics endpoint: {str(e)}")
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
# Application entry point
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user