summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSeth Vidal <skvidal@fedoraproject.org>2013-07-01 18:47:01 +0000
committerSeth Vidal <skvidal@fedoraproject.org>2013-07-01 18:47:01 +0000
commit7dc7a9207e4501a2420bb978ec2ae92832b705cb (patch)
treea09f62a7a5cb85c8e6d60fb27deca3ddd3b335df /scripts
parent79d8b2e65639879321879c87781e6ea2d14253bc (diff)
downloadansible-7dc7a9207e4501a2420bb978ec2ae92832b705cb.tar.gz
ansible-7dc7a9207e4501a2420bb978ec2ae92832b705cb.tar.xz
ansible-7dc7a9207e4501a2420bb978ec2ae92832b705cb.zip
2 rough cuts for viewing/listing the ansible logs
- see the scripts for how they work and example usages
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/loglist30
-rwxr-xr-xscripts/logview25
2 files changed, 55 insertions, 0 deletions
diff --git a/scripts/loglist b/scripts/loglist
new file mode 100755
index 000000000..fd2e0905c
--- /dev/null
+++ b/scripts/loglist
@@ -0,0 +1,30 @@
+#!/bin/bash
+# lists what playbooks/processes have happened today
+# takes 2 optional arguments: date string, playbook name
+# examples:
+# ./loglist
+# ./loglist yesterday
+# ./loglist "last friday"
+# ./loglist yesterday mirrorlist
+
+logpath='/var/log/ansible'
+
+when='yesterday'
+if [ -n "$1" ]; then
+when=$1
+fi
+
+ts=`date -d "$when" +%Y/%m/%d`
+
+if [ -z "$2" ]; then
+ find $logpath/$ts -mindepth 1 -maxdepth 1 -type d -print
+exit;
+fi
+
+if [ -d $logpath/$ts/$2 ]; then
+ find $logpath/$ts/$2 -mindepth 1 -maxdepth 1 -type d -print
+else
+ echo "No such playbook log: $2"
+ exit 1
+fi
+
diff --git a/scripts/logview b/scripts/logview
new file mode 100755
index 000000000..e55d848c1
--- /dev/null
+++ b/scripts/logview
@@ -0,0 +1,25 @@
+#!/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
+