Merge "Tolerate missing deps in get-stats.py"

This commit is contained in:
Zuul 2022-04-27 22:49:07 +00:00 committed by Gerrit Code Review
commit 85c2999e27
2 changed files with 19 additions and 6 deletions

View File

@ -13,3 +13,4 @@
{% for i in debian_suse_apache_deref_logs.results | default([]) + redhat_apache_deref_logs.results | default([]) %} {% for i in debian_suse_apache_deref_logs.results | default([]) + redhat_apache_deref_logs.results | default([]) %}
--apache-log="{{ i.stat.path }}" --apache-log="{{ i.stat.path }}"
{% endfor %} {% endfor %}
ignore_errors: yes

View File

@ -6,12 +6,24 @@ import glob
import itertools import itertools
import json import json
import os import os
import psutil
import re import re
import socket import socket
import subprocess import subprocess
import sys import sys
try:
import psutil
except ImportError:
psutil = None
print('No psutil, process information will not be included',
file=sys.stderr)
try:
import pymysql import pymysql
except ImportError:
pymysql = None
print('No pymysql, database information will not be included',
file=sys.stderr)
# https://www.elastic.co/blog/found-crash-elasticsearch#mapping-explosion # https://www.elastic.co/blog/found-crash-elasticsearch#mapping-explosion
@ -144,10 +156,10 @@ if __name__ == '__main__':
data = { data = {
'services': get_services_stats(), 'services': get_services_stats(),
'db': args.db_pass and get_db_stats(args.db_host, 'db': pymysql and args.db_pass and get_db_stats(args.db_host,
args.db_user, args.db_user,
args.db_pass) or [], args.db_pass) or [],
'processes': get_processes_stats(args.process), 'processes': psutil and get_processes_stats(args.process) or [],
'api': get_http_stats(args.apache_log), 'api': get_http_stats(args.apache_log),
'report': get_report_info(), 'report': get_report_info(),
} }