Skip to content

Commit 85c2999

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Tolerate missing deps in get-stats.py"
2 parents bfae1be + 1b601c7 commit 85c2999

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

roles/capture-performance-data/tasks/main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
{% for i in debian_suse_apache_deref_logs.results | default([]) + redhat_apache_deref_logs.results | default([]) %}
1414
--apache-log="{{ i.stat.path }}"
1515
{% endfor %}
16+
ignore_errors: yes

tools/get-stats.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@
66
import itertools
77
import json
88
import os
9-
import psutil
109
import re
1110
import socket
1211
import subprocess
1312
import sys
14-
import pymysql
13+
14+
try:
15+
import psutil
16+
except ImportError:
17+
psutil = None
18+
print('No psutil, process information will not be included',
19+
file=sys.stderr)
20+
21+
try:
22+
import pymysql
23+
except ImportError:
24+
pymysql = None
25+
print('No pymysql, database information will not be included',
26+
file=sys.stderr)
1527

1628
# https://www.elastic.co/blog/found-crash-elasticsearch#mapping-explosion
1729

@@ -144,10 +156,10 @@ def get_report_info():
144156

145157
data = {
146158
'services': get_services_stats(),
147-
'db': args.db_pass and get_db_stats(args.db_host,
148-
args.db_user,
149-
args.db_pass) or [],
150-
'processes': get_processes_stats(args.process),
159+
'db': pymysql and args.db_pass and get_db_stats(args.db_host,
160+
args.db_user,
161+
args.db_pass) or [],
162+
'processes': psutil and get_processes_stats(args.process) or [],
151163
'api': get_http_stats(args.apache_log),
152164
'report': get_report_info(),
153165
}

0 commit comments

Comments
 (0)