Quick Script to check the uptime of ASR920's

Mel Beckman mel at beckman.org
Wed Feb 20 19:20:18 UTC 2019

I realize you’re aiming for the NETCONF paradigm, but for anyone interested, a more consistent, device- and release-independent method is to just query the SNMP uptime variable:

$ snmpget -v 1 -c demopublic system.sysUpTime.0

system.sysUpTime.0 = Timeticks: (586731977) 67 days, 21:48:39.77

 -mel beckman

On Feb 20, 2019, at 11:00 AM, Benoit Claise via NANOG <nanog at nanog.org<mailto:nanog at nanog.org>> wrote:


Just in case you want to go into/learn the data model-driven management, here is a NETCONF/YANG script.

CiscoRouterUptimeNETCONF) dvulovic at DVULOVIC-D2DW2:~/python-venv/CiscoRouterUptimeNETCONF$ ./CiscoRouterUptimeNETCONF.py testinput

CiscoRouterUptimeNETCONF by Djordje Vulovic (dvulovic at cisco.com<mailto:dvulovic at cisco.com>)


Router has uptime of 5724548.0 seconds (66 days, 6:09:08)

Router has uptime of 5724551.0 seconds (66 days, 6:09:11)

Router has uptime of 5724555.0 seconds (66 days, 6:09:15)

Router has uptime of 5724557.0 seconds (66 days, 6:09:17)

Router has uptime of 5724497.0 seconds (66 days, 6:08:17)

(CiscoRouterUptimeNETCONF) dvulovic at DVULOVIC-D2DW2:~/python-venv/CiscoRouterUptimeNETCONF$ ./CiscoRouterUptimeNETCONF.py

CiscoRouterUptimeNETCONF by Djordje Vulovic (dvulovic at cisco.com<mailto:dvulovic at cisco.com>)


Usage: CiscoRouterUptimeNETCONF <file>

File consists of lines <mgmt ip>,<NETCONF port>,<username>,<password>

The script was tested on a real ASR920, running IOS 16.8.1
See the source code at https://github.com/djordjevulovic/CiscoRouterUptimeNETCONF

Thanks to Djordje for developing this script.

Regards, Benoit


I just created a quick script to check the uptime of a ASR920 via SNMP if you have a fairly long list of devices. It's a simple bash script and snmpwalk version 2c. Figured I would share it with you. Happy Friday

Grab the code from GitHub: https://github.com/esundberg/CiscoRouterUptime
It's a quick and dirty script and my first repo on github. Let me know if there any issues with it.

Output Format in CSV
DeviceName, IP, Uptime in Days, OK/Warning

I set my warning to 800 Days, you can change this in the code

ASR920-1.SEA1,, SuperSecretSNMPKey
ASR920-2.SEA1,, SuperSecretSNMPKey
~~~~snip you get the idea~~~~


[user at Linux]$ ./CiscoRouterUptime.sh ASR920list.txt
ASR920-1.SEA1,, 827, WARNING
ASR920-2.SEA1,, 827, WARNING
ASR920-2.ATL1,, 828, WARNING
ASR920-1.ATL1,, 813, WARNING
ASR920-1.CHI1,, 828, WARNING
ASR920-1.NYC1,, 787, OK
ASR920-2.CHI1,, 720, OK
ASR920-3.CHI1,, 720, OK
ASR920-1.DAL1,, 488, OK
ASR920-4.CHI1,, 142, OK


CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents, files or previous e-mail messages attached to it may contain confidential information that is legally privileged. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of any of the information contained in or attached to this transmission is STRICTLY PROHIBITED. If you have received this transmission in error please notify the sender immediately by replying to this e-mail. You must destroy the original transmission and its attachments without reading or saving in any manner. Thank you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nanog.org/pipermail/nanog/attachments/20190220/eae61bc0/attachment.html>

More information about the NANOG mailing list