コード例 #1
0
 def alert_dismiss(self, request):
     from freenasUI.freeadmin.views import JsonResp
     from freenasUI.system.models import Alert
     from freenasUI.system.alert import alert_node
     msgid = request.POST.get("msgid", None)
     dismiss = request.POST.get("dismiss", None)
     assert msgid is not None  # FIX ME
     try:
         alert = Alert.objects.get(node=alert_node(), message_id=msgid)
         if dismiss == "0":
             alert.delete()
     except Alert.DoesNotExist:
         if dismiss == "1":
             alert = Alert.objects.create(node=alert_node(),
                                          message_id=msgid)
     return JsonResp(request, message="OK")
コード例 #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,
     })
コード例 #3
0
ファイル: site.py プロジェクト: amazted/freenas
 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.run()
     return render(request, "freeadmin/alert_status.html", {
         'alerts': alerts,
         'dismisseds': dismisseds,
     })
コード例 #4
0
ファイル: site.py プロジェクト: amazted/freenas
 def alert_dismiss(self, request):
     from freenasUI.freeadmin.views import JsonResp
     from freenasUI.system.models import Alert
     from freenasUI.system.alert import alert_node
     msgid = request.POST.get("msgid", None)
     dismiss = request.POST.get("dismiss", None)
     assert msgid is not None  # FIX ME
     try:
         alert = Alert.objects.get(node=alert_node(), message_id=msgid)
         if dismiss == "0":
             alert.dismiss = False
             alert.save()
         elif dismiss == "1":
             alert.dismiss = True
             alert.save()
     except Alert.DoesNotExist:
         if dismiss == "1":
             alert = Alert.objects.create(
                 node=alert_node(),
                 message_id=msgid,
                 dismiss=True,
             )
     return JsonResp(request, message="OK")
コード例 #5
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)
コード例 #6
0
ファイル: site.py プロジェクト: amazted/freenas
 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(), dismiss=True)]
     alerts = alertPlugins.run()
     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)