Skip to content

Instantly share code, notes, and snippets.

@tcuthbert
Created December 19, 2016 12:41
Show Gist options
  • Save tcuthbert/128b61acfce3cf8da02fc4545ace6b70 to your computer and use it in GitHub Desktop.
Save tcuthbert/128b61acfce3cf8da02fc4545ace6b70 to your computer and use it in GitHub Desktop.
from datetime import timedelta
from time import asctime, localtime, time
from trigger.cmds import Commando
class ShowTech(Commando):
"""Execute 'show clock' on a list of Cisco devices."""
vendors = ['cisco']
commands = ['show tech-support']
if __name__ == '__main__':
start = time()
print "Starting time is :", asctime(localtime(start))
device_list = ['pe1.demo.localdomain', 'pe2.demo.localdomain', 'p1.demo.localdomain', 'p2.demo.localdomain', 'p3.demo.localdomain', 'p4.demo.localdomain']
showtech = ShowTech(devices=device_list)
showtech.run() # Commando exposes this to start the event loop
print '\nResults:'
for host in showtech.results:
for line in showtech.results[host]['show tech-support'].splitlines():
if 'uffer' in line:
print line
#with open('out/{}.txt'.format(host), 'w') as f:
# f.write(showtech.results[host]['show tech-support'])
finish = time()
total_time = finish - start
print "Finishing time is :", asctime(localtime(finish))
print "Time taken to retrieve tech support from all devices: {} ({})".format(str(timedelta(seconds=int(total_time))), asctime(localtime(finish)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment