-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowVersion.py
More file actions
29 lines (25 loc) · 751 Bytes
/
showVersion.py
File metadata and controls
29 lines (25 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/bash/python3
# Save current config to a file for support
import time
import os
from netmiko import ConnectHandler
ipaddress = "10.199.199.251" # example
print("I'll attempt to ping: " + ipaddress)
response = os.system("ping -c 1 " + ipaddress)
# and then check the response...
if response == 0:
print(ipaddress, 'is up!')
print("The current time is:", time.asctime())
else:
print(ipaddress, 'is down!')
SW1 = {
'device_type': 'cisco_ios',
'host': ipaddress,
'username': 'admin',
'password': 'cisco',
'port': 22, # optional, defaults to 22
'secret': 'cisco', # optional, defaults to ''
}
net_connect = ConnectHandler(**SW1)
output = net_connect.send_command('show version')
print(output)