sysview-py 0.4.2__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sysview_py-0.4.2 → sysview_py-0.4.4}/PKG-INFO +1 -1
- {sysview_py-0.4.2 → sysview_py-0.4.4}/pyproject.toml +1 -1
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/db.py +1 -1
- sysview_py-0.4.4/src/sysview_py/helpers.py +18 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/report.py +7 -2
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/sysview.py +3 -2
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/templates/header.html +3 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/templates/service.html +5 -1
- {sysview_py-0.4.2 → sysview_py-0.4.4}/README.md +0 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/__init__.py +0 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/flock.py +0 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/main.py +0 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/static/simple.css +0 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/static/sysview.css +0 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/templates/card_view.html +0 -0
- {sysview_py-0.4.2 → sysview_py-0.4.4}/src/sysview_py/templates/footer.html +0 -0
|
@@ -90,7 +90,7 @@ class SysviewDB:
|
|
|
90
90
|
self._connection.commit()
|
|
91
91
|
|
|
92
92
|
def get_last_changed_item(self, item):
|
|
93
|
-
sql = f"SELECT report_id,raw_item FROM items WHERE command = '{item.command}' AND hostname = '{item.host}' AND
|
|
93
|
+
sql = f"SELECT report_id,raw_item FROM items WHERE command = '{item.command}' AND hostname = '{item.host}' AND report_id < {item.report_id} AND NOT status = '{item.status}' ORDER BY rowid DESC LIMIT 1"
|
|
94
94
|
last_changed_item = self._cursor.execute(sql).fetchone()
|
|
95
95
|
if last_changed_item is not None:
|
|
96
96
|
report_id = last_changed_item[0]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import unicodedata
|
|
2
|
+
import re
|
|
3
|
+
|
|
4
|
+
def slugify(value, allow_unicode=False):
|
|
5
|
+
"""
|
|
6
|
+
Taken from https://github.com/django/django/blob/master/django/utils/text.py
|
|
7
|
+
Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated
|
|
8
|
+
dashes to single dashes. Remove characters that aren't alphanumerics,
|
|
9
|
+
underscores, or hyphens. Convert to lowercase. Also strip leading and
|
|
10
|
+
trailing whitespace, dashes, and underscores.
|
|
11
|
+
"""
|
|
12
|
+
value = str(value)
|
|
13
|
+
if allow_unicode:
|
|
14
|
+
value = unicodedata.normalize('NFKC', value)
|
|
15
|
+
else:
|
|
16
|
+
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
|
|
17
|
+
value = re.sub(r'[^\w\s-]', '', value.lower())
|
|
18
|
+
return re.sub(r'[-\s]+', '-', value).strip('-_')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
from datetime import datetime, timedelta
|
|
3
|
+
from .helpers import slugify
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
status_map = {"UNKNOWN": 3, "CRITICAL": 2, "WARNING": 1, "OK": 0}
|
|
@@ -97,12 +98,16 @@ class ReportItem:
|
|
|
97
98
|
def name(self):
|
|
98
99
|
result = self.command
|
|
99
100
|
if len(result) > self.max_name_length:
|
|
100
|
-
result = result[: self.max_name_length]
|
|
101
|
+
result = result[: self.max_name_length]
|
|
101
102
|
return result
|
|
102
103
|
|
|
104
|
+
@property
|
|
105
|
+
def filename(self):
|
|
106
|
+
return slugify(self.name)
|
|
107
|
+
|
|
103
108
|
@property
|
|
104
109
|
def url_path(self):
|
|
105
|
-
return f"{self.report_type}_{self.
|
|
110
|
+
return f"{self.report_type}_{self.filename}.html"
|
|
106
111
|
|
|
107
112
|
@property
|
|
108
113
|
def status(self):
|
|
@@ -78,13 +78,14 @@ class Sysview:
|
|
|
78
78
|
html = env.get_template("service.html").render(
|
|
79
79
|
item=item,
|
|
80
80
|
title=host.name,
|
|
81
|
+
subtitle=item.name,
|
|
81
82
|
active="Services",
|
|
82
83
|
path="../../",
|
|
83
84
|
auto_refresh=False,
|
|
84
85
|
item_history=item_history,
|
|
85
86
|
)
|
|
86
|
-
html_path = host_dir / f"{item.report_type}_{item.
|
|
87
|
-
raw_path = host_dir / f"{item.report_type}_{item.
|
|
87
|
+
html_path = host_dir / f"{item.report_type}_{item.filename}.html"
|
|
88
|
+
raw_path = host_dir / f"{item.report_type}_{item.filename}.txt"
|
|
88
89
|
with open(html_path, "w") as f:
|
|
89
90
|
f.write(html)
|
|
90
91
|
with open(raw_path, "w") as f:
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
<nav>
|
|
3
3
|
<a href="host.html">Show host</a>
|
|
4
4
|
|
|
|
5
|
-
<a href="{{ item.report_type }}_{{ item.
|
|
5
|
+
<a href="{{ item.report_type }}_{{ item.filename }}.txt">Raw report</a>
|
|
6
6
|
</nav>
|
|
7
7
|
</table>
|
|
8
8
|
<pre id="{{item.status}}">{{ item.status }}: {{ item.status_text }}</pre>
|
|
9
|
+
<details>
|
|
10
|
+
<summary>full report</summary>
|
|
11
|
+
<pre>{{ item.raw_item }}</pre>
|
|
12
|
+
</details>
|
|
9
13
|
<i>Received: {{ item.date }}</i>
|
|
10
14
|
{% if item_history %}
|
|
11
15
|
<h3>History</h3>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|