Created
December 19, 2016 12:41
-
-
Save tcuthbert/128b61acfce3cf8da02fc4545ace6b70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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