Created
April 25, 2015 01:27
-
-
Save ozzyjohnson/3b96e40c53bef4e1596c to your computer and use it in GitHub Desktop.
awk cisco IOS cli script
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
BEGIN { | |
device_id = "" | |
entry_address = "" | |
ip_address = "" | |
platform = "" | |
capabilities = "" | |
interface = "" | |
port_id = "" | |
holdtime = "" | |
version = "" | |
advertisement_version = "" | |
duplex = "" | |
power_drawn = "" | |
power_request_id = "" | |
power_management_id = "" | |
power_request_levels_are = "" | |
management_address = "" | |
printf("device_id;ip_address;interface\n"); | |
} | |
#printf("device_id;entry_address;ip_address;platform;capabilities;interface;port id;holdtime;version;advertisement_version;duplex;power_drawn;power_request_id;power_management_id;power_request_levels_are;management_address\n"); | |
#} | |
#------------------------- | |
#Device ID: xxx | |
#Entry address(es): | |
# IP address: x.x.x.x | |
#Platform: cisco AIR-AP1242AG-A-K9 , Capabilities: Trans-Bridge | |
#Interface: FastEthernet0/43, Port ID (outgoing port): FastEthernet0 | |
#Holdtime : 148 sec | |
# | |
#Version : | |
#Cisco IOS Software, C1240 Software (C1240-K9W8-M), Version 12.4(21a)JHB1, RELEASE SOFTWARE (fc1) | |
#Technical Support: http://www.cisco.com/techsupport | |
#Copyright (c) 1986-2010 by Cisco Systems, Inc. | |
#Compiled Wed 11-Aug-10 15:55 by prod_rel_team | |
# | |
#advertisement version: 2 | |
#Duplex: full | |
#Power drawn: 15.000 Watts | |
#Power request id: 6605, Power management id: 5 | |
#Power request levels are:15000 12960 11560 5800 0 | |
#Management address(es): | |
# | |
#------------------------- | |
function trim(field) { | |
#gsub(/\s/, "", field) | |
gsub(/^[ \t]+|[ \s]+|[ \t]+$/,"",field) | |
return field; | |
} | |
/^.*Device ID:/ {split($0,a,":");device_id = a[2];} | |
#/^Entry address(es):/ {split($0,a,"=");entry_address = a[2];} | |
/^.*IP address:/ {split($0,a,":");ip_address = a[2];} | |
#/^Platform:/ {split($0,a,":");platform = a[2];} | |
/^Interface:/ {split($0,a,":");interface = a[2];} | |
#/^.*Dirs :/ {t_dirs = substr($0,13,9);c_dirs = substr($0,23,9);s_dirs = substr($0,33,9);m_dirs = substr($0,43,9);f_dirs = substr($0,53,9);e_dirs = substr($0,63,9);} | |
#/^.*Files :.*[0-9]/ {t_files = substr($0,13,9);c_files = substr($0,23,9);s_files = substr($0,33,9);m_files = substr($0,43,9);f_files = substr($0,53,9);e_files = substr($0,63,9);} | |
#/^.*Bytes :/ {t_bytes = substr($0,13,9);c_bytes = substr($0,23,9);s_bytes = substr($0,33,9);m_bytes = substr($0,43,9);f_bytes = substr($0,53,9);e_bytes = substr($0,63,9);} | |
#/^.*Times :/ {t_times = substr($0,13,9);c_times = substr($0,23,10);f_times = substr($0,53,9);e_times = substr($0,63,9);} | |
#/^.*Speed :/ {speed = $3} | |
#/^.*Ended :/ {split($0,a," :");ended = a[2]; | |
#c_dirs = trim(c_dirs); | |
/^-----------------------/ { | |
#device_id = trim(device_id); | |
#ip_address = trim(ip_address); | |
#interface = trim(interface); | |
printf("%s;%s;%s\n",device_id,ip_address,interface) | |
device_id = "" | |
ip_address = "" | |
interface = "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment