cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1677
Views
0
Helpful
4
Replies

Ports Status Changes between certain times on Cisco 3850s

anovis82
Level 1
Level 1

 

 

I am trying to find out which ports have been used or which ports have status changes within the day i.e between ports that have gone from down to up during the hours of 6am and 6pm etc.

Is there a way to report port or track status changes during the day?

 

Caan be from Cisco Prime or directly from the switch, script would be easier, but if there is even a manual way, then it's worth a shot.

Cisco 3850 Running 16.3.6

 

1 Accepted Solution

Accepted Solutions

You could do something like this ..  

#!/usr/bin/env python
from netmiko import ConnectHandler import re from datetime import datetime today = datetime.today().strftime('%B %d') print(today) cisco = { 'device_type': 'cisco_ios', 'host': 'REPLACE_WITH_IP', 'username': 'REPLACE_WITH_USERNAME', 'password': 'REPLACE_WITH_PASSWORD' 'port': '22' } net_connect = ConnectHandler(**cisco) output = net_connect.send_command('',expect_string=r'#',strip_command=False, strip_prompt=False) output += net_connect.send_command('show log | i UPDOWN',expect_string=r'#',strip_command=False, strip_prompt=False) net_connect.disconnect() DATE_RE = today + '.*' matched = re.findall(DATE_RE,output) for line in matched: print(line) #print(output)

tested on sandbox - 

show-log.gif

View solution in original post

4 Replies 4

omz
VIP Alumni
VIP Alumni

Hi 

You could use syslog and log the info.

You can also script .. 

Manually .. sh logging | i UPDOWN

 

Great Thanks for you help!

I will give it a go and come back and let you know how it goes.

Thanks again!

You could do something like this ..  

#!/usr/bin/env python
from netmiko import ConnectHandler import re from datetime import datetime today = datetime.today().strftime('%B %d') print(today) cisco = { 'device_type': 'cisco_ios', 'host': 'REPLACE_WITH_IP', 'username': 'REPLACE_WITH_USERNAME', 'password': 'REPLACE_WITH_PASSWORD' 'port': '22' } net_connect = ConnectHandler(**cisco) output = net_connect.send_command('',expect_string=r'#',strip_command=False, strip_prompt=False) output += net_connect.send_command('show log | i UPDOWN',expect_string=r'#',strip_command=False, strip_prompt=False) net_connect.disconnect() DATE_RE = today + '.*' matched = re.findall(DATE_RE,output) for line in matched: print(line) #print(output)

tested on sandbox - 

show-log.gif

 

Review Cisco Networking for a $25 gift card