Exemplo n.º 1
0
 def alert_detail(self, request):
     from freenasUI.system.models import Alert
     from freenasUI.system.alert import alert_node, alertPlugins
     dismisseds = [a.message_id for a in Alert.objects.filter(node=alert_node(), dismiss=True)]
     alerts = alertPlugins.get_alerts()
     return render(request, "freeadmin/alert_status.html", {
         'alerts': alerts,
         'dismisseds': dismisseds,
     })
Exemplo n.º 2
0
 def alert_detail(self, request):
     from freenasUI.system.models import Alert
     from freenasUI.system.alert import alert_node, alertPlugins
     dismisseds = [a.message_id for a in Alert.objects.filter(node=alert_node(), dismiss=True)]
     alerts = alertPlugins.get_alerts()
     return render(request, "freeadmin/alert_status.html", {
         'alerts': alerts,
         'dismisseds': dismisseds,
     })
Exemplo n.º 3
0
 def get_alerts(self):
     """
     Temporary workaround to get alerts from legacy UI code
     """
     rv = []
     for alert in alertPlugins.get_alerts():
         if alert.getDismiss():
             continue
         rv.append(f'{alert.getLevel()} - {alert.getMessage()}')
     return '\n'.join(rv)
Exemplo n.º 4
0
 def alert_status(self, request):
     from freenasUI.system.models import Alert
     from freenasUI.system.alert import alert_node, alertPlugins
     dismisseds = [
         a.message_id for a in Alert.objects.filter(node=alert_node())
     ]
     alerts = alertPlugins.get_alerts()
     current = 'OK'
     for alert in alerts:
         # Skip dismissed alerts
         if alert.getId() in dismisseds:
             continue
         status = alert.getLevel()
         if ((status == 'WARN' and current == 'OK')
                 or status == 'CRIT' and current in ('OK', 'WARN')):
             current = status
     return HttpResponse(current)