25 lines
687 B
Bash
Executable file
25 lines
687 B
Bash
Executable file
#!/bin/bash
|
|
# view the ansible logs
|
|
# takes all the options of grep and passes them straight through - then parses the output so it looks better and readable
|
|
# should only be used on the .log files not the .info files. info files are flat readable
|
|
# example:
|
|
# logview CHANGED /var/log/2013/07/01/mirrorlist/*/*.log
|
|
|
|
IFS='
|
|
'
|
|
|
|
for line in `grep -H $@`
|
|
do
|
|
logpath=`echo $line| cut -d: -f1`
|
|
hostname=`basename $logpath`
|
|
echo -n "$hostname "
|
|
echo $line | cut -d: -f2-| cut -f3-4
|
|
json=`echo $line | cut -d: -f2- |cut -f5-`
|
|
echo $json| python -m json.tool 2>/dev/null >&2
|
|
if [ $? != 0 ]; then
|
|
echo "Error parsing json"
|
|
else
|
|
echo $json| python -m json.tool
|
|
fi
|
|
done
|
|
|