06-17-2025
11:06 AM
- last edited on
06-17-2025
05:45 PM
by
frsierra
In an effort to consolidate C3850 switches (ver 16.12.11) , I am looking at log messages to determine ports that have been active in the past two months. I have very little scripting background but is looking for a script to search throught the syslog messaged for up/down stats on all the ports on a switch and compile a report.
06-17-2025 01:46 PM
With every environment being a little bit different, you might not find a script that works perfectly for you, but could use some adjustments.
For example, since you mention a couple of months back in time, can I safely(?) assume that you're sending all the logs to a central syslog server?
If not: we're relying on the syslog buffer that might not cover this time period. (and is cleared at restart).
If yes: how are the logs managed? Is it in a single big file, or separate file per day, or per device, or both, etc?
Keep in mind that any ports that has not changed (either up or down) in the last 2 months, is then not going to be a part of the report.
So you would need manual work on top to identify ports that were either consistently down or up during that timeframe.
But before going down this route, consider other ways:
If you're adventurous, this could be a good example for any of the AI LLMs (ChatGPT or similar).
For example, pasting 2-3 lines of LINEPROTO-5-UPDOWN logs into ChatGPT and ask for a python script that would read a log file and create a summary based on when the latest event for a port.
(If you have all the logs in one big single log file)
06-17-2025 02:55 PM
From a high-level overview, use the command "sh interface counters". Eliminate all the ports with 0 utilization.
Any port worth taking a look, use the following command: sh interface PORT | include Last input
We use a 3rd party NMS server which can give us an audit of ports not used for X amount of days.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide