nginx-lens 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- commands/analyze.py +14 -1
- commands/diff.py +3 -0
- commands/graph.py +4 -0
- commands/health.py +4 -0
- commands/include.py +4 -0
- commands/logs.py +12 -2
- commands/route.py +3 -0
- commands/syntax.py +8 -2
- commands/tree.py +5 -0
- {nginx_lens-0.1.2.dist-info → nginx_lens-0.1.4.dist-info}/METADATA +1 -1
- {nginx_lens-0.1.2.dist-info → nginx_lens-0.1.4.dist-info}/RECORD +14 -14
- {nginx_lens-0.1.2.dist-info → nginx_lens-0.1.4.dist-info}/WHEEL +0 -0
- {nginx_lens-0.1.2.dist-info → nginx_lens-0.1.4.dist-info}/entry_points.txt +0 -0
- {nginx_lens-0.1.2.dist-info → nginx_lens-0.1.4.dist-info}/top_level.txt +0 -0
commands/analyze.py
CHANGED
|
@@ -15,7 +15,20 @@ console = Console()
|
|
|
15
15
|
|
|
16
16
|
def analyze(config_path: str = typer.Argument(..., help="Путь к nginx.conf")):
|
|
17
17
|
"""
|
|
18
|
-
Анализирует конфигурацию Nginx на типовые
|
|
18
|
+
Анализирует конфигурацию Nginx на типовые проблемы и best practices.
|
|
19
|
+
|
|
20
|
+
Показывает:
|
|
21
|
+
- Конфликты location-ов
|
|
22
|
+
- Дублирующиеся директивы
|
|
23
|
+
- Пустые блоки
|
|
24
|
+
- Потенциальные проблемы (proxy_pass без схемы, autoindex on, if, server_tokens on, SSL, лимиты, deprecated и др.)
|
|
25
|
+
- Неиспользуемые переменные
|
|
26
|
+
- Конфликты listen/server_name
|
|
27
|
+
- Проблемы с rewrite
|
|
28
|
+
- Мертвые location-ы
|
|
29
|
+
|
|
30
|
+
Пример:
|
|
31
|
+
nginx-lens analyze /etc/nginx/nginx.conf
|
|
19
32
|
"""
|
|
20
33
|
tree = parse_nginx_config(config_path)
|
|
21
34
|
conflicts = find_location_conflicts(tree)
|
commands/diff.py
CHANGED
commands/graph.py
CHANGED
|
@@ -12,6 +12,10 @@ def graph(
|
|
|
12
12
|
):
|
|
13
13
|
"""
|
|
14
14
|
Генерирует схему маршрутизации nginx (dot/mermaid).
|
|
15
|
+
|
|
16
|
+
Пример:
|
|
17
|
+
nginx-lens graph /etc/nginx/nginx.conf --format dot
|
|
18
|
+
nginx-lens graph /etc/nginx/nginx.conf --format mermaid
|
|
15
19
|
"""
|
|
16
20
|
tree = parse_nginx_config(config_path)
|
|
17
21
|
if format == "dot":
|
commands/health.py
CHANGED
|
@@ -14,6 +14,10 @@ def health(
|
|
|
14
14
|
):
|
|
15
15
|
"""
|
|
16
16
|
Проверяет доступность upstream-серверов, определённых в nginx.conf. Выводит таблицу.
|
|
17
|
+
|
|
18
|
+
Пример:
|
|
19
|
+
nginx-lens health /etc/nginx/nginx.conf
|
|
20
|
+
nginx-lens health /etc/nginx/nginx.conf --timeout 5 --retries 3
|
|
17
21
|
"""
|
|
18
22
|
tree = parse_nginx_config(config_path)
|
|
19
23
|
upstreams = tree.get_upstreams()
|
commands/include.py
CHANGED
|
@@ -13,6 +13,10 @@ def include_tree(
|
|
|
13
13
|
):
|
|
14
14
|
"""
|
|
15
15
|
Показывает дерево include-ов, циклы и shadowing директив.
|
|
16
|
+
|
|
17
|
+
Пример:
|
|
18
|
+
nginx-lens include-tree /etc/nginx/nginx.conf
|
|
19
|
+
nginx-lens include-tree /etc/nginx/nginx.conf --directive server_name
|
|
16
20
|
"""
|
|
17
21
|
tree = build_include_tree(config_path)
|
|
18
22
|
rich_tree = Tree(f"[bold blue]{config_path}[/bold blue]")
|
commands/logs.py
CHANGED
|
@@ -4,7 +4,7 @@ from rich.table import Table
|
|
|
4
4
|
import re
|
|
5
5
|
from collections import Counter, defaultdict
|
|
6
6
|
|
|
7
|
-
app = typer.Typer()
|
|
7
|
+
app = typer.Typer(help="Анализ access.log/error.log: топ-статусы, пути, IP, User-Agent, ошибки.")
|
|
8
8
|
console = Console()
|
|
9
9
|
|
|
10
10
|
log_line_re = re.compile(r'(?P<ip>\S+) \S+ \S+ \[(?P<time>[^\]]+)\] "(?P<method>\S+) (?P<path>\S+) [^\"]+" (?P<status>\d{3})')
|
|
@@ -15,7 +15,17 @@ def logs(
|
|
|
15
15
|
top: int = typer.Option(10, help="Сколько топ-значений выводить")
|
|
16
16
|
):
|
|
17
17
|
"""
|
|
18
|
-
Анализирует access.log/error.log
|
|
18
|
+
Анализирует access.log/error.log.
|
|
19
|
+
|
|
20
|
+
Показывает:
|
|
21
|
+
- Топ HTTP-статусов (404, 500 и др.)
|
|
22
|
+
- Топ путей
|
|
23
|
+
- Топ IP-адресов
|
|
24
|
+
- Топ User-Agent
|
|
25
|
+
- Топ путей с ошибками 404/500
|
|
26
|
+
|
|
27
|
+
Пример:
|
|
28
|
+
nginx-lens logs /var/log/nginx/access.log --top 20
|
|
19
29
|
"""
|
|
20
30
|
status_counter = Counter()
|
|
21
31
|
path_counter = Counter()
|
commands/route.py
CHANGED
commands/syntax.py
CHANGED
|
@@ -5,7 +5,7 @@ import subprocess
|
|
|
5
5
|
import os
|
|
6
6
|
import re
|
|
7
7
|
|
|
8
|
-
app = typer.Typer()
|
|
8
|
+
app = typer.Typer(help="Проверка синтаксиса nginx-конфига через nginx -t с подсветкой ошибок.")
|
|
9
9
|
console = Console()
|
|
10
10
|
|
|
11
11
|
ERROR_RE = re.compile(r'in (.+?):(\d+)')
|
|
@@ -16,7 +16,13 @@ def syntax(
|
|
|
16
16
|
nginx_path: str = typer.Option("nginx", help="Путь к бинарю nginx (по умолчанию 'nginx')")
|
|
17
17
|
):
|
|
18
18
|
"""
|
|
19
|
-
Проверяет синтаксис nginx-конфига через nginx -t.
|
|
19
|
+
Проверяет синтаксис nginx-конфига через nginx -t.
|
|
20
|
+
|
|
21
|
+
В случае ошибки показывает место в виде таблицы с контекстом.
|
|
22
|
+
|
|
23
|
+
Пример:
|
|
24
|
+
nginx-lens syntax /etc/nginx/nginx.conf
|
|
25
|
+
nginx-lens syntax /etc/nginx/nginx.conf --nginx-path /usr/local/sbin/nginx
|
|
20
26
|
"""
|
|
21
27
|
cmd = [nginx_path, "-t", "-c", os.path.abspath(config_path)]
|
|
22
28
|
try:
|
commands/tree.py
CHANGED
|
@@ -28,6 +28,11 @@ def tree(
|
|
|
28
28
|
):
|
|
29
29
|
"""
|
|
30
30
|
Визуализирует структуру nginx.conf в виде дерева.
|
|
31
|
+
|
|
32
|
+
Пример:
|
|
33
|
+
nginx-lens tree /etc/nginx/nginx.conf
|
|
34
|
+
nginx-lens tree /etc/nginx/nginx.conf --markdown
|
|
35
|
+
nginx-lens tree /etc/nginx/nginx.conf --html
|
|
31
36
|
"""
|
|
32
37
|
tree_obj = parse_nginx_config(config_path)
|
|
33
38
|
root = RichTree(f"[bold blue]nginx.conf[/bold blue]")
|
|
@@ -11,16 +11,16 @@ analyzer/route.py,sha256=2xxQooQEsfn10tzGCZUoP32T0OnTMnPB6qRgBR6not8,2345
|
|
|
11
11
|
analyzer/unused.py,sha256=Ixzv0bPsw9IafblVwLiAOgugdg2dGu1MJDtuoqzPZiY,1066
|
|
12
12
|
analyzer/warnings.py,sha256=zC36QMvegA2eQPvZ-P1eysrX_kXHx5A1MUKHKKNvG5c,5784
|
|
13
13
|
commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
commands/analyze.py,sha256=
|
|
14
|
+
commands/analyze.py,sha256=ZpChHk6QXut3S1PvslcX_4IeqdaaXtUXX-ogkB-a6GQ,3618
|
|
15
15
|
commands/cli.py,sha256=0uzz71nMXTGlY1odZkEGwtVOjf7uq7762qRLXQaQURo,780
|
|
16
|
-
commands/diff.py,sha256=
|
|
17
|
-
commands/graph.py,sha256=
|
|
18
|
-
commands/health.py,sha256=
|
|
19
|
-
commands/include.py,sha256=
|
|
20
|
-
commands/logs.py,sha256=
|
|
21
|
-
commands/route.py,sha256=
|
|
22
|
-
commands/syntax.py,sha256=
|
|
23
|
-
commands/tree.py,sha256=
|
|
16
|
+
commands/diff.py,sha256=VeZsUu1BYrDubDFrmM5xC4DUWZvWUjFRHfddXm3-I3c,1373
|
|
17
|
+
commands/graph.py,sha256=xEDMAOZ9Z5gaOGqLhSIGeRlDvRfSborWwUVjk-XLCsk,930
|
|
18
|
+
commands/health.py,sha256=d2bBui0qauQtO4Ll9cjniKR1Y5dYJBQzG9CECDnsUQ4,1365
|
|
19
|
+
commands/include.py,sha256=zPqJpbbSU_6S3L4ntFncPmyFWba8smvdCRog_SFuAFI,1907
|
|
20
|
+
commands/logs.py,sha256=NkBJAfKGXvZQDEjHwqdfYikKFMyCrEtjfDeD_MJ9ycg,3435
|
|
21
|
+
commands/route.py,sha256=Rnm-zjIbos0NJjUZ0gRs27dCmUfF1tKWKVzdcFcl9hA,1224
|
|
22
|
+
commands/syntax.py,sha256=TM9uOZ7MsxF78iJlajybWzouJgH2YeAbUXo8i3GxPVo,2624
|
|
23
|
+
commands/tree.py,sha256=NEhNU66_e0JCsD4xh4315TM-xwo8NkPwc00lZ4saPzE,1844
|
|
24
24
|
exporter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
exporter/graph.py,sha256=WYUrqUgCaK6KihgxAcRHaQn4oMo6b7ybC8yb_36ZIsA,3995
|
|
26
26
|
exporter/html.py,sha256=uquEM-WvBt2aV9GshgaI3UVhYd8sD0QQ-OmuNtvYUdU,798
|
|
@@ -29,8 +29,8 @@ parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
29
29
|
parser/nginx_parser.py,sha256=JqZ3clNy4Nf-bmbsx_rJUL7EgRoB79b87eEu_isMeqg,3577
|
|
30
30
|
upstream_checker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
upstream_checker/checker.py,sha256=9-6CMUTN7gXUACP8EwX722QogfujZyV-WWWUeM3a79k,455
|
|
32
|
-
nginx_lens-0.1.
|
|
33
|
-
nginx_lens-0.1.
|
|
34
|
-
nginx_lens-0.1.
|
|
35
|
-
nginx_lens-0.1.
|
|
36
|
-
nginx_lens-0.1.
|
|
32
|
+
nginx_lens-0.1.4.dist-info/METADATA,sha256=MkC1F3wihoxkMKrTJqH0DMrgrZmtTg4L8VqbY85J0jg,476
|
|
33
|
+
nginx_lens-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
34
|
+
nginx_lens-0.1.4.dist-info/entry_points.txt,sha256=qEcecjSyLqcJjbIVlNlTpqAhPqDyaujUV5ZcBTAr3po,48
|
|
35
|
+
nginx_lens-0.1.4.dist-info/top_level.txt,sha256=mxLJO4rZg0rbixVGhplF3fUNFs8vxDIL25ronZNvRy4,51
|
|
36
|
+
nginx_lens-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|