diff --git a/.gitignore b/.gitignore index e27f8df..c6f9c58 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ env/ var/ log/ diff --git a/rrd/model/portal/alarm.py b/rrd/model/portal/alarm.py index 8a18dff..0194061 100644 --- a/rrd/model/portal/alarm.py +++ b/rrd/model/portal/alarm.py @@ -57,7 +57,7 @@ def __init__(self, id, endpoint, metric, func, cond, note, max_step, current_ste self.process_status = process_status @classmethod - def query(cls, page, limit, endpoint_query, metric_query, status): + def query(cls, page, limit, endpoint_query, metric_query, status, from_data, to_data): where = '1=1' params = [] if status == "PROBLEM" or status == "OK": @@ -72,6 +72,15 @@ def query(cls, page, limit, endpoint_query, metric_query, status): where += ' and metric like %s' params.append('%' + metric_query + '%') + if from_data != "": + where += ' and timestamp >= %s' + params.append(from_data) + + if to_data != "": + where += ' and timestamp <= %s' + params.append(to_data) + + vs = cls.select_vs(where=where, params=params, page=page, limit=limit, order='update_at desc') total = cls.total(where, params) diff --git a/rrd/model/portal/bean.py b/rrd/model/portal/bean.py index edfb332..1b58ed5 100644 --- a/rrd/model/portal/bean.py +++ b/rrd/model/portal/bean.py @@ -82,7 +82,6 @@ def select(cls, cols=None, where=None, params=None, order=None, limit=None, page if offset < 0: offset = 0 sql = '%s OFFSET %s' % (sql, offset) - return cls._db.query_all(sql, params) @classmethod diff --git a/rrd/templates/portal/alarm/case.html b/rrd/templates/portal/alarm/case.html index 9118662..ca60e72 100644 --- a/rrd/templates/portal/alarm/case.html +++ b/rrd/templates/portal/alarm/case.html @@ -1,6 +1,47 @@ {% extends "portal/layout.html" %} {% block content %} - +
+
+ + +
+
+ + +
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+ + +
+

{{_('alerting cases')}} @@ -14,6 +55,7 @@

{{_('alerting cases')}} {{case.status}} P{{case.priority}} [第#{{case.current_step}}次/最大{{case.max_step}}次] + {{case.timestamp}} {{case.timestamp|time_duration}} [ template @@ -55,7 +97,7 @@

{{_('alerting cases')}} {% import "portal/blocks.html" as blocks %}
- {{ blocks.pager('/portal/alarm-dash/case?status='+status, total, limit, page) }} + {{ blocks.pager('/portal/alarm-dash/case?status='+status+'&endpoint_q='+endpoint_q+'&metric_q='+metric_q+'&from_data='+from_data+'&to_data='+to_data, total, limit, page) }}

diff --git a/rrd/templates/portal/alarm/case_problem.html b/rrd/templates/portal/alarm/case_problem.html new file mode 100644 index 0000000..9c84485 --- /dev/null +++ b/rrd/templates/portal/alarm/case_problem.html @@ -0,0 +1,105 @@ +{% extends "portal/layout.html" %} +{% block content %} +
+
+ + +
+
+ + +
+
+ +
+ + + + +
+
+
+ +
+ + + + +
+
+ + + +
+
+
+
+

{{_('alerting cases')}} + {{_('not recovered cases')}} +

+
+
+
+ {%for case in cases%} +
+ + {{case.status}} P{{case.priority}} + [第#{{case.current_step}}次/最大{{case.max_step}}次] + {{case.timestamp}} + {{case.timestamp|time_duration}} + [ + template + + {%if case.strategy_id>0%} + ¦ + strategy + {%endif%} + + {%if case.expression_id>0%} + ¦ + expression + {%endif%} + + ¦ + delete + ¦ + {{_('event list')}} + ] +
+ + {{case.endpoint}} + ¦ + {{case.metric}} + ¦ + {{case.func}} + ¦ + {{case.cond}} + ¦ + note: {{case.note}} +
+
+ {%endfor%} + {{_('select all')}}/ + {{_('reverse select')}} + +
+
+ + {% import "portal/blocks.html" as blocks %} +
+ {{ blocks.pager('/portal/alarm-dash/case?status='+status+'&endpoint_q='+endpoint_q+'&metric_q='+metric_q+'&from_data='+from_data+'&to_data='+to_data, total, limit, page) }} +
+ +
+{%endblock%} diff --git a/rrd/templates/portal/expression/list.html b/rrd/templates/portal/expression/list.html index 6753dff..1f64e0e 100644 --- a/rrd/templates/portal/expression/list.html +++ b/rrd/templates/portal/expression/list.html @@ -58,7 +58,7 @@
{% import "portal/blocks.html" as blocks %} - {{ blocks.pager('/portal/expressions?q='+data.query+'&mine='+data.mine, data.total, data.limit, data.page) }} + {{ blocks.pager('/portal/expression?q='+data.query+'&mine='+data.mine, data.total, data.limit, data.page) }}

diff --git a/rrd/view/portal/alarm.py b/rrd/view/portal/alarm.py index ba1bad6..31be220 100644 --- a/rrd/view/portal/alarm.py +++ b/rrd/view/portal/alarm.py @@ -12,9 +12,14 @@ def alarm_dash_case_get(): endpoint_q = request.args.get("endpoint_q") or "" metric_q = request.args.get("metric_q") or "" status = request.args.get("status") or "" + from_data = request.args.get("from_data") or "" + to_data = request.args.get("to_data") or "" - cases, total = EventCase.query(page, limit, endpoint_q, metric_q, status) - return render_template("portal/alarm/case.html", **locals()) + cases, total = EventCase.query(page, limit, endpoint_q, metric_q, status, from_data, to_data) + if status == 'PROBLEM': + return render_template("portal/alarm/case_problem.html", **locals()) + else: + return render_template("portal/alarm/case.html", **locals()) @app.route("/portal/alarm-dash/case/event") def alarm_dash_event_get():