-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some helper tools for viewing saved summaries
- Loading branch information
Showing
9 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
export PYTHONPATH=$PYTHONPATH:$(dirname $0)/.. | ||
$(dirname $0)/../tools/summary/view.py $@ |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
# | ||
# Description: diff two hotsos summary outputs. | ||
# | ||
src=${1:-""} | ||
dst=${2:-""} | ||
format={3:-yaml} | ||
if [[ -z $src ]] || [[ -z $dst ]]; then | ||
echo "USAGE: `basename $0` <src dir> <dst dir>" | ||
exit | ||
fi | ||
|
||
for f in `find $src -maxdepth 1 -name *summary.${format}`; do | ||
diff -y $dst/$f $f| less | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
# | ||
# Description: display only bugs and issues from summary outputs. | ||
# | ||
path=${1:-hotsos-output} | ||
for f in `find $path -maxdepth 1 -name *summary.json`; do | ||
clear | ||
jq -r '"\nHostname: " + .system.hostname, | ||
"Issues:", (.[]|to_entries[]|select(.key=="potential-issues")|.value|to_entries[]|.key, .value), | ||
"Bugs:", (.[]|to_entries[]|select(.key=="known-bugs")|.value|to_entries[]|.key, .value)' $f | ||
read -p "Next? [ENTER]" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# | ||
# Description: less each hotsos summary in path | ||
# | ||
path=${1:-hotsos-output} | ||
for f in `find $path -maxdepth 1 -name *summary.yaml`; do | ||
less $f | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Create a structured summary of key information from hotsos summary outputs. | ||
""" | ||
import glob | ||
import os | ||
import json | ||
import sys | ||
import subprocess | ||
|
||
import yaml | ||
# load all plugins | ||
import hotsos.plugin_extensions # noqa: F401, pylint: disable=W0611 | ||
from hotsos.core import plugintools | ||
|
||
|
||
def get_summary(root): | ||
if root is None: | ||
root = '.' | ||
|
||
paths = [] | ||
if os.path.isdir(root): | ||
for encoding in ['json', 'yaml']: | ||
results = glob.glob(os.path.join(root, f'*.{encoding}')) | ||
if results: | ||
paths = results | ||
break | ||
else: | ||
paths = [root] | ||
|
||
for path in paths: | ||
with open(path, encoding='utf-8') as fd: | ||
if path.endswith('json'): | ||
yield json.loads(fd.read()) | ||
else: | ||
yield yaml.safe_load(fd.read()) | ||
|
||
|
||
def get_info(s): | ||
_enabled = [] | ||
_services = {} | ||
_has_bugs = {} | ||
_has_potential_issues = {} | ||
for plugin in plugintools.PLUGINS: | ||
if plugin in s: | ||
_enabled.append(plugin) | ||
if 'services' in s[plugin]: | ||
enabled = s[plugin]['services'] | ||
enabled = enabled.get('systemd', {}) | ||
_services[plugin] = enabled.get('enabled') | ||
|
||
if 'known-bugs' in s[plugin]: | ||
_has_bugs.update(s[plugin]['known-bugs']) | ||
|
||
if 'potential-issues' in s[plugin]: | ||
_has_potential_issues.update( | ||
s[plugin]['potential-issues']) | ||
|
||
return _enabled, _services, _has_bugs, _has_potential_issues | ||
|
||
|
||
def main(): | ||
if len(sys.argv) > 1: | ||
path = sys.argv[1] | ||
else: | ||
path = None | ||
|
||
for s in get_summary(path): | ||
subprocess.call(['clear']) | ||
print(f"host: {s['system']['hostname']}") | ||
print(f"date: {s['system']['date']}") | ||
_enabled, _services, _has_bugs, _has_potential_issues = get_info(s) | ||
# print("enabled: {}".format(', '.join(sorted(_enabled)))) | ||
print("services:") | ||
for plugin, svcs in _services.items(): | ||
_svcs = ', '.join(svcs) | ||
print(f" {plugin}: {_svcs}") | ||
|
||
if _has_bugs: | ||
print("bugs:") | ||
for btype, content in _has_bugs.items(): | ||
_content = '\n'.join(content) | ||
print(f" {btype}: {_content}\n") | ||
|
||
if _has_potential_issues: | ||
print("issues:") | ||
for btype, content in _has_potential_issues.items(): | ||
print(f" {btype}:") | ||
for msg in content: | ||
print(f" {msg}") | ||
|
||
input("\nNext? [ENTER]") | ||
|
||
print("") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters