Thanks.
If we send this string:
>>> b.System_Statistics.get_gtm_ldns_statistics(
… ldns_ips = [‘0.0.0.0’]
… );
We get data like this
{‘return’: {‘time_stamp’: {‘hour’: 21, ‘month’: 2, ‘second’: 29, ‘year’: 2009, ’
day’: 27, ‘minute’: 38}, ‘statistics’: [{‘city’: ‘Unknown’, ‘statistics’: [{'tim
e_stamp’: 0, ‘type’: ‘STATISTIC_GTM_LDNS_REQUESTS’, ‘value’: {‘high’: 0, ‘low’:
718}}], ‘ldns_ip’: ‘64.212.90.163’, ‘country’: ‘UNITED STATES’, ‘last_accessed’:
1235770459, ‘state’: ‘Unknown’, ‘continent’: ‘North America’}, {‘city’: 'Unknow
n’, ‘statistics’: [{‘time_stamp’: 0, ‘type’: ‘STATISTIC_GTM_LDNS_REQUESTS’, 'val
ue’: {‘high’: 0, ‘low’: 718}}], ‘ldns_ip’: ‘64.212.90.163’, ‘country’: 'UNITED S
TATES’, ‘last_accessed’: 1235770459, ‘state’: ‘Unknown’, ‘continent’: 'North Ame
rica’}]}}
this appears as a single row, so couldnt format it to display only hit count and Ip address.
Searched online and came up with something like this that works. It needs excel to clean up though.
a = open(file)
text = a.read()
a.close()
tokens = text.split() split on whitespace
keyword = re.compile(target, re.IGNORECASE)
for index in range( len(tokens) ):
if keyword.match( tokens[index] ):
start = max(0, index-window)
finish = min(len(tokens), index+window+1)
lhs = string.join( tokens[start:index] )
rhs = string.join( tokens[index+1:finish] )
print “%s [%s] %s” % (lhs, tokens[index], rhs)