· 7 years ago · Mar 09, 2018, 04:16 PM
1host8 | UNREACHABLE! => {
2 "changed": false,
3 "msg": "[Errno None] Unable to connect to port 22 on 192.144.16.229",
4 "unreachable": true
5}
6
7host4 | SUCCESS | rc=0 >>
8; generated by kdns-config-net
9domain sammer.com
10search sammer.com
11nameserver 192.168.1.10
12nameserver 192.168.1.11
13nameserver 192.168.1.12
14
15host1 | FAILED! => {
16 "changed": false,
17 "module_stderr": "",
18 "module_stdout": "/bin/sh: /grid/common/pkgs/python/v2.7.10/bin/python2.7: No such file or directoryrn",
19 "msg": "MODULE FAILURE",
20 "rc": 0
21}
22
23#!/usr/bin/python
24# data_parse.py
25f = open('data.txt', 'r')
26for line in f:
27 if "FAILED" in line or "UNREACHABLE" in line:
28 print(line)
29f.close()
30
31host1 | UNREACHABLE! => {
32host2 | UNREACHABLE! => {
33host3 | FAILED! => {
34host4 | FAILED! => {
35
36host4 | SUCCESS | rc=0 >>
37; generated by kdns-config-net
38domain sammer.com
39search sammer.com
40nameserver 192.168.1.10
41nameserver 192.168.1.11
42nameserver 192.168.1.12
43
44inSuccess = False
45for line in f:
46 if inSuccess:
47 if "FAILED" in line or "UNREACHABLE" in line:
48 inSuccess = False
49 else:
50 print(line)
51 elif "| SUCCESS |" in line:
52 inSuccess = True
53 print(line)