Script example customsearch.py:
import urllib2, sys,csv,time
from lxml import etree
import splunk.Intersplunk as si
host = ['host1.net','host2.net']
for s in host:
url = "http://" + s + ":8080/rex/administration?files_used=true"
#print(url)
results = []
now = str(int(time.mktime(time.gmtime())))
try:
f = urllib2.urlopen(url)
doc = etree.XML(f.read())
one = doc.xpath("//str[@name='LINEUP']/text()")
two = doc.xpath("//str[@name='LINEAR']/text()")
three = doc.xpath("//str[@name='BITSET']/text()")
results.append({'_time' : now,'qe_host' : s,'Stack' : 'cim','Status' : 'up','LINEUP' : one,'LINEAR' : two,'BITSET' : three})
si.outputResults(results)
except urllib2.URLError, e:
results.append({'_time' : 'now','qe_host' : s,'Stack' : 'cim','Status' : 'down','LINEUP' : '','LINEAR' : '','BITSET' : ''})
si.outputResults(results)
f.close()
commands.conf
[customsearch]
filename = customsearch.py
generating = true
maxinputs = 1
... View more